Skip to content

Commit

Permalink
fix(lint): lint bugs variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jpeedroza committed Jun 13, 2022
1 parent d6308b2 commit 1f1fb93
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 22 deletions.
8 changes: 4 additions & 4 deletions lib/functions/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -165,7 +165,7 @@ validateBool(){
if [[ $(echo $1 | tr '[:upper:]' '[:lower:]') =~ ^true|false$ ]]; then
return
else
echo "error"
echo "error"
exit
fi
}
Expand Down Expand Up @@ -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
}
}
3 changes: 2 additions & 1 deletion lib/functions/var.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions vkpr/cert-manager/install/aws/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion vkpr/ingress/install/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
4 changes: 2 additions & 2 deletions vkpr/kong/deck/dump/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
@@ -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!")"
Expand Down
6 changes: 3 additions & 3 deletions vkpr/kong/deck/sync/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion vkpr/mockserver/install/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions vkpr/postgres/install/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
10 changes: 7 additions & 3 deletions vkpr/vault/install/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)\" |
Expand Down Expand Up @@ -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)\" |
Expand Down Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion vkpr/whoami/install/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f1fb93

Please sign in to comment.