feat(understackctl): deploy check uses kustomize build to validate#1923
Open
feat(understackctl): deploy check uses kustomize build to validate#1923
Conversation
Validate the manifests by running 'kustomize build' against each enabled component.
38ce2e2 to
d94849b
Compare
skrobul
approved these changes
Apr 9, 2026
Collaborator
skrobul
left a comment
There was a problem hiding this comment.
This works, but I was wondering what do you think about not relying on the kustomize binary to be present on the system and running kustomize natively instead?
import (
"fmt"
"path/filepath"
"sigs.k8s.io/kustomize/api/krusty"
kusttypes "sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kyaml/filesys"
)
// validateKustomizationNative runs the equivalent of:
// kustomize build --enable-alpha-plugins --enable-exec --enable-helm --load-restrictor LoadRestrictionsNone <compDir>
func validateKustomizationNative(compDir string) error {
opts := krusty.MakeDefaultOptions()
// --load-restrictor LoadRestrictionsNone
opts.LoadRestrictions = kusttypes.LoadRestrictionsNone
// --enable-alpha-plugins + --enable-helm
opts.PluginConfig = kusttypes.EnabledPluginConfig(kusttypes.BploLoadFromFileSys)
opts.PluginConfig.HelmConfig.Command = "helm"
// --enable-exec (for function plugins)
opts.PluginConfig.FnpLoadingOptions.EnableExec = true
k := krusty.MakeKustomizer(opts)
if _, err := k.Run(filesys.MakeFsOnDisk(), compDir); err != nil {
return fmt.Errorf("%s: %w", filepath.Join(compDir, "kustomization.yaml"), err)
}
return nil
}And in runDeployCheck, replace the `exec.Command(...) with:
if err := validateKustomizationNative(compDir); err != nil {
kustomizeErrors = append(kustomizeErrors, err.Error())
}the import block will need:
"sigs.k8s.io/kustomize/api/krusty"
kusttypes "sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kyaml/filesys"the docs:
https://pkg.go.dev/sigs.k8s.io/kustomize/api/krusty
https://pkg.go.dev/sigs.k8s.io/kustomize/api/types
Contributor
Author
|
That's probably better |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Validate the manifests by running 'kustomize build' against each enabled
component.