diff --git a/internal/utils/kustomize/kustomize.go b/internal/utils/kustomize/kustomize.go index 96abc6b..01b6359 100644 --- a/internal/utils/kustomize/kustomize.go +++ b/internal/utils/kustomize/kustomize.go @@ -4,7 +4,6 @@ import ( "fmt" "os" "path/filepath" - "strings" "git.badhouseplants.net/allanger/shoebill/internal/utils/githelper" kustomize_types "sigs.k8s.io/kustomize/api/types" @@ -39,18 +38,22 @@ func (k *Kusmtomize) PopulateResources(path string) error { return nil } -func (k *Kusmtomize) CmGeneratorFromFiles() ([]kustomize_types.ConfigMapArgs, error) { +func (k *Kusmtomize) CmGeneratorFromFiles() []kustomize_types.ConfigMapArgs { cmGens := []kustomize_types.ConfigMapArgs{} for _, cm := range k.ConfigMaps { - cmName := + cmName := filepath.Base(cm) cmGen := &kustomize_types.ConfigMapArgs{ GeneratorArgs: kustomize_types.GeneratorArgs{ Namespace: "flux-system", - Name: "", + Name: cmName, + KvPairSources: kustomize_types.KvPairSources{ + FileSources: []string{cm}, + }, }, } + cmGens = append(cmGens, *cmGen) } - + return cmGens } func Generate(path string, gh githelper.Githelper) error { @@ -62,7 +65,7 @@ func Generate(path string, gh githelper.Githelper) error { kustomization := kustomize_types.Kustomization{ TypeMeta: kustomize_types.TypeMeta{ Kind: kustomize_types.KustomizationKind, - APIVersion: kustomize_types.ComponentVersion, + APIVersion: kustomize_types.KustomizationVersion, }, MetaData: &kustomize_types.ObjectMeta{ Name: "helm-root", @@ -72,7 +75,7 @@ func Generate(path string, gh githelper.Githelper) error { GeneratorOptions: &kustomize_types.GeneratorOptions{ DisableNameSuffixHash: true, }, - ConfigMapGenerator: []kustomize_types.ConfigMapArgs{}, + ConfigMapGenerator: kustomize.CmGeneratorFromFiles(), } manifest, err := yaml.Marshal(kustomization) if err != nil {