-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Oppleg for versjonsstyring av malar (#1060)
* Konfig for Unleash for brevbaker * Unleash-konfig * Skriv om så oppsett og overstyring av feature toggle kun kan gjerast ved initialisering, og dermed unngå risikoen for at nokon på eit tidspunkt misbruker overrides-funksjonaliteten * Gjer om builder frå objekt til klasse, så testane kan køyre utan å gå i frø * POC-commit for å vise korleis det kan funke * Som det er no blir malane lese inn kun ved oppstart, og toggle-styring av dei blir kun oppdatert ved oppstart av systemet. Det er ikkje bra nok, så refaktoriserer for å leggje til rette for oppdatering undervegs * POC-commit for å vise korleis det kan funke * Revert "POC-commit for å vise korleis det kan funke" This reverts commit 0303a8a. * Revert "POC-commit for å vise korleis det kan funke" This reverts commit 0aa973b. * Kommentar for å tydeleggjera tenkt bruk * Konfig for Unleash for brevbaker også i docker-compose * Satt opp fetch-secrets også for azuread, det treng vi jo også for å køyre brevbaker no * Presiserer appname i bygg også * Skrur på fullstendig logging av stacktrace ved feil undervegs i gradle * Effektiviserer bygga våre ved å skru på gradle-caching * Nytt forsøk på fullverdig logging av feil * Litt ekstra indireksjon for å unngå å initialisere Unleash unødig i testsamanheng * Oppsett for testane * Vi kan jo bruke Unleash-sdken sin innebygde fake heller enn å lage vår eigen * Unngå unødig builder-metode-bruk * Ekstra mykje event-logging for integrasjonstestane * Prøver å pinpointe feilen * Kanskje det var manglande miljøvariablar som var problemet * Roar ned logginga no når ting funkar * Rettar feil mappenamn * Oppdaterer unleash-token-referanse * Prøver litt meir flytande kotlinsk måte å gjera det på * Tar bort debuglogging som eigentleg ikkje er så nyttig * Gjer template-map privat, så vi ikkje risikerer at nokon bruker den ved eit uhell seinare * Loggar når oppsettet er ferdig på ordentleg måte * Får ut rett kode også for metadata * Rettar opp i fetch-secrets
- Loading branch information
1 parent
771d0e7
commit 12afdc4
Showing
21 changed files
with
346 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
*.iml | ||
*.ipr | ||
*.iws | ||
/docs | ||
/docs | ||
/secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: unleash.nais.io/v1 | ||
kind: ApiToken | ||
metadata: | ||
name: {{ app-name }} | ||
namespace: pensjonsbrev | ||
spec: | ||
unleashInstance: | ||
apiVersion: unleash.nais.io/v1 | ||
kind: RemoteUnleash | ||
name: teampensjon | ||
secretName: {{ app-name }}-unleash-api-token | ||
|
||
# Specify which environment the API token should be created for. | ||
# Can be one of: development, or production. | ||
environment: development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: unleash.nais.io/v1 | ||
kind: ApiToken | ||
metadata: | ||
name: {{ app-name }} | ||
namespace: pensjonsbrev | ||
spec: | ||
unleashInstance: | ||
apiVersion: unleash.nais.io/v1 | ||
kind: RemoteUnleash | ||
name: teampensjon | ||
secretName: {{ app-name }}-unleash-api-token | ||
|
||
# Specify which environment the API token should be created for. | ||
# Can be one of: development, or production. | ||
environment: production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
|
||
KUBE_CLUSTER="dev-gcp" | ||
|
||
function checkKubectl() { | ||
echo "Verify kubectl, may take some time..." | ||
output="$(kubectl --context $KUBE_CLUSTER version 2>&1)" | ||
status=$? | ||
|
||
if [ $status -gt 0 ] ; then | ||
if echo "$output" | grep -q "command not found" ; then | ||
echo "ERROR: You need to install kubectl: $output" | ||
echo "Howto: https://doc.nais.io/basics/access/" | ||
return $status | ||
|
||
elif echo "$output" | grep -q "Unable to connect to the server" ; then | ||
error_msg="$(echo "$output" | grep "Unable to connect to the server" | cut -d':' -f2)" | ||
echo "ERROR: Cannot connect to kubernetes cluster $KUBE_CLUSTER: $error_msg" | ||
echo "Have you remembered to connect naisdevice? (see https://doc.nais.io/basics/access/)" | ||
return 1 | ||
|
||
elif echo "$output" | grep -q "error: You must be logged in" ; then | ||
echo "ERROR: Not logged in to the cluster. Use 'gcloud auth login' (see https://doc.nais.io/basics/access/)." | ||
return 1 | ||
|
||
else | ||
echo "WARN: Got unknown error from kubectl, but will attempt to fetch secrets anyway." | ||
return 0 | ||
|
||
fi | ||
elif echo "$output" | grep -q "Client Version" && echo "$output" | grep -q "Server Version" ; then | ||
echo "kubectl: OK " | ||
return 0 | ||
else | ||
echo "WARN: Got unexpected output from 'kubectl version', but will attempt to fetch secrets anyway." | ||
return 0 | ||
fi | ||
} | ||
|
||
checkKubectl || exit 1 | ||
jq --version || ( | ||
echo "ERROR: You need to install the jq CLI tool on your machine: https://stedolan.github.io/jq/" && exit 1 | ||
) || exit 1 | ||
which base64 || ( | ||
echo "ERROR: You need to install the base64 tool on your machine. (brew install base64 on macOS)" && exit 1 | ||
) || exit 1 | ||
|
||
function getSecret() { | ||
local secret_name="$1" | ||
local output_name="$2" | ||
|
||
echo "" | ||
kubectl --context $KUBE_CLUSTER -n pensjonsbrev get secret "${secret_name}" -o json | jq '.data | map_values(@base64d)' > secrets/"${output_name}".json | ||
|
||
echo "Creating ${output_name}.env file from ${output_name}.json..." | ||
jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' secrets/"${output_name}".json > secrets/"${output_name}".env | ||
echo "${output_name}.env file created in the \"secrets\" folder." | ||
|
||
} | ||
|
||
mkdir -p secrets | ||
|
||
# AzureAD | ||
secret_name="$(kubectl --context $KUBE_CLUSTER -n pensjonsbrev get azureapp pensjon-brevbaker -o=jsonpath='{.spec.secretName}')" | ||
getSecret "$secret_name" azuread | ||
|
||
# Unleash ApiToken | ||
getSecret pensjon-brevbaker-unleash-api-token unleash | ||
|
||
echo "All secrets are fetched and stored in the \"secrets\" folder." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.