fix: allow recursive dry-run over local sources
Signed-off-by: niveau0 <plingplong@t-online.de>
This commit is contained in:
@@ -169,6 +169,12 @@ spec:
|
|||||||
resultFile: "./testdata/build-kustomization/podinfo-with-my-app-result.yaml",
|
resultFile: "./testdata/build-kustomization/podinfo-with-my-app-result.yaml",
|
||||||
assertFunc: "assertGoldenTemplateFile",
|
assertFunc: "assertGoldenTemplateFile",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "build with recursive in dry-run mode",
|
||||||
|
args: "build kustomization podinfo --kustomization-file " + tmpFile + " --path ./testdata/build-kustomization/podinfo-with-my-app --recursive --local-sources GitRepository/default/podinfo=./testdata/build-kustomization --dry-run",
|
||||||
|
resultFile: "./testdata/build-kustomization/podinfo-with-my-app-result.yaml",
|
||||||
|
assertFunc: "assertGoldenTemplateFile",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl := map[string]string{
|
tmpl := map[string]string{
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ func NewBuilder(name, resources string, opts ...BuilderOptionFunc) (*Builder, er
|
|||||||
b.timeout = defaultTimeout
|
b.timeout = defaultTimeout
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.dryRun && b.kustomizationFile == "" {
|
if b.dryRun && b.kustomizationFile == "" && b.kustomization == nil {
|
||||||
return nil, fmt.Errorf("kustomization file is required for dry-run")
|
return nil, fmt.Errorf("kustomization file is required for dry-run")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +355,9 @@ func (b *Builder) build() (m resmap.ResMap, err error) {
|
|||||||
|
|
||||||
// Get the kustomization object
|
// Get the kustomization object
|
||||||
liveKus := &kustomizev1.Kustomization{}
|
liveKus := &kustomizev1.Kustomization{}
|
||||||
if !b.dryRun {
|
if b.dryRun {
|
||||||
|
liveKus = b.kustomization
|
||||||
|
} else {
|
||||||
liveKus, err = b.getKustomization(ctx)
|
liveKus, err = b.getKustomization(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !apierrors.IsNotFound(err) || b.kustomization == nil {
|
if !apierrors.IsNotFound(err) || b.kustomization == nil {
|
||||||
@@ -365,6 +367,7 @@ func (b *Builder) build() (m resmap.ResMap, err error) {
|
|||||||
liveKus = b.kustomization
|
liveKus = b.kustomization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
k, err := b.resolveKustomization(liveKus)
|
k, err := b.resolveKustomization(liveKus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("failed to get kustomization object: %w", err)
|
err = fmt.Errorf("failed to get kustomization object: %w", err)
|
||||||
@@ -432,6 +435,7 @@ func (b *Builder) kustomizationBuild(k *kustomizev1.Kustomization) ([]*unstructu
|
|||||||
WithStrictSubstitute(b.strictSubst),
|
WithStrictSubstitute(b.strictSubst),
|
||||||
WithRecursive(b.recursive),
|
WithRecursive(b.recursive),
|
||||||
WithLocalSources(b.localSources),
|
WithLocalSources(b.localSources),
|
||||||
|
WithDryRun(b.dryRun),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user