Repository: Azure/ARO-RP
Pull request #1932 (2022-02-02 19:00:14)

Better support for multiple envs
### Which issue this PR addresses:

<!--
Please include a link to the ADO work item as well as any GitHub issues.

Usage: `Fixes #<GitHub issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes https://msazure.visualstudio.com/AzureRedHatOpenShift/_workitems/edit/13111265/
(ref #1917 point 1)

### What this PR does / why we need it:

<!--
Include a brief summary of what the PR is intended to accomplish and how the PR
does it. (2-3 sentences)
-->

The current setup makes no distinction between different environment types. By splitting up configuration into two files, it is less likely that a developer forgets to comment out envvars in `./env` when swapping between "full" and "regular" type environments - instead, they source the file that makes the most sense for what they want to do. This solution also maintains backwards compatibility with the old instruction set if devs still want to go that route.

### Test plan for issue:

<!--
How did you test that this PR works?

- Are there unit tests?
- Are there integration/e2e tests?
- If it is not possible to write automated tests, explain why and document how
  to manually test and verify the feature.
-->

N/A - changing dev instructions/workflow

### Is there any documentation that needs to be updated for this PR?

<!--
- If yes and the docs are in GitHub, include doc updates in the PR.
- If yes and the docs are not in GitHub (i.e. ADO wiki), include a link to the
  docs.
- If no, explain why (e.g. "tech debt cleanup, N/A").
-->

Instructions have been modified and committed here.


SudoBrendan: /azp run ci
azure-pipelines[bot]: <samp>
Azure Pipelines successfully started running 1 pipeline(s).<br>

</samp>
SudoBrendan: /azp run e2e
azure-pipelines[bot]: <samp>
Azure Pipelines successfully started running 1 pipeline(s).<br>

</samp>

Patch:
diff --git a/.gitignore b/.gitignore
index f8e72571b..9117184c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,7 @@ gomock_reflect_*
 /e2e.test
 /env*
 !/env.example
+!/env-int.example
 /id_rsa
 /proxy
 /pyenv*
diff --git a/Makefile b/Makefile
index e57f07af2..d79a24eb0 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,7 @@ SHELL = /bin/bash
 TAG ?= $(shell git describe --exact-match 2>/dev/null)
 COMMIT = $(shell git rev-parse --short=7 HEAD)$(shell [[ $$(git status --porcelain) = "" ]] || echo -dirty)
 ARO_IMAGE_BASE = ${RP_IMAGE_ACR}.azurecr.io/aro
+E2E_FLAGS ?= -test.timeout 180m -test.v -ginkgo.v
 
 # fluentbit version must also be updated in RP code, see pkg/util/version/const.go
 FLUENTBIT_VERSION = 1.7.8-1
@@ -141,7 +142,7 @@ e2e.test:
 	go test ./test/e2e -tags e2e,codec.safe -c -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" -o e2e.test
 
 test-e2e: e2e.test
-	./e2e.test -test.timeout 180m -test.v -ginkgo.v
+	./e2e.test $(E2E_FLAGS)
 
 test-go: generate build-all validate-go lint-go unit-test-go
 
diff --git a/docs/deploy-development-rp.md b/docs/deploy-development-rp.md
index 12f00a2dd..aa01e63e0 100644
--- a/docs/deploy-development-rp.md
+++ b/docs/deploy-development-rp.md
@@ -150,7 +150,7 @@
   curl -X PATCH -k "https://localhost:8443/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$RESOURCEGROUP/providers/Microsoft.RedHatOpenShift/openShiftClusters/$CLUSTER?api-version=admin" --header "Content-Type: application/json" -d "{}"
   ```
 
-* Get Cluster detials of a dev cluster
+* Get Cluster details of a dev cluster
   ```bash
   curl -X GET -k "https://localhost:8443/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$RESOURCEGROUP/providers/Microsoft.RedHatOpenShift/openShiftClusters/$CLUSTER?api-version=admin" --header "Content-Type: application/json" -d "{}"
   ```
diff --git a/docs/deploy-full-rp-service-in-dev.md b/docs/deploy-full-rp-service-in-dev.md
index a2746d0f2..c9f01a799 100644
--- a/docs/deploy-full-rp-service-in-dev.md
+++ b/docs/deploy-full-rp-service-in-dev.md
@@ -21,24 +21,11 @@
     make dev-config.yaml
     ```
 
-1. Update and resource your environment file
-    > It should look something like below once completed
+1. Create a full environment file, which overrides some default `./env` options when sourced
     ```bash
-    export LOCATION=eastus
-    export ARO_IMAGE=arointsvc.azurecr.io/aro:latest
-
-    . secrets/env
-
-    export RESOURCEGROUP=$USER-aro-$LOCATION
-    export DATABASE_ACCOUNT_NAME=$USER-aro-$LOCATION
-    export DATABASE_NAME=ARO
-    export KEYVAULT_PREFIX=$USER-aro-$LOCATION
-    export ARO_IMAGE=${USER}aro.azurecr.io/aro:$(git rev-parse --short=7 HEAD)$([[ $(git status --porcelain) = "" ]] || echo -dirty)
-    export FLUENTBIT_IMAGE=${USER}aro.azurecr.io/fluentbit:latest
-    ```
-
-    ```bash
-    . ./env
+    cp env-int.example env-int
+    vi env-int
+    . ./env-int
     ```
 
 1. Run `make deploy`
@@ -104,6 +91,7 @@
         export SRC_AUTH_QUAY=$(echo $USER_PULL_SECRET | jq -r '.auths."quay.io".auth')
         export SRC_AUTH_REDHAT=$(echo $USER_PULL_SECRET | jq -r '.auths."registry.redhat.io".auth')
         export DST_AUTH=$(echo -n '00000000-0000-0000-0000-000000000000:'$(az acr login -n ${DST_ACR_NAME} --expose-token | jq -r .accessToken) | base64 -w0)
+        ```
 
     1. Login to the Azure Container Registry
         ```bash
diff --git a/env-int.example b/env-int.example
new file mode 100644
index 000000000..08e0d574c
--- /dev/null
+++ b/env-int.example
@@ -0,0 +1,9 @@
+. ./env
+
+# Overrides for a full int-like local environment
+export RESOURCEGROUP=$USER-aro-$LOCATION
+export DATABASE_ACCOUNT_NAME=$USER-aro-$LOCATION
+export DATABASE_NAME=ARO
+export KEYVAULT_PREFIX=$USER-aro-$LOCATION
+export ARO_IMAGE=${USER}aro.azurecr.io/aro:$(git rev-parse --short=7 HEAD)$([[ $(git status --porcelain) = "" ]] || echo -dirty)
+export FLUENTBIT_IMAGE=${USER}aro.azurecr.io/fluentbit:latest
\ No newline at end of file


Test patch:
diff --git a/docs/testing.md b/docs/testing.md
index cac756424..9f0717662 100644
--- a/docs/testing.md
+++ b/docs/testing.md
@@ -42,6 +42,8 @@ E2e tests can also be run locally as follows:
 - Run the `make test-e2e` target
 - Delete the cosmos database, if applicable
 
+You can also modify the flags passed to the e2e.test run by setting the E2E_FLAGS environment variable before running `make test-e2e`.
+
 These steps can be acheived using commands below.  Look at the [e2e helper
 file](../hack/e2e/run-rp-and-e2e.sh) to understand each of the bash functions
 below.