1
0
mirror of synced 2026-02-06 19:05:55 +00:00

Add --strict-substitute flag to flux build and flux diff ks commands

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
Stefan Prodan
2024-04-08 16:05:10 +03:00
parent 9e52b3ff41
commit 7d52267fc4
5 changed files with 34 additions and 9 deletions

View File

@@ -80,6 +80,7 @@ type Builder struct {
timeout time.Duration
spinner *yacspin.Spinner
dryRun bool
strictSubst bool
}
// BuilderOptionFunc is a function that configures a Builder
@@ -158,6 +159,14 @@ func WithDryRun(dryRun bool) BuilderOptionFunc {
}
}
// WithStrictSubstitute sets the strict substitute flag
func WithStrictSubstitute(strictSubstitute bool) BuilderOptionFunc {
return func(b *Builder) error {
b.strictSubst = strictSubstitute
return nil
}
}
// WithIgnore sets ignore field
func WithIgnore(ignore []string) BuilderOptionFunc {
return func(b *Builder) error {
@@ -391,7 +400,13 @@ func (b *Builder) do(ctx context.Context, kustomization kustomizev1.Kustomizatio
if err != nil {
return nil, err
}
outRes, err := kustomize.SubstituteVariables(ctx, b.client, unstructured.Unstructured{Object: data}, res, b.dryRun)
outRes, err := kustomize.SubstituteVariables(ctx,
b.client,
unstructured.Unstructured{Object: data},
res,
kustomize.SubstituteWithDryRun(b.dryRun),
kustomize.SubstituteWithStrict(b.strictSubst),
)
if err != nil {
return nil, fmt.Errorf("var substitution failed for '%s': %w", res.GetName(), err)
}