Skip to content

Commit

Permalink
Fix kustomize path error
Browse files Browse the repository at this point in the history
  • Loading branch information
rajansandeep committed Apr 20, 2020
1 parent 85eb326 commit 7e0ffb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/patterns/declarative/pkg/manifest/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
type Objects struct {
Items []*Object
Blobs [][]byte
Path string
}

type Object struct {
Expand Down
9 changes: 7 additions & 2 deletions pkg/patterns/declarative/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,18 @@ func (r *Reconciler) reconcileExists(ctx context.Context, name types.NamespacedN
// run kustomize to create final manifest
opts := krusty.MakeDefaultOptions()
k := krusty.MakeKustomizer(fs, opts)
m, err := k.Run(string(filepath.Separator))
m, err := k.Run(objects.Path)
if err != nil {
log.Error(err, "running kustomize to create final manifest")
return reconcile.Result{}, fmt.Errorf("error running kustomize: %v", err)
}
log.Info("running kustomize to create final manifest")
manifestYaml, err := m.AsYaml()
if err != nil {
log.Error(err, "creating final manifest yaml")
return reconcile.Result{}, fmt.Errorf("error converting kustomize output to yaml: %v", err)
}
log.Info("creating final manifest yaml")
manifestStr = string(manifestYaml)

} else {
Expand Down Expand Up @@ -250,8 +252,11 @@ func (r *Reconciler) buildDeploymentObjects(ctx context.Context, name types.Name
}
fs.WriteFile(string(manifestPath), json)
}
for _, blob := range objects.Blobs {
fs.WriteFile(string(manifestPath), blob)
}
}

manifestObjects.Path = filepath.Dir(manifestPath)
manifestObjects.Items = append(manifestObjects.Items, objects.Items...)
}
// 6. Sort objects to work around dependent objects in the same manifest (eg: service-account, deployment)
Expand Down

0 comments on commit 7e0ffb4

Please sign in to comment.