From 1f1fb9336b74d449afbc6fedc59533ff35f8bd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Pedroza?= Date: Mon, 13 Jun 2022 17:18:06 -0300 Subject: [PATCH] fix(lint): lint bugs variables --- lib/functions/validate.sh | 8 ++++---- lib/functions/var.sh | 3 ++- .../install/aws/src/unix/formula/formula.sh | 1 + .../install/digitalocean/src/unix/formula/formula.sh | 1 + vkpr/ingress/install/src/unix/formula/formula.sh | 2 +- vkpr/kong/deck/dump/src/unix/formula/formula.sh | 4 ++-- vkpr/kong/deck/sync/src/unix/formula/formula.sh | 6 +++--- vkpr/mockserver/install/src/unix/formula/formula.sh | 2 +- vkpr/postgres/install/src/unix/formula/formula.sh | 9 +++------ vkpr/vault/install/src/unix/formula/formula.sh | 10 +++++++--- vkpr/whoami/install/src/unix/formula/formula.sh | 2 +- 11 files changed, 26 insertions(+), 22 deletions(-) diff --git a/lib/functions/validate.sh b/lib/functions/validate.sh index ce7a6cd5..8af1e04a 100644 --- a/lib/functions/validate.sh +++ b/lib/functions/validate.sh @@ -98,7 +98,7 @@ validatePostgresqlPassword() { validatePostgresqlMetrics() { if validateBool $1 | grep -q "error" ; then - error "Invalid value for postgresql.metrics, please insert true or false" + error "Invalid value for postgresql.metrics, please insert true or false" exit else return @@ -165,7 +165,7 @@ validateBool(){ if [[ $(echo $1 | tr '[:upper:]' '[:lower:]') =~ ^true|false$ ]]; then return else - echo "error" + echo "error" exit fi } @@ -226,9 +226,9 @@ validateKongRBACPsw() { validateHA(){ if validateBool $1 | grep -q "error" ; then - error "It was not possible to identify if the application will have High Availability " + error "It was not possible to identify if the application will have High Availability " exit else return fi -} \ No newline at end of file +} diff --git a/lib/functions/var.sh b/lib/functions/var.sh index 921d9460..0959c97c 100644 --- a/lib/functions/var.sh +++ b/lib/functions/var.sh @@ -12,4 +12,5 @@ export VKPR_GLAB=$VKPR_HOME/bin/glab \ VKPR_KUBECTL=$VKPR_HOME/bin/kubectl \ VKPR_HELM=$VKPR_HOME/bin/helm \ VKPR_JQ=$VKPR_HOME/bin/jq \ - VKPR_YQ=$VKPR_HOME/bin/yq + VKPR_YQ=$VKPR_HOME/bin/yq \ + VKPR_DECK=$VKPR_HOME/bin/deck diff --git a/vkpr/cert-manager/install/aws/src/unix/formula/formula.sh b/vkpr/cert-manager/install/aws/src/unix/formula/formula.sh index 57fd25b8..4bb770f3 100755 --- a/vkpr/cert-manager/install/aws/src/unix/formula/formula.sh +++ b/vkpr/cert-manager/install/aws/src/unix/formula/formula.sh @@ -108,6 +108,7 @@ configureDNS01() { validateAwsRegion "$AWS_REGION" echoColor "bold" "$(echoColor "green" "Setting AWS secret...")" + # shellcheck disable=SC2086 $VKPR_KUBECTL create secret generic route53-secret -n "$VKPR_ENV_CERT_MANAGER_NAMESPACE" --from-literal="secret-access-key=$AWS_SECRET_KEY" $DRY_RUN_FLAGS $VKPR_KUBECTL label secret route53-secret -n "$VKPR_ENV_CERT_MANAGER_NAMESPACE" vkpr=true app.kubernetes.io/instance=cert-manager 2> /dev/null diff --git a/vkpr/cert-manager/install/digitalocean/src/unix/formula/formula.sh b/vkpr/cert-manager/install/digitalocean/src/unix/formula/formula.sh index e5028510..01767abc 100755 --- a/vkpr/cert-manager/install/digitalocean/src/unix/formula/formula.sh +++ b/vkpr/cert-manager/install/digitalocean/src/unix/formula/formula.sh @@ -103,6 +103,7 @@ configureDNS01() { validateDigitalOceanApiToken "$DO_TOKEN" echoColor "bold" "$(echoColor "green" "Setting DO secret...")" + # shellcheck disable=SC2086 $VKPR_KUBECTL create secret generic digitalocean-secret -n $VKPR_ENV_CERT_MANAGER_NAMESPACE --from-literal="access-token=$DO_TOKEN" $DRY_RUN_FLAGS $VKPR_KUBECTL label secret digitalocean-secret -n $VKPR_ENV_CERT_MANAGER_NAMESPACE vkpr=true app.kubernetes.io/instance=cert-manager 2> /dev/null diff --git a/vkpr/ingress/install/src/unix/formula/formula.sh b/vkpr/ingress/install/src/unix/formula/formula.sh index 9a7316cd..55c13120 100755 --- a/vkpr/ingress/install/src/unix/formula/formula.sh +++ b/vkpr/ingress/install/src/unix/formula/formula.sh @@ -70,7 +70,7 @@ settingIngress() { fi if [[ "$VKPR_ENV_INGRESS_SSL" == "true" ]]; then - [[ "$VKPR_ENV_INGRESS_SSL_SECRET" == "nginx-cert" ]] && $VKPR_KUBECTL create secret tls nginx-cert -n $VKPR_ENV_INGRESS_NAMESPACE \ + [[ "$VKPR_ENV_INGRESS_SSL_SECRET" == "nginx-cert" ]] && $VKPR_KUBECTL create secret tls nginx-cert -n "$VKPR_ENV_INGRESS_NAMESPACE" \ --cert="$VKPR_ENV_INGRESS_CERTIFICATE" \ --key="$VKPR_ENV_INGRESS_KEY" YQ_VALUES="$YQ_VALUES | diff --git a/vkpr/kong/deck/dump/src/unix/formula/formula.sh b/vkpr/kong/deck/dump/src/unix/formula/formula.sh index 2ab159b2..4109039e 100755 --- a/vkpr/kong/deck/dump/src/unix/formula/formula.sh +++ b/vkpr/kong/deck/dump/src/unix/formula/formula.sh @@ -1,12 +1,12 @@ #!/bin/bash runFormula() { - if $(deck ping --kong-addr=$KONG_ADDR --headers=Kong-Admin-Token:$KONG_ADMIN_TOKEN | grep -q "Successfully"); then + if $($VKPR_DECK ping --kong-addr="$KONG_ADDR" --headers=Kong-Admin-Token:"$KONG_ADMIN_TOKEN" | grep -q "Successfully"); then notice "Successfully connected to Kong!" if [[ "$KONG_WORKSPACE" == "default" ]]; then bold "$(error "WARNING! we do not recommend DUMP in the default workspace")" fi - deck dump -w $KONG_WORKSPACE --kong-addr=$KONG_ADDR --headers=Kong-Admin-Token:$KONG_ADMIN_TOKEN + $VKPR_DECK dump -w "$KONG_WORKSPACE" --kong-addr="$KONG_ADDR" --headers=Kong-Admin-Token:"$KONG_ADMIN_TOKEN" info "Kong DUMP successfully executed" else bold "$(error "Unable to connect with Kong!")" diff --git a/vkpr/kong/deck/sync/src/unix/formula/formula.sh b/vkpr/kong/deck/sync/src/unix/formula/formula.sh index 32ae57f5..e688d9c7 100755 --- a/vkpr/kong/deck/sync/src/unix/formula/formula.sh +++ b/vkpr/kong/deck/sync/src/unix/formula/formula.sh @@ -1,15 +1,15 @@ #!/bin/bash runFormula() { - if $(deck ping --kong-addr=$KONG_ADDR --headers=Kong-Admin-Token:$KONG_ADMIN_TOKEN | grep -q "Successfully"); then + if $($VKPR_DECK ping --kong-addr="$KONG_ADDR" --headers=Kong-Admin-Token:"$KONG_ADMIN_TOKEN" | grep -q "Successfully"); then if [[ "$KONG_WORKSPACE" == "default" ]]; then bold "$(error "WARNING! we do not recommend SYNC in the default workspace")" fi - if $(deck validate -s $KONG_YAML_PATH 2>&1 | grep -q "Error:"); then + if $($VKPR_DECK validate -s "$KONG_YAML_PATH" 2>&1 | grep -q "Error:"); then bold "$(error "File contains errors, check your kong.yaml")" else notice "Successfully connected to Kong!" - deck sync -s $KONG_YAML_PATH --workspace $KONG_WORKSPACE --kong-addr=$KONG_ADDR --headers=Kong-Admin-Token:$KONG_ADMIN_TOKEN + $VKPR_DECK sync -s "$KONG_YAML_PATH" --workspace "$KONG_WORKSPACE" --kong-addr="$KONG_ADDR" --headers=Kong-Admin-Token:"$KONG_ADMIN_TOKEN" info "Kong SYNC successfully executed" fi fi diff --git a/vkpr/mockserver/install/src/unix/formula/formula.sh b/vkpr/mockserver/install/src/unix/formula/formula.sh index c1a777ef..714943e3 100755 --- a/vkpr/mockserver/install/src/unix/formula/formula.sh +++ b/vkpr/mockserver/install/src/unix/formula/formula.sh @@ -13,7 +13,7 @@ runFormula() { local VKPR_ENV_MOCKSERVER_DOMAIN="mockserver.${VKPR_ENV_GLOBAL_DOMAIN}" local VKPR_MOCKSERVER_VALUES; VKPR_MOCKSERVER_VALUES=$(dirname "$0")/utils/mockserver.yaml - local HELM_NAMESPACE='--create-namespace --namespace "$VKPR_ENV_MOCKSERVER_NAMESPACE"' + local HELM_NAMESPACE="--create-namespace --namespace $VKPR_ENV_MOCKSERVER_NAMESPACE" startInfos addRepoMockServer diff --git a/vkpr/postgres/install/src/unix/formula/formula.sh b/vkpr/postgres/install/src/unix/formula/formula.sh index 1d5cf43d..a94b5b9f 100755 --- a/vkpr/postgres/install/src/unix/formula/formula.sh +++ b/vkpr/postgres/install/src/unix/formula/formula.sh @@ -16,12 +16,8 @@ runFormula() { validatePostgresqlMetrics "$VKPR_ENV_POSTGRESQL_METRICS" local VKPR_POSTGRES_VALUES; VKPR_POSTGRES_VALUES=$(dirname "$0")/utils/postgres.yaml -<<<<<<< HEAD - local HELM_ARGS='--namespace "$VKPR_ENV_POSTGRES_NAMESPACE" --create-namespace' + local HELM_ARGS="--namespace $VKPR_ENV_POSTGRES_NAMESPACE --create-namespace" -======= - ->>>>>>> origin/VKPR-383 startInfos addRepoPostgres installPostgres @@ -52,6 +48,7 @@ installPostgres(){ info "Installing Postgresql..." $VKPR_YQ eval -i "$YQ_VALUES" "$VKPR_POSTGRES_VALUES" mergeVkprValuesHelmArgs "postgresql" "$VKPR_POSTGRES_VALUES" + # shellcheck disable=SC2086 $VKPR_HELM upgrade -i --version "$VKPR_POSTGRES_VERSION" \ $HELM_ARGS \ --wait -f "$VKPR_POSTGRES_VALUES" postgresql bitnami/$POSTGRESQL_CHART @@ -106,7 +103,7 @@ settingPostgres() { settingPostgresProvider(){ ACTUAL_CONTEXT=$($VKPR_KUBECTL config get-contexts --no-headers | grep "\*" | xargs | awk -F " " '{print $2}') - if [[ "$VKPR_ENV_GLOBAL_PROVIDER" == "okteto" ]] || [[$ACTUAL_CONTEXT == "cloud_okteto_com" ]]; then + if [[ "$VKPR_ENV_GLOBAL_PROVIDER" == "okteto" ]] || [[ $ACTUAL_CONTEXT == "cloud_okteto_com" ]]; then HELM_ARGS="" fi } \ No newline at end of file diff --git a/vkpr/vault/install/src/unix/formula/formula.sh b/vkpr/vault/install/src/unix/formula/formula.sh index 478c0557..d455471e 100755 --- a/vkpr/vault/install/src/unix/formula/formula.sh +++ b/vkpr/vault/install/src/unix/formula/formula.sh @@ -24,8 +24,8 @@ runFormula() { local VKPR_VAULT_CONFIG; VKPR_VAULT_CONFIG=$(dirname "$0")/utils/config.hcl [[ $DRY_RUN == true ]] && DRY_RUN_FLAGS="--dry-run=client -o yaml" - local HELM_NAMESPACE='--namespace $VKPR_ENV_VAULT_NAMESPACE --create-namespace' - local KUBERNETES_NAMESPACE='-n $VKPR_ENV_VAULT_NAMESPACE' + local HELM_NAMESPACE="--namespace $VKPR_ENV_VAULT_NAMESPACE --create-namespace" + local KUBERNETES_NAMESPACE="-n $VKPR_ENV_VAULT_NAMESPACE" startInfos configureRepository @@ -59,13 +59,16 @@ installVault() { info "Installing Vault..." $VKPR_YQ eval -i "$YQ_VALUES" "$VKPR_VAULT_VALUES" mergeVkprValuesHelmArgs "vault" "$VKPR_VAULT_VALUES" + # shellcheck disable=SC2086 $VKPR_HELM upgrade -i --version "$VKPR_VAULT_VERSION" \ $HELM_NAMESPACE \ --wait -f "$VKPR_VAULT_VALUES" vault hashicorp/vault fi + # shellcheck disable=SC2086 if [[ $($VKPR_KUBECTL get secret $KUBERNETES_NAMESPACE | grep vault-storage-config | cut -d " " -f1) != "vault-storage-config" ]]; then info "Creating storage config..." + # shellcheck disable=SC2015 $VKPR_KUBECTL create secret generic vault-storage-config $KUBERNETES_NAMESPACE --from-file="$VKPR_VAULT_CONFIG" $DRY_RUN_FLAGS && \ $VKPR_KUBECTL label secret vault-storage-config vkpr=true app.kubernetes.io/instance=vault -n "$VKPR_ENV_VAULT_NAMESPACE" 2> /dev/null || true fi @@ -117,6 +120,7 @@ settingVault() { validateAwsSecretKey "$AWS_SECRET_KEY" validateAwsRegion "$AWS_REGION" echoColor "bold" "$(echoColor "green" "Setting AWS secret...")" + # shellcheck disable=SC2086 $VKPR_YQ eval ".metadata.name = \"aws-unseal-vault\" | .metadata.namespace = \"$VKPR_ENV_VAULT_NAMESPACE\" | .data.AWS_ACCESS_KEY = \"$(echo -n "$AWS_ACCESS_KEY" | base64)\" | @@ -146,6 +150,7 @@ settingVault() { .server.extraSecretEnvironmentVars[4].secretKey = \"VAULT_AZUREKEYVAULT_KEY_NAME\" " bold "$(info "Setting Azure secret...")" + # shellcheck disable=SC2086 $VKPR_YQ eval ".metadata.name = \"azure-unseal-vault\" | .metadata.namespace = \"$VKPR_ENV_VAULT_NAMESPACE\" | .data.AZURE_TENANT_ID = \"$(echo -n "$($VKPR_JQ -r .credential.azuretenantid $RIT_CREDENTIALS_PATH/azure)" | base64)\" | @@ -187,7 +192,6 @@ settingVault() { settingVaultProvider() { ACTUAL_CONTEXT=$($VKPR_KUBECTL config get-contexts --no-headers | grep "\*" | xargs | awk -F " " '{print $2}') if [[ "$VKPR_ENV_GLOBAL_PROVIDER" == "okteto" ]] || [[ $ACTUAL_CONTEXT == "cloud_okteto_com" ]]; then - OKTETO_NAMESPACE=$($VKPR_KUBECTL config get-contexts --no-headers | grep "\*" | xargs | awk -F " " '{print $NF}') HELM_NAMESPACE="" KUBERNETES_NAMESPACE="" YQ_VALUES="$YQ_VALUES | diff --git a/vkpr/whoami/install/src/unix/formula/formula.sh b/vkpr/whoami/install/src/unix/formula/formula.sh index 3d4dbfc4..661813e3 100755 --- a/vkpr/whoami/install/src/unix/formula/formula.sh +++ b/vkpr/whoami/install/src/unix/formula/formula.sh @@ -13,7 +13,7 @@ runFormula() { local VKPR_ENV_WHOAMI_DOMAIN="whoami.${VKPR_ENV_GLOBAL_DOMAIN}" local VKPR_WHOAMI_VALUES; VKPR_WHOAMI_VALUES=$(dirname "$0")/utils/whoami.yaml - local HELM_NAMESPACE='--create-namespace --namespace "$VKPR_ENV_WHOAMI_NAMESPACE"' + local HELM_NAMESPACE="--create-namespace --namespace $VKPR_ENV_WHOAMI_NAMESPACE" startInfos addRepoWhoami