-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from kaweezle/feature/kustomization-generator
✨ Added kustomization generator
- Loading branch information
Showing
15 changed files
with
184 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,9 @@ builds: | |
archives: | ||
- format: binary | ||
name_template: '{{ .Binary }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}' | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
checksum: | ||
name_template: "SHA256SUMS" | ||
snapshot: | ||
|
@@ -73,3 +76,16 @@ dockers: | |
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} | ||
- --label=org.opencontainers.image.revision={{ .FullCommit }} | ||
- --label=org.opencontainers.image.licenses=Apache-2.0 | ||
scoop: | ||
bucket: | ||
owner: kaweezle | ||
name: scoop-bucket | ||
branch: main | ||
token: "{{ .Env.SCOOP_BUCKET_GITHUB_TOKEN }}" | ||
commit_author: | ||
name: Antoine Martin | ||
email: [email protected] | ||
commit_msg_template: "Scoop update for {{ .ProjectName }} version {{ .Tag }}" | ||
homepage: https://github.com/kaweezle/krmfnbuiltin | ||
description: "Kustomize SOPS KRM function" | ||
license: Apache-2.0 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package extras | ||
|
||
import ( | ||
"sigs.k8s.io/kustomize/api/krusty" | ||
"sigs.k8s.io/kustomize/api/resmap" | ||
"sigs.k8s.io/kustomize/api/types" | ||
"sigs.k8s.io/kustomize/kyaml/filesys" | ||
"sigs.k8s.io/yaml" | ||
) | ||
|
||
// KustomizationGeneratorPlugin configures the KustomizationGenerator. | ||
type KustomizationGeneratorPlugin struct { | ||
Directory string `json:"kustomizeDirectory,omitempty" yaml:"kustomizeDirectory,omitempty"` | ||
} | ||
|
||
// enablePlugins adds to opts the options to run exec functions | ||
func enablePlugins(opts *krusty.Options) *krusty.Options { | ||
opts.PluginConfig = types.EnabledPluginConfig(types.BploUseStaticallyLinked) // cSpell: disable-line | ||
opts.PluginConfig.FnpLoadingOptions.EnableExec = true | ||
opts.PluginConfig.FnpLoadingOptions.AsCurrentUser = true | ||
opts.PluginConfig.HelmConfig.Command = "helm" | ||
opts.LoadRestrictions = types.LoadRestrictionsNone | ||
return opts | ||
} | ||
|
||
// runKustomizations runs the kustomization in dirname (URL compatible) with | ||
// the filesystem fs. | ||
func runKustomizations(fs filesys.FileSystem, dirname string) (resources resmap.ResMap, err error) { | ||
|
||
opts := enablePlugins(krusty.MakeDefaultOptions()) | ||
k := krusty.MakeKustomizer(opts) | ||
resources, err = k.Run(fs, dirname) | ||
return | ||
} | ||
|
||
// Config reads the function configuration, i.e. the kustomizeDirectory | ||
func (p *KustomizationGeneratorPlugin) Config( | ||
h *resmap.PluginHelpers, c []byte) (err error) { | ||
err = yaml.Unmarshal(c, p) | ||
if err != nil { | ||
return err | ||
} | ||
return err | ||
} | ||
|
||
// Generate generates the resources of the directory | ||
func (p *KustomizationGeneratorPlugin) Generate() (resmap.ResMap, error) { | ||
return runKustomizations(filesys.MakeFsOnDisk(), p.Directory) | ||
} | ||
|
||
// NewKustomizationGeneratorPlugin returns a newly Created KustomizationGenerator | ||
func NewKustomizationGeneratorPlugin() resmap.GeneratorPlugin { | ||
return &KustomizationGeneratorPlugin{} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
10 changes: 10 additions & 0 deletions
10
tests/kustomization/functions/kustomization-generator.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: builtin | ||
kind: KustomizationGenerator | ||
metadata: | ||
name: kustomization-generator | ||
annotations: | ||
config.kaweezle.com/path: "" | ||
config.kubernetes.io/function: | | ||
exec: | ||
path: ../../krmfnbuiltin | ||
kustomizeDirectory: https://github.com/antoinemartin/autocloud.git//packages/uninode?ref=deploy/citest |
Empty file.
This file contains 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
This file contains 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