Merge branch 'feature/circleci-labs' of https://github.com/valet-customers/labs into luke-edits

This commit is contained in:
Luke Engle
2022-09-20 12:42:45 -07:00
18 changed files with 1201 additions and 147 deletions
+39 -28
View File
@@ -13,41 +13,52 @@ You will need to complete all of the setup instructions [here](./readme.md#confi
```
2. Open the GitLab server in a new browser tab:
- Click the `PORTS` tab in the codespace terminal window.
- In the `PORTS` tab find the row for port 80.
- Hover over the address under the `Local Address` column and click the globe to "open in browser".
- Click the `PORTS` tab in the codespace terminal window.
- In the `PORTS` tab find the row for port 80.
- Hover over the address under the `Local Address` column and click the globe to "open in browser".
3. Create a GitLab personal access token (PAT):
- Authenticate with the GitLab server using the following credentials:
- Username: `root`
- Password: `valet-labs!`
- Follow the GitLab [instructions](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token) to generate a PAT.
- Ensure the token has the `read_api` scope.
- Copy the generated token and save it in a safe location.
- Authenticate with the GitLab server using the following credentials:
- Username: `root`
- Password: `valet-labs!`
- Follow the GitLab [instructions](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token) to generate a PAT.
- Ensure the token has the `read_api` scope.
- Copy the generated token and save it in a safe location.
4. Create a GitHub personal access token (PAT):
- Open github.com in a new browser tab.
- In the top right corner of the UI, click your profile photo and click `Settings`.
- In the left panel, click `Developer Settings`.
- Click `Personal access tokens` and then `Legacy tokens` (if present).
- Click `Generate new token` and then `Generate new legacy token`. You may be required to authenticate with GitHub during this step.
- Name your token in the `Note` field.
- Select the following scopes: `workflow` and `read:packages`.
- Click `Generate token`.
- Copy the generated PAT and save it in a safe location.
- Open github.com in a new browser tab.
- In the top right corner of the UI, click your profile photo and click `Settings`.
- In the left panel, click `Developer Settings`.
- Click `Personal access tokens` and then `Legacy tokens` (if present).
- Click `Generate new token` and then `Generate new legacy token`. You may be required to authenticate with GitHub during this step.
- Name your token in the `Note` field.
- Select the following scopes: `workflow` and `read:packages`.
- Click `Generate token`.
- Copy the generated PAT and save it in a safe location.
5. Run the `configure` CLI command:
- Select the `TERMINAL` tab from within the codespace terminal window.
- Run the following command: `gh valet configure`.
- Use the down arrow key to highlight `GitLab CI`, press the spacebar to select, and then press enter to continue.
- At the GitHub handle prompt, enter the GitHub handle used to generate the GitHub PAT in step 2 and press enter.
- At the GitHub Container Registry prompt, enter the GitHub PAT generated in step 4 and press enter.
- At the GitHub PAT prompt, enter the GitHub PAT generated in step 4 and press enter.
- At the GitHub URL prompt, enter the GitHub instance URL or press enter to accept the default value (`https://github.com`).
- At the GitLab CI token prompt, enter the GitLab CI access token from step 3 and press enter.
- At the GitLab CI URL prompt, enter `http://localhost` and press enter.
- Select the `TERMINAL` tab from within the codespace terminal window.
- Run the following command: `gh valet configure`.
- Use the down arrow key to highlight `GitLab CI`, press the spacebar to select, and then press enter to continue.
- At the GitHub handle prompt, enter the GitHub handle used to generate the GitHub PAT in step 2 and press enter.
- At the GitHub Container Registry prompt, enter the GitHub PAT generated in step 4 and press enter.
- At the GitHub PAT prompt, enter the GitHub PAT generated in step 4 and press enter.
- At the GitHub URL prompt, enter the GitHub instance URL or press enter to accept the default value (`https://github.com`).
- At the GitLab CI token prompt, enter the GitLab CI access token from step 3 and press enter.
- At the GitLab CI URL prompt, enter `http://localhost` and press enter.
![img](https://user-images.githubusercontent.com/18723510/183990474-d0b2559c-d2bf-40d9-ac43-19af53e45329.png)
```console
$ gh valet configure
✔ Which CI providers are you configuring?: GitLab CI
Enter the following values (leave empty to omit):
✔ GitHub handle used to authenticate with the GitHub Container Registry: mona
✔ Personal access token to authenticate with the GitHub Container Registry: ***************
✔ Personal access token for GitHub: ***************
✔ Base url of the GitHub instance: https://github.com
✔ Private token for GitLab: ***************
✔ Base url of the GitLab instance: https://gitlab.com
Environment variables successfully updated.
```
## Verify your environment
+3 -3
View File
@@ -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:
@@ -115,7 +115,7 @@ end
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.
@@ -131,7 +131,7 @@ The converted workflow that is generated by the above command will now use the c
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"
-4
View File
@@ -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 '.'