From eb5fb50e2a3088de77eea59c8ae8e52b04213c3e Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Fri, 23 Nov 2018 14:54:53 +0100 Subject: [PATCH] Split up CRD manifests into their own folder This way, CRD and app deployments can be separated, e.g. if someone wishes to install Argo CD multiple times. Also: Make update-manifests.sh fail-fast and more resilient against spaces in paths and user's CDPATH settings. --- hack/update-manifests.sh | 21 ++++++++++--------- manifests/base/kustomization.yaml | 2 -- manifests/cluster-install/kustomization.yaml | 2 +- manifests/{base => crds}/application-crd.yaml | 0 manifests/{base => crds}/appproject-crd.yaml | 0 manifests/crds/kustomization.yaml | 3 +++ .../namespace-install/kustomization.yaml | 3 +++ reposerver/repository/repository_test.go | 2 +- test/e2e/fixture.go | 2 +- 9 files changed, 20 insertions(+), 15 deletions(-) rename manifests/{base => crds}/application-crd.yaml (100%) rename manifests/{base => crds}/appproject-crd.yaml (100%) create mode 100644 manifests/crds/kustomization.yaml create mode 100644 manifests/namespace-install/kustomization.yaml diff --git a/hack/update-manifests.sh b/hack/update-manifests.sh index af57aad572d2d..746f08ce28358 100755 --- a/hack/update-manifests.sh +++ b/hack/update-manifests.sh @@ -1,22 +1,23 @@ #!/bin/sh -SRCROOT="$( cd "$(dirname "$0")/.." ; pwd -P )" +set -e + +SRCROOT="$( CDPATH='' cd -- "$(dirname "$0")/.." && pwd -P )" AUTOGENMSG="# This is an auto-generated file. DO NOT EDIT" update_image () { if [ ! -z "${IMAGE_NAMESPACE}" ]; then - sed -i '' 's| image: \(.*\)/\(argocd.*\)| image: '"${IMAGE_NAMESPACE}"'/\2|g' ${1} + sed -i -- 's| image: \(.*\)/\(argocd.*\)| image: '"${IMAGE_NAMESPACE}"'/\2|g' "${1}" fi if [ ! -z "${IMAGE_TAG}" ]; then - sed -i '' 's|\( image: .*/argocd.*\)\:.*|\1:'"${IMAGE_TAG}"'|g' ${1} + sed -i -- 's|\( image: .*/argocd.*\)\:.*|\1:'"${IMAGE_TAG}"'|g' "${1}" fi } -echo "${AUTOGENMSG}" > ${SRCROOT}/manifests/install.yaml -kustomize build ${SRCROOT}/manifests/cluster-install >> ${SRCROOT}/manifests/install.yaml -update_image ${SRCROOT}/manifests/install.yaml - -echo "${AUTOGENMSG}" > ${SRCROOT}/manifests/namespace-install.yaml -kustomize build ${SRCROOT}/manifests/base >> ${SRCROOT}/manifests/namespace-install.yaml -update_image ${SRCROOT}/manifests/namespace-install.yaml +echo "${AUTOGENMSG}" > "${SRCROOT}/manifests/install.yaml" +kustomize build "${SRCROOT}/manifests/cluster-install" >> "${SRCROOT}/manifests/install.yaml" +update_image "${SRCROOT}/manifests/install.yaml" +echo "${AUTOGENMSG}" > "${SRCROOT}/manifests/namespace-install.yaml" +kustomize build "${SRCROOT}/manifests/namespace-install" >> "${SRCROOT}/manifests/namespace-install.yaml" +update_image "${SRCROOT}/manifests/namespace-install.yaml" diff --git a/manifests/base/kustomization.yaml b/manifests/base/kustomization.yaml index 6d7f07ec51512..4adf9fb8e5947 100644 --- a/manifests/base/kustomization.yaml +++ b/manifests/base/kustomization.yaml @@ -1,6 +1,4 @@ resources: -- application-crd.yaml -- appproject-crd.yaml - argocd-cm.yaml - argocd-secret.yaml - argocd-rbac-cm.yaml diff --git a/manifests/cluster-install/kustomization.yaml b/manifests/cluster-install/kustomization.yaml index b5252639e5572..fbf60a7d97750 100644 --- a/manifests/cluster-install/kustomization.yaml +++ b/manifests/cluster-install/kustomization.yaml @@ -1,5 +1,5 @@ bases: -- ../base +- ../namespace-install resources: - application-controller-clusterrole.yaml diff --git a/manifests/base/application-crd.yaml b/manifests/crds/application-crd.yaml similarity index 100% rename from manifests/base/application-crd.yaml rename to manifests/crds/application-crd.yaml diff --git a/manifests/base/appproject-crd.yaml b/manifests/crds/appproject-crd.yaml similarity index 100% rename from manifests/base/appproject-crd.yaml rename to manifests/crds/appproject-crd.yaml diff --git a/manifests/crds/kustomization.yaml b/manifests/crds/kustomization.yaml new file mode 100644 index 0000000000000..c1b96f9dc45e0 --- /dev/null +++ b/manifests/crds/kustomization.yaml @@ -0,0 +1,3 @@ +resources: +- application-crd.yaml +- appproject-crd.yaml diff --git a/manifests/namespace-install/kustomization.yaml b/manifests/namespace-install/kustomization.yaml new file mode 100644 index 0000000000000..87447545e12f4 --- /dev/null +++ b/manifests/namespace-install/kustomization.yaml @@ -0,0 +1,3 @@ +bases: +- ../crds +- ../base diff --git a/reposerver/repository/repository_test.go b/reposerver/repository/repository_test.go index 361510b5ab16d..617dad19cbbda 100644 --- a/reposerver/repository/repository_test.go +++ b/reposerver/repository/repository_test.go @@ -10,7 +10,7 @@ import ( func TestGenerateYamlManifestInDir(t *testing.T) { // update this value if we add/remove manifests - const countOfManifests = 23 + const countOfManifests = 21 q := ManifestRequest{ ApplicationSource: &argoappv1.ApplicationSource{}, diff --git a/test/e2e/fixture.go b/test/e2e/fixture.go index 977c585a8a8a4..404e45ccb0649 100644 --- a/test/e2e/fixture.go +++ b/test/e2e/fixture.go @@ -93,7 +93,7 @@ func getFreePort() (int, error) { } func (f *Fixture) setup() error { - _, err := exec.Command("kubectl", "apply", "-f", "../../manifests/base/application-crd.yaml", "-f", "../../manifests/base/appproject-crd.yaml").Output() + _, err := exec.Command("kubectl", "apply", "-f", "../../manifests/crds/application-crd.yaml", "-f", "../../manifests/crds/appproject-crd.yaml").Output() if err != nil { return err }