From 483872a190f39a5520d02fb8bb37a7d8f7b7b4ee Mon Sep 17 00:00:00 2001 From: Jesse Suen Date: Mon, 10 Dec 2018 02:30:21 -0800 Subject: [PATCH] Fix issue preventing kustomize apps being multi-namespaced (#913) --- cmd/argocd/commands/app.go | 4 +--- reposerver/repository/repository.go | 4 +--- util/kustomize/kustomize.go | 11 ----------- util/kustomize/kustomize_test.go | 2 -- 4 files changed, 2 insertions(+), 19 deletions(-) diff --git a/cmd/argocd/commands/app.go b/cmd/argocd/commands/app.go index 3d31d296c4429..38c0915209505 100644 --- a/cmd/argocd/commands/app.go +++ b/cmd/argocd/commands/app.go @@ -592,9 +592,7 @@ func getLocalObjects(app *argoappv1.Application, local string, env string, value log.Fatal("--env option invalid when performing local diff on Kustomize application") } k := kustomize.NewKustomizeApp(local) - opts := kustomize.KustomizeBuildOpts{ - Namespace: app.Namespace, - } + opts := kustomize.KustomizeBuildOpts{} if app.Spec.Source.Kustomize != nil { opts.NamePrefix = app.Spec.Source.Kustomize.NamePrefix } diff --git a/reposerver/repository/repository.go b/reposerver/repository/repository.go index a0d051789fbae..7cc87395be04c 100644 --- a/reposerver/repository/repository.go +++ b/reposerver/repository/repository.go @@ -183,9 +183,7 @@ func helmOpts(q *ManifestRequest) helm.HelmTemplateOpts { } func kustomizeOpts(q *ManifestRequest) kustomize.KustomizeBuildOpts { - opts := kustomize.KustomizeBuildOpts{ - Namespace: q.Namespace, - } + opts := kustomize.KustomizeBuildOpts{} if q.ApplicationSource.Kustomize != nil { opts.NamePrefix = q.ApplicationSource.Kustomize.NamePrefix } diff --git a/util/kustomize/kustomize.go b/util/kustomize/kustomize.go index e2518201d0015..580498ab915d6 100644 --- a/util/kustomize/kustomize.go +++ b/util/kustomize/kustomize.go @@ -28,22 +28,11 @@ type kustomize struct { // KustomizeBuildOpts are options to a `kustomize build` command type KustomizeBuildOpts struct { - // Namespace will run `kustomize edit set namespace` during manifest generation - Namespace string // NamePrefix will run `kustomize edit set nameprefix` during manifest generation NamePrefix string } func (k *kustomize) Build(opts KustomizeBuildOpts, overrides []*v1alpha1.ComponentParameter) ([]*unstructured.Unstructured, []*v1alpha1.ComponentParameter, error) { - if opts.Namespace != "" { - cmd := exec.Command("kustomize", "edit", "set", "namespace", opts.Namespace) - cmd.Dir = k.path - _, err := argoexec.RunCommandExt(cmd) - if err != nil { - return nil, nil, err - } - } - if opts.NamePrefix != "" { cmd := exec.Command("kustomize", "edit", "set", "nameprefix", opts.NamePrefix) cmd.Dir = k.path diff --git a/util/kustomize/kustomize_test.go b/util/kustomize/kustomize_test.go index 634da5100f1ee..d805cc0cb38cf 100644 --- a/util/kustomize/kustomize_test.go +++ b/util/kustomize/kustomize_test.go @@ -29,7 +29,6 @@ func TestKustomizeBuild(t *testing.T) { namePrefix := "namePrefix-" kustomize := NewKustomizeApp(appPath) opts := KustomizeBuildOpts{ - Namespace: "mynamespace", NamePrefix: namePrefix, } objs, params, err := kustomize.Build(opts, []*v1alpha1.ComponentParameter{{ @@ -49,7 +48,6 @@ func TestKustomizeBuild(t *testing.T) { case "Deployment": assert.Equal(t, namePrefix+"nginx-deployment", obj.GetName()) } - assert.Equal(t, "mynamespace", obj.GetNamespace()) } for _, param := range params {