Commit 687778dd authored by Ronny Moreas's avatar Ronny Moreas Committed by Pierre Smeyers
Browse files

fix: use helmfile default config resolution

parent c4f6d524
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ The Helm template uses some global configuration used throughout all jobs.
| Input / Variable | Description                            | Default value     |
| --------------------- | -------------------------------------- | ----------------- |
| `cli-image` / `HELMFILE_CLI_IMAGE` | The Docker image used to run helmfile <br/>:warning: **set the version required by your Kubernetes server** | `ghcr.io/helmfile/helmfile:latest` <br/>[![Trivy Badge](https://to-be-continuous.gitlab.io/doc/secu/trivy-badge-HELMFILE_CLI_IMAGE.svg)](https://to-be-continuous.gitlab.io/doc/secu/trivy-HELMFILE_CLI_IMAGE) |
| `path` / `HELMFILE_PATH` | The path to your `helmfile.yaml` | `./helmfile.yaml` |
| `path` / `HELMFILE_PATH` | Path to file or directory to load helmfile config from. If not defined, defaults to `helmfile.yaml`, `helmfile.yaml.gotmpl` or `helmfile.d` (meaning `helmfile.d/*.yaml` or `helmfile.d/*.yaml.gotmpl`) | _none_ |
| `scripts-dir` / `HELMFILE_SCRIPTS_DIR` | The folder where hook scripts are located | `.` _(root project dir)_ |
| `kube-namespace` / `KUBE_NAMESPACE` | The default Kubernetes namespace to use | `"${CI_PROJECT_NAME}-${CI_PROJECT_ID}-${CI_ENVIRONMENT_SLUG}"` ([see GitLab doc](https://docs.gitlab.com/ci/variables/predefined_variables/)) |
| `KUBE_CONTEXT`      | Defines the context to be used in `KUBECONFIG`. When using [GitLab agents with the CI/CD workflow](https://docs.gitlab.com/user/clusters/agent/ci_cd_workflow/), the value should be like `path/to/agent/project:agent-name`. To use different agents per environment, define an [environment-scoped CI/CD variable](https://docs.gitlab.com/ci/environments/#limit-the-environment-scope-of-a-cicd-variable) for each agent. | _none_ |
+1 −2
Original line number Diff line number Diff line
@@ -18,8 +18,7 @@
    },
    {
      "name": "HELMFILE_PATH",
      "description": "Path to the `helmfile.yaml` to deploy",
      "default": "./helmfile.yaml"
      "description": "Path to file or directory to load helmfile config from. If not defined, defaults to `helmfile.yaml`, `helmfile.yaml.gotmpl` or `helmfile.d` (means `helmfile.d/*.yaml` or `helmfile.d/*.yaml.gotmpl`)"
    },
    {
      "name": "KUBE_NAMESPACE",
+29 −6
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@ spec:
      description: The folder where hook scripts are located
      default: .
    path:
      description: Path to the `helmfile.yaml` to deploy
      default: ./helmfile.yaml
      description: Path to file or directory to load helmfile configuration from. If not defined, defaults to `helmfile.yaml`, `helmfile.yaml.gotmpl` or `helmfile.d` (means `helmfile.d/*.yaml` or `helmfile.d/*.yaml.gotmpl`)
      default: ''
    kube-namespace:
      description: The default Kubernetes namespace to use. _Leave default if [GitLab Kubernetes integration](https://docs.gitlab.com/user/project/clusters/) is enabled._
      default: ''
@@ -595,7 +595,10 @@ stages:
    fi

    helmfile_opts=${TRACE+--debug}
    if [ -n "$HELMFILE_PATH" ]; then
      log_info "--- \\e[32mhelmfile path\\e[0m: \\e[33;1m${HELMFILE_PATH}\\e[0m"
      helmfile_opts="$helmfile_opts --file ${HELMFILE_PATH}"
    fi

    if [ -n "$environment_type" ]; then
      log_info "--- using \\e[32mhelmfile environment\\e[0m: \\e[33;1m${environment_type}\\e[0m"
@@ -649,7 +652,10 @@ stages:
    fi

    helmfile_opts=${TRACE+--debug}    
    if [ -n "$HELMFILE_PATH" ]; then
      log_info "--- \\e[32mhelmfile path\\e[0m: \\e[33;1m${HELMFILE_PATH}\\e[0m"
      helmfile_opts="$helmfile_opts --file ${HELMFILE_PATH}"
    fi

    if [ -n "$environment_type" ]; then
      log_info "--- using \\e[32mhelmfile environment\\e[0m: \\e[33;1m${environment_type}\\e[0m"
@@ -682,7 +688,10 @@ stages:
    kubectl config set-context --current --namespace="$kube_namespace"

    helmfile_opts=""
    if [ -n "$HELMFILE_PATH" ]; then
      log_info "--- \\e[32mhelmfile path\\e[0m: \\e[33;1m${HELMFILE_PATH}\\e[0m"
      helmfile_opts="$helmfile_opts --file ${HELMFILE_PATH}"
    fi

    if [ -n "$environment_type" ]; then
      log_info "--- using \\e[32mhelmfile environment\\e[0m: \\e[33;1m${environment_type}\\e[0m"
@@ -693,6 +702,20 @@ stages:
    helmfile $helmfile_opts $HELMFILE_TEST_ARGS
  }

  # lint helmfile manifest
  function helmfile_lint() {
    log_info "--- \\e[32mlint\\e[0m"

    helmfile_opts=${TRACE+--debug}
    if [ -n "$HELMFILE_PATH" ]; then
      log_info "--- \\e[32mhelmfile path\\e[0m: \\e[33;1m${HELMFILE_PATH}\\e[0m"
      helmfile_opts="$helmfile_opts --file ${HELMFILE_PATH}"
    fi

    # shellcheck disable=SC2086
    helmfile $helmfile_opts $HELMFILE_LINT_ARGS
  }

  # Setup PGP key for decrypt of helmfile secrets
  function setup_pgp_key() {
    if [[ -n "$HELMFILE_PGP_PRIVATE_KEY_FILE" && -f "$HELMFILE_PGP_PRIVATE_KEY_FILE" ]]; then
@@ -752,7 +775,7 @@ helmfile-lint:
  extends: .helmfile-base
  stage: test
  script:
    - helmfile ${TRACE+--debug} -f ${HELMFILE_PATH} $HELMFILE_LINT_ARGS
    - helmfile_lint
  rules:
    - if: '$HELMFILE_LINT_ENABLED != "true"'
      when: never