diff --git a/argocd/manifest-cmp/Dockerfile b/argocd/helmfile-cmp/Dockerfile similarity index 76% rename from argocd/manifest-cmp/Dockerfile rename to argocd/helmfile-cmp/Dockerfile index 5b7f9c4c..1c8e31b5 100644 --- a/argocd/manifest-cmp/Dockerfile +++ b/argocd/helmfile-cmp/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine/k8s:1.28.9 +FROM ghcr.io/helmfile/helmfile:v0.157.0 RUN mkdir -p /home/argocd/cmp-server/config/ COPY plugin.yaml /home/argocd/cmp-server/config/ diff --git a/argocd/manifest-cmp/deploy.sh b/argocd/helmfile-cmp/deploy.sh similarity index 58% rename from argocd/manifest-cmp/deploy.sh rename to argocd/helmfile-cmp/deploy.sh index b0c97e9d..b2319ffc 100755 --- a/argocd/manifest-cmp/deploy.sh +++ b/argocd/helmfile-cmp/deploy.sh @@ -1,6 +1,6 @@ #!/bin/sh -img=registry.gitlab.com/oceanbox/manifests/manifest-cmp +img=registry.gitlab.com/oceanbox/manifests/helmfile-cmp tag=${1:-latest} docker build -t $img:$tag . diff --git a/argocd/helmfile-cmp/generate.sh b/argocd/helmfile-cmp/generate.sh new file mode 100644 index 00000000..d27a22bc --- /dev/null +++ b/argocd/helmfile-cmp/generate.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +export HOME=/plugin +export HELM_CACHE_HOME=/tmp/helm/cache +export HELM_CONFIG_HOME=/tmp/helm/config +export HELMFILE_CACHE_HOME=/tmp/helmfile/cache +export HELMFILE_TEMPDIR=/tmp/helmfile/tmp + +env > /tmp/$ARGOCD_APP_NAME.env + +if [[ -v ENV_NAME ]]; then + helmfile -n "$ARGOCD_APP_NAMESPACE" -e $ENV_NAME template --include-crds -q +elif [[ -v ARGOCD_ENV_ENV_NAME ]]; then + helmfile -n "$ARGOCD_APP_NAMESPACE" -e "$ARGOCD_ENV_ENV_NAME" template --include-crds -q +else + helmfile -n "$ARGOCD_APP_NAMESPACE" template --include-crds -q +fi + diff --git a/argocd/helmfile-cmp/plugin.yaml b/argocd/helmfile-cmp/plugin.yaml new file mode 100644 index 00000000..7ecee01b --- /dev/null +++ b/argocd/helmfile-cmp/plugin.yaml @@ -0,0 +1,12 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ConfigManagementPlugin +metadata: + name: helmfile +spec: + generate: + command: [ /bin/sh ] + args: + - /plugin/generate.sh + discover: + fileName: helmfile.yaml + lockRepo: false diff --git a/argocd/manifest-cmp/.gitignore b/argocd/manifest-cmp/.gitignore deleted file mode 100644 index 5ab6415a..00000000 --- a/argocd/manifest-cmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -argo-repo-server.yaml -values.yaml diff --git a/argocd/manifest-cmp/generate.sh b/argocd/manifest-cmp/generate.sh deleted file mode 100644 index 544d2ae4..00000000 --- a/argocd/manifest-cmp/generate.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -env > /tmp/$ARGOCD_APP_NAME.env - -# cat /tmp/$ARGOCD_APP_NAME-manifest.yaml diff --git a/argocd/manifest-cmp/plugin.yaml b/argocd/manifest-cmp/plugin.yaml deleted file mode 100644 index 4e8a1340..00000000 --- a/argocd/manifest-cmp/plugin.yaml +++ /dev/null @@ -1,88 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: ConfigManagementPlugin -metadata: - name: manifest-cmp -spec: - # version: v1.2 - # The init command runs in the Application source directory at the beginning of each manifest generation. The init - # command can output anything. A non-zero status code will fail manifest generation. - # init: - # Init always happens immediately before generate, but its output is not treated as manifests. - # This is a good place to, for example, download chart dependencies. - # command: [ /bin/sh ] - # args: - # - /plugin/init.sh - # The generate command runs in the Application source directory each time manifests are generated. Standard output - # must be ONLY valid Kubernetes Objects in either YAML or JSON. A non-zero exit code will fail manifest generation. - # To write log messages from the command, write them to stderr, it will always be displayed. - # Error output will be sent to the UI, so avoid printing sensitive information (such as secrets). - generate: - command: [ /bin/sh ] - args: - - /plugin/generate.sh - - # The discovery config is applied to a repository. If every configured discovery tool matches, then the plugin may be - # used to generate manifests for Applications using the repository. If the discovery config is omitted then the plugin - # will not match any application but can still be invoked explicitly by specifying the plugin name in the app spec. - # Only one of fileName, find.glob, or find.command should be specified. If multiple are specified then only the - # first (in that order) is evaluated. - # discover: - # fileName is a glob pattern (https://pkg.go.dev/path/filepath#Glob) that is applied to the Application's source - # directory. If there is a match, this plugin may be used for the Application. - # fileName: "./subdir/s*.yaml" - # find: - # This does the same thing as fileName, but it supports double-start (nested directory) glob patterns. - # glob: "**/Chart.yaml" - # The find command runs in the repository's root directory. To match, it must exit with status code 0 _and_ - # produce non-empty output to standard out. - # command: [sh, -c, find . -name env.yaml] - # The parameters config describes what parameters the UI should display for an Application. It is up to the user to - # actually set parameters in the Application manifest (in spec.source.plugin.parameters). The announcements _only_ - # inform the "Parameters" tab in the App Details page of the UI. - parameters: - # Static parameter announcements are sent to the UI for _all_ Applications handled by this plugin. - # Think of the `string`, `array`, and `map` values set here as "defaults". It is up to the plugin author to make - # sure that these default values actually reflect the plugin's behavior if the user doesn't explicitly set different - # values for those parameters. - static: - - name: env - title: Environment - tooltip: Kustomization env (directory in manifest folder) - required: true - itemType: string - collectionType: string - string: "staging" - - name: cluster - title: Cluster - tooltip: Name of cluster - required: true - itemType: string - collectionType: string - string: "oceanbox" - - name: flags - title: Feature flags - tooltip: Feature flags - required: false - collectionType: map - map: - cilium: true - kyverno: true - # All the fields above besides "string" apply to both the array and map type parameter announcements. - # - name: array-param - # # This field communicates the parameter's default value to the UI. Setting this field is optional. - # array: [default, items] - # collectionType: array - # - name: map-param - # # This field communicates the parameter's default value to the UI. Setting this field is optional. - # map: - # some: value - # collectionType: map - # dynamic: - # The command is run in an Application's source directory. Standard output must be JSON matching the schema of the - # static parameter announcements list. - # command: [ /bin/sh, /plugin/get-values.sh ] - - # If set to `true` then the plugin receives repository files with original file mode. Dangerous since the repository - # might have executable files. Set to true only if you trust the CMP plugin authors. - preserveFileMode: false -