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

Localize fields: openapi, configurations, crds #4907

Merged
merged 4 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
37 changes: 31 additions & 6 deletions api/internal/localizer/localizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,38 @@ func (lc *localizer) load() (*types.Kustomization, string, error) {
// localizeNativeFields localizes paths on kustomize-native fields, like configMapGenerator, that kustomize has a
// built-in understanding of. This excludes helm-related fields, such as `helmGlobals` and `helmCharts`.
func (lc *localizer) localizeNativeFields(kust *types.Kustomization) error {
for i, path := range kust.Components {
newPath, err := lc.localizeDir(path)
if path, exists := kust.OpenAPI["path"]; exists {
newPath, err := lc.localizeFile(path)
if err != nil {
return errors.WrapPrefixf(err, "unable to localize components field")
return errors.WrapPrefixf(err, "unable to localize openapi path")
}
kust.OpenAPI["path"] = newPath
}

for fieldName, field := range map[string]struct {
paths []string
locFn func(string) (string, error)
}{
"components": {
kust.Components,
lc.localizeDir,
},
"configurations": {
kust.Configurations,
lc.localizeFile,
},
"crds": {
kust.Crds,
lc.localizeFile,
},
} {
for i, path := range field.paths {
newPath, err := field.locFn(path)
if err != nil {
return errors.WrapPrefixf(err, "unable to localize %s path", fieldName)
}
field.paths[i] = newPath
}
kust.Components[i] = newPath
}

for i := range kust.ConfigMapGenerator {
Expand Down Expand Up @@ -168,8 +194,7 @@ func (lc *localizer) localizeNativeFields(kust *types.Kustomization) error {
}
}

// TODO(annasong): localize all other kustomization fields: resources, bases, crds, configurations,
// openapi, configMapGenerator.env, secretGenerator.env
// TODO(annasong): localize all other kustomization fields: resources, bases, configMapGenerator.env, secretGenerator.env
return nil
}

Expand Down
Loading