From f848c682f3192a7dbb932535c649d101734d4b09 Mon Sep 17 00:00:00 2001 From: Ethan Dennis Date: Mon, 19 Sep 2022 12:55:34 -0700 Subject: [PATCH 1/6] Set DOCKER_ARGS variable in codespace --- .devcontainer/devcontainer.json | 3 +++ gitlab/bootstrap/setup.sh | 4 ---- jenkins/bootstrap/setup.sh | 4 ---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f1f0b7a..40f6a92 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,6 +13,9 @@ "--privileged", "--init" ], + "remoteEnv": { + "DOCKER_ARGS": "--network=host" + }, // Add the IDs of extensions you want installed when the container is created. "extensions": [ "ms-azuretools.vscode-docker" diff --git a/gitlab/bootstrap/setup.sh b/gitlab/bootstrap/setup.sh index 021ce64..27006ba 100755 --- a/gitlab/bootstrap/setup.sh +++ b/gitlab/bootstrap/setup.sh @@ -33,10 +33,6 @@ else docker exec -it gitlab update-permissions &> /dev/null fi -# allow valet to talk to GitLab by removing network isolation between containers -export DOCKER_ARGS="--network=host" -`grep -q "export DOCKER_ARGS=" ~/.bashrc || echo 'export DOCKER_ARGS="--network=host"' >> ~/.bashrc` - echo -e "Waiting for GitLab to be ready. This might take a while \U23F0" until $(curl --output /dev/null --silent --head --fail http://localhost); do printf '.' diff --git a/jenkins/bootstrap/setup.sh b/jenkins/bootstrap/setup.sh index 5947fa4..e843745 100755 --- a/jenkins/bootstrap/setup.sh +++ b/jenkins/bootstrap/setup.sh @@ -18,10 +18,6 @@ else docker run -d --name jenkins -p 8080:8080 --env JENKINS_ADMIN_ID=$username --env JENKINS_ADMIN_PASSWORD=$password jenkins:$container_name fi -# allow valet to talk to Jenkins by removing network isolation between containers -export DOCKER_ARGS="--network=host" -grep -q "export DOCKER_ARGS=" ~/.bashrc || echo 'export DOCKER_ARGS="--network=host"' >> ~/.bashrc - echo -e "\nWaiting for Jenkins to start..." while ! curl -s http://localhost:8080/ > /dev/null; do printf "." From cf5156055a957a4cfb3c56565dce7acc74863e3b Mon Sep 17 00:00:00 2001 From: Nate Rickard Date: Mon, 19 Sep 2022 16:58:24 -0400 Subject: [PATCH 2/6] output to tmp/dry-run for consistency --- gitlab/5-custom-transformers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitlab/5-custom-transformers.md b/gitlab/5-custom-transformers.md index 7466dc9..cce52f3 100644 --- a/gitlab/5-custom-transformers.md +++ b/gitlab/5-custom-transformers.md @@ -18,7 +18,7 @@ In this lab you will build upon the `dry-run` command to override Valet's defaul You will be performing a `dry-run` command to inspect the workflow that is converted by default. Run the following command within the codespace terminal: ```bash -gh valet dry-run gitlab --output-dir tmp --namespace valet --project terraform-example +gh valet dry-run gitlab --output-dir tmp/dry-run --namespace valet --project terraform-example ``` The converted workflow that is generated by the above command can be seen below: @@ -95,7 +95,7 @@ This method can use any valid ruby syntax and should return a `Hash` that repres Now you can perform another `dry-run` command and use the `--custom-transformers` CLI option to provide this custom transformer. Run the following command within your codespace terminal: ```bash -gh valet dry-run gitlab --output-dir tmp --namespace valet --project terraform-example --custom-transformers transformers.rb +gh valet dry-run gitlab --output-dir tmp/dry-run --namespace valet --project terraform-example --custom-transformers transformers.rb ``` The converted workflow that is generated by the above command will now use the custom logic for the `artifacts.terraform` step. From f7a72f901ddbdf54bbcd97fe5cf39973c6ff884b Mon Sep 17 00:00:00 2001 From: Ethan Dennis Date: Mon, 19 Sep 2022 14:02:05 -0700 Subject: [PATCH 3/6] Add default settings in codespace --- .devcontainer/devcontainer.json | 44 +++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 40f6a92..4f970ad 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,23 +2,29 @@ "name": "Codespace to perform Valet Labs", "image": "mcr.microsoft.com/vscode/devcontainers/universal:linux", "remoteUser": "codespace", - "overrideCommand": false, - "mounts": [ - "source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume" - ], - "runArgs": [ - "--cap-add=SYS_PTRACE", - "--security-opt", - "seccomp=unconfined", - "--privileged", - "--init" - ], - "remoteEnv": { + "overrideCommand": false, + "mounts": [ + "source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume" + ], + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined", + "--privileged", + "--init" + ], + "remoteEnv": { "DOCKER_ARGS": "--network=host" - }, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "ms-azuretools.vscode-docker" - ], - "postCreateCommand": "gh extension install github/gh-valet || echo 'Could not auto-build. Skipping.' " -} + }, + "customizations": { + "vscode": { + "settings": { + "files.autoSave": "onFocusChange" + }, + "extensions": [ + "ms-azuretools.vscode-docker" + ] + } + }, + "postCreateCommand": "gh extension install github/gh-valet || echo 'Could not auto-build. Skipping.' " +} \ No newline at end of file From aa600253560d3fa58ad58c264d015a1980ea1c54 Mon Sep 17 00:00:00 2001 From: Nate Rickard Date: Mon, 19 Sep 2022 17:03:40 -0400 Subject: [PATCH 4/6] clarify placement of env --- azure_devops/5-custom-transformers.md | 2 +- gitlab/5-custom-transformers.md | 2 +- jenkins/5-custom-transformers.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azure_devops/5-custom-transformers.md b/azure_devops/5-custom-transformers.md index 8b2658a..5b72d1f 100644 --- a/azure_devops/5-custom-transformers.md +++ b/azure_devops/5-custom-transformers.md @@ -149,7 +149,7 @@ Open the workflow that is generated and inspect the contents. Now the `DotnetCor You can also use custom transformers to edit the values of environment variables in converted workflows. In this example, you will be updating the `BUILDCONFIGURATION` environment variable to be `Debug` instead of `Release`. -To do this, add the following code to the `transformers.rb` file. +To do this, add the following code at the top of the `transformers.rb` file. ```ruby env "BUILDCONFIGURATION", "Debug" diff --git a/gitlab/5-custom-transformers.md b/gitlab/5-custom-transformers.md index cce52f3..77a5fca 100644 --- a/gitlab/5-custom-transformers.md +++ b/gitlab/5-custom-transformers.md @@ -119,7 +119,7 @@ end You can also use custom transformers to edit the values of environment variables in converted workflows. In this example, you will update the `PLAN_JSON` environment variable to be `custom_plan.json` instead of `plan.json`. -To do this, add the following code to the `transformers.rb` file. +To do this, add the following code at the top of the `transformers.rb` file. ```ruby env "PLAN_JSON", "custom_plan.json" diff --git a/jenkins/5-custom-transformers.md b/jenkins/5-custom-transformers.md index 91a9f6e..913fab4 100644 --- a/jenkins/5-custom-transformers.md +++ b/jenkins/5-custom-transformers.md @@ -205,7 +205,7 @@ Now you can perform another `dry-run` command with the `--custom-transformers` C You can also use custom transformers to edit the values of environment variables in converted workflows. In this example, you will be updating the `DB_ENGINE` environment variable to be `mongodb` instead of `sqlite`. -To do this, add the following code to the `transformers.rb` file. +To do this, add the following code at the top of the `transformers.rb` file. ```ruby env "DB_ENGINE", "mongodb" From 216b844d6bd75485acdfbb192a0b73c003360f4b Mon Sep 17 00:00:00 2001 From: Ethan Dennis Date: Mon, 19 Sep 2022 15:19:57 -0700 Subject: [PATCH 5/6] Set installation_type to labs --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4f970ad..ba5c350 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -14,7 +14,8 @@ "--init" ], "remoteEnv": { - "DOCKER_ARGS": "--network=host" + "DOCKER_ARGS": "--network=host", + "INSTALLATION_TYPE": "labs" }, "customizations": { "vscode": { From 59b717f5460cf60b1a56239276a9866a75ee8d78 Mon Sep 17 00:00:00 2001 From: Ethan Dennis Date: Mon, 19 Sep 2022 16:46:46 -0700 Subject: [PATCH 6/6] Update .devcontainer/devcontainer.json Co-authored-by: Luke Cheung Engle <99493186+luke-engle@users.noreply.github.com> --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ba5c350..7145591 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -20,7 +20,8 @@ "customizations": { "vscode": { "settings": { - "files.autoSave": "onFocusChange" + "files.autoSave": "onFocusChange", + "editor.tabSize": 2 }, "extensions": [ "ms-azuretools.vscode-docker"