Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue preventing kustomize apps being multi-namespaced #913

Merged
merged 1 commit into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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