Skip to content

Commit 1dfb998

Browse files
authored
feat: add support for kustomize plugins (#4285)
Signed-off-by: Jeff Rescignano <jeffr@defenseunicorns.com>
1 parent 58cd53f commit 1dfb998

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

src/api/v1alpha1/component.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ type ZarfManifest struct {
206206
KustomizeAllowAnyDirectory bool `json:"kustomizeAllowAnyDirectory,omitempty"`
207207
// List of local kustomization paths or remote URLs to include in the package.
208208
Kustomizations []string `json:"kustomizations,omitempty"`
209+
// Enable kustomize plugins during kustomize builds.
210+
EnableKustomizePlugins bool `json:"enableKustomizePlugins,omitempty"`
209211
// Whether to not wait for manifest resources to be ready before continuing.
210212
NoWait bool `json:"noWait,omitempty"`
211213
// [alpha]

src/internal/packager/kustomize/build.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
// Build reads a kustomization and builds it into a single yaml file.
18-
func Build(path string, destination string, kustomizeAllowAnyDirectory bool) error {
18+
func Build(path string, destination string, kustomizeAllowAnyDirectory bool, enableKustomizePlugins bool) error {
1919
// Kustomize has to write to the filesystem on-disk
2020
fSys := filesys.MakeFsOnDisk()
2121

@@ -26,6 +26,10 @@ func Build(path string, destination string, kustomizeAllowAnyDirectory bool) err
2626
buildOptions.LoadRestrictions = krustytypes.LoadRestrictionsNone
2727
}
2828

29+
if enableKustomizePlugins {
30+
buildOptions.PluginConfig = krustytypes.MakePluginConfig(krustytypes.PluginRestrictionsNone, krustytypes.BploUseStaticallyLinked)
31+
}
32+
2933
kustomizer := krusty.MakeKustomizer(buildOptions)
3034

3135
// Try to build the kustomization

src/pkg/packager/layout/assemble.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ func PackageManifest(ctx context.Context, manifest v1alpha1.ZarfManifest, compBu
481481
if !helpers.IsURL(path) && !filepath.IsAbs(path) {
482482
path = filepath.Join(packagePath, path)
483483
}
484-
if err := kustomize.Build(path, dst, manifest.KustomizeAllowAnyDirectory); err != nil {
484+
if err := kustomize.Build(path, dst, manifest.KustomizeAllowAnyDirectory, manifest.EnableKustomizePlugins); err != nil {
485485
return fmt.Errorf("unable to build kustomization %s: %w", path, err)
486486
}
487487
}
@@ -666,7 +666,7 @@ func assembleSkeletonComponent(ctx context.Context, component v1alpha1.ZarfCompo
666666
}
667667

668668
// Build() requires the path be present - otherwise will throw an error.
669-
if err := kustomize.Build(path, dst, manifest.KustomizeAllowAnyDirectory); err != nil {
669+
if err := kustomize.Build(path, dst, manifest.KustomizeAllowAnyDirectory, manifest.EnableKustomizePlugins); err != nil {
670670
return fmt.Errorf("unable to build kustomization %s: %w", path, err)
671671
}
672672
}

zarf.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,10 @@
10511051
"type": "array",
10521052
"description": "List of local kustomization paths or remote URLs to include in the package."
10531053
},
1054+
"enableKustomizePlugins": {
1055+
"type": "boolean",
1056+
"description": "Enable kustomize plugins during kustomize builds."
1057+
},
10541058
"noWait": {
10551059
"type": "boolean",
10561060
"description": "Whether to not wait for manifest resources to be ready before continuing."

0 commit comments

Comments
 (0)