@@ -258,7 +258,7 @@ func NewBuilder(name, resources string, opts ...BuilderOptionFunc) (*Builder, er
258
258
b .timeout = defaultTimeout
259
259
}
260
260
261
- if b .dryRun && b .kustomizationFile == "" {
261
+ if b .dryRun && b .kustomizationFile == "" && b . kustomization == nil {
262
262
return nil , fmt .Errorf ("kustomization file is required for dry-run" )
263
263
}
264
264
@@ -355,7 +355,9 @@ func (b *Builder) build() (m resmap.ResMap, err error) {
355
355
356
356
// Get the kustomization object
357
357
liveKus := & kustomizev1.Kustomization {}
358
- if ! b .dryRun {
358
+ if b .dryRun {
359
+ liveKus = b .kustomization
360
+ } else {
359
361
liveKus , err = b .getKustomization (ctx )
360
362
if err != nil {
361
363
if ! apierrors .IsNotFound (err ) || b .kustomization == nil {
@@ -365,6 +367,7 @@ func (b *Builder) build() (m resmap.ResMap, err error) {
365
367
liveKus = b .kustomization
366
368
}
367
369
}
370
+
368
371
k , err := b .resolveKustomization (liveKus )
369
372
if err != nil {
370
373
err = fmt .Errorf ("failed to get kustomization object: %w" , err )
@@ -432,6 +435,7 @@ func (b *Builder) kustomizationBuild(k *kustomizev1.Kustomization) ([]*unstructu
432
435
WithStrictSubstitute (b .strictSubst ),
433
436
WithRecursive (b .recursive ),
434
437
WithLocalSources (b .localSources ),
438
+ WithDryRun (b .dryRun ),
435
439
)
436
440
if err != nil {
437
441
return nil , err
0 commit comments