Skip to content

Commit

Permalink
Fix issue preventing kustomize apps being multi-namespaced
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesuen committed Dec 9, 2018
1 parent 457e137 commit e724783
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 19 deletions.
4 changes: 1 addition & 3 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 1 addition & 3 deletions reposerver/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 0 additions & 11 deletions util/kustomize/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions util/kustomize/kustomize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{{
Expand All @@ -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 {
Expand Down

0 comments on commit e724783

Please sign in to comment.