One plugin per dir.

This commit is contained in:
jregan
2019-05-19 12:00:07 -07:00
parent 31534fe47d
commit 5653ae69e4
42 changed files with 612 additions and 626 deletions

View File

@@ -1,10 +1,5 @@
// +build plugin
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
//go:generate go run sigs.k8s.io/kustomize/cmd/pluginator
package main
// Code generated by pluginator on ConfigMapGenerator; DO NOT EDIT.
package builtin
import (
"sigs.k8s.io/kustomize/pkg/ifc"
@@ -13,16 +8,18 @@ import (
"sigs.k8s.io/yaml"
)
type plugin struct {
type ConfigMapGeneratorPlugin struct {
ldr ifc.Loader
rf *resmap.Factory
types.GeneratorOptions
types.ConfigMapArgs
}
var KustomizePlugin plugin
func NewConfigMapGeneratorPlugin() *ConfigMapGeneratorPlugin {
return &ConfigMapGeneratorPlugin{}
}
func (p *plugin) Config(
func (p *ConfigMapGeneratorPlugin) Config(
ldr ifc.Loader, rf *resmap.Factory, config []byte) (err error) {
p.GeneratorOptions = types.GeneratorOptions{}
p.ConfigMapArgs = types.ConfigMapArgs{}
@@ -32,7 +29,7 @@ func (p *plugin) Config(
return
}
func (p *plugin) Generate() (resmap.ResMap, error) {
func (p *ConfigMapGeneratorPlugin) Generate() (resmap.ResMap, error) {
argsList := make([]types.ConfigMapArgs, 1)
argsList[0] = p.ConfigMapArgs
return p.rf.NewResMapFromConfigMapArgs(

View File

@@ -1,10 +1,5 @@
// +build plugin
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
//go:generate go run sigs.k8s.io/kustomize/cmd/pluginator
package main
// Code generated by pluginator on ImageTagTransformer; DO NOT EDIT.
package builtin
import (
"sigs.k8s.io/kustomize/pkg/ifc"
@@ -17,21 +12,23 @@ import (
// Find matching image declarations and replace
// the name, tag and/or digest.
type plugin struct {
type ImageTagTransformerPlugin struct {
ImageTag image.Image `json:"imageTag,omitempty" yaml:"imageTag,omitempty"`
FieldSpecs []config.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
}
var KustomizePlugin plugin
func NewImageTagTransformerPlugin() *ImageTagTransformerPlugin {
return &ImageTagTransformerPlugin{}
}
func (p *plugin) Config(
func (p *ImageTagTransformerPlugin) Config(
ldr ifc.Loader, rf *resmap.Factory, c []byte) (err error) {
p.ImageTag = image.Image{}
p.FieldSpecs = nil
return yaml.Unmarshal(c, p)
}
func (p *plugin) Transform(m resmap.ResMap) error {
func (p *ImageTagTransformerPlugin) Transform(m resmap.ResMap) error {
argsList := make([]image.Image, 1)
argsList[0] = p.ImageTag
t, err := transformers.NewImageTransformer(argsList, p.FieldSpecs)

View File

@@ -1,10 +1,5 @@
// +build plugin
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
//go:generate go run sigs.k8s.io/kustomize/cmd/pluginator
package main
// Code generated by pluginator on NameTransformer; DO NOT EDIT.
package builtin
import (
"sigs.k8s.io/kustomize/pkg/ifc"
@@ -15,15 +10,17 @@ import (
)
// Add the given prefix and suffix to the resource name.
type plugin struct {
type NameTransformerPlugin struct {
Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty"`
Suffix string `json:"suffix,omitempty" yaml:"suffix,omitempty"`
FieldSpecs []config.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
}
var KustomizePlugin plugin
func NewNameTransformerPlugin() *NameTransformerPlugin {
return &NameTransformerPlugin{}
}
func (p *plugin) Config(
func (p *NameTransformerPlugin) Config(
ldr ifc.Loader, rf *resmap.Factory, c []byte) (err error) {
p.Prefix = ""
p.Suffix = ""
@@ -31,7 +28,7 @@ func (p *plugin) Config(
return yaml.Unmarshal(c, p)
}
func (p *plugin) Transform(m resmap.ResMap) error {
func (p *NameTransformerPlugin) Transform(m resmap.ResMap) error {
t, err := transformers.NewNamePrefixSuffixTransformer(
p.Prefix,
p.Suffix,

View File

@@ -1,10 +1,5 @@
// +build plugin
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
//go:generate go run sigs.k8s.io/kustomize/cmd/pluginator
package main
// Code generated by pluginator on SecretGenerator; DO NOT EDIT.
package builtin
import (
"sigs.k8s.io/kustomize/pkg/ifc"
@@ -13,16 +8,18 @@ import (
"sigs.k8s.io/yaml"
)
type plugin struct {
type SecretGeneratorPlugin struct {
ldr ifc.Loader
rf *resmap.Factory
types.GeneratorOptions
types.SecretArgs
}
var KustomizePlugin plugin
func NewSecretGeneratorPlugin() *SecretGeneratorPlugin {
return &SecretGeneratorPlugin{}
}
func (p *plugin) Config(
func (p *SecretGeneratorPlugin) Config(
ldr ifc.Loader, rf *resmap.Factory, config []byte) (err error) {
p.GeneratorOptions = types.GeneratorOptions{}
p.SecretArgs = types.SecretArgs{}
@@ -32,7 +29,7 @@ func (p *plugin) Config(
return
}
func (p *plugin) Generate() (resmap.ResMap, error) {
func (p *SecretGeneratorPlugin) Generate() (resmap.ResMap, error) {
argsList := make([]types.SecretArgs, 1)
argsList[0] = p.SecretArgs
return p.rf.NewResMapFromSecretArgs(

View File

@@ -0,0 +1,38 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
//go:generate go run sigs.k8s.io/kustomize/plugin/pluginator
package main
import (
"sigs.k8s.io/kustomize/pkg/ifc"
"sigs.k8s.io/kustomize/pkg/resmap"
"sigs.k8s.io/kustomize/pkg/types"
"sigs.k8s.io/yaml"
)
type plugin struct {
ldr ifc.Loader
rf *resmap.Factory
types.GeneratorOptions
types.ConfigMapArgs
}
var KustomizePlugin plugin
func (p *plugin) Config(
ldr ifc.Loader, rf *resmap.Factory, config []byte) (err error) {
p.GeneratorOptions = types.GeneratorOptions{}
p.ConfigMapArgs = types.ConfigMapArgs{}
err = yaml.Unmarshal(config, p)
p.ldr = ldr
p.rf = rf
return
}
func (p *plugin) Generate() (resmap.ResMap, error) {
argsList := make([]types.ConfigMapArgs, 1)
argsList[0] = p.ConfigMapArgs
return p.rf.NewResMapFromConfigMapArgs(
p.ldr, &p.GeneratorOptions, argsList)
}

View File

@@ -11,7 +11,7 @@ import (
)
func TestConfigMapGenerator(t *testing.T) {
tc := plugin.NewPluginTestEnv(t).Set()
tc := plugin.NewEnvForTest(t).Set()
defer tc.Reset()
tc.BuildGoPlugin(

View File

@@ -0,0 +1,40 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
//go:generate go run sigs.k8s.io/kustomize/plugin/pluginator
package main
import (
"sigs.k8s.io/kustomize/pkg/ifc"
"sigs.k8s.io/kustomize/pkg/image"
"sigs.k8s.io/kustomize/pkg/resmap"
"sigs.k8s.io/kustomize/pkg/transformers"
"sigs.k8s.io/kustomize/pkg/transformers/config"
"sigs.k8s.io/yaml"
)
// Find matching image declarations and replace
// the name, tag and/or digest.
type plugin struct {
ImageTag image.Image `json:"imageTag,omitempty" yaml:"imageTag,omitempty"`
FieldSpecs []config.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
}
var KustomizePlugin plugin
func (p *plugin) Config(
ldr ifc.Loader, rf *resmap.Factory, c []byte) (err error) {
p.ImageTag = image.Image{}
p.FieldSpecs = nil
return yaml.Unmarshal(c, p)
}
func (p *plugin) Transform(m resmap.ResMap) error {
argsList := make([]image.Image, 1)
argsList[0] = p.ImageTag
t, err := transformers.NewImageTransformer(argsList, p.FieldSpecs)
if err != nil {
return err
}
return t.Transform(m)
}

View File

@@ -11,7 +11,7 @@ import (
)
func TestImageTagTransformer(t *testing.T) {
tc := plugin.NewPluginTestEnv(t).Set()
tc := plugin.NewEnvForTest(t).Set()
defer tc.Reset()
tc.BuildGoPlugin(

View File

@@ -0,0 +1,42 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
//go:generate go run sigs.k8s.io/kustomize/plugin/pluginator
package main
import (
"sigs.k8s.io/kustomize/pkg/ifc"
"sigs.k8s.io/kustomize/pkg/resmap"
"sigs.k8s.io/kustomize/pkg/transformers"
"sigs.k8s.io/kustomize/pkg/transformers/config"
"sigs.k8s.io/yaml"
)
// Add the given prefix and suffix to the resource name.
type plugin struct {
Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty"`
Suffix string `json:"suffix,omitempty" yaml:"suffix,omitempty"`
FieldSpecs []config.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
}
var KustomizePlugin plugin
func (p *plugin) Config(
ldr ifc.Loader, rf *resmap.Factory, c []byte) (err error) {
p.Prefix = ""
p.Suffix = ""
p.FieldSpecs = nil
return yaml.Unmarshal(c, p)
}
func (p *plugin) Transform(m resmap.ResMap) error {
t, err := transformers.NewNamePrefixSuffixTransformer(
p.Prefix,
p.Suffix,
p.FieldSpecs,
)
if err != nil {
return err
}
return t.Transform(m)
}

View File

@@ -11,7 +11,7 @@ import (
)
func TestNameTransformer(t *testing.T) {
tc := plugin.NewPluginTestEnv(t).Set()
tc := plugin.NewEnvForTest(t).Set()
defer tc.Reset()
tc.BuildGoPlugin(

View File

@@ -0,0 +1,38 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
//go:generate go run sigs.k8s.io/kustomize/plugin/pluginator
package main
import (
"sigs.k8s.io/kustomize/pkg/ifc"
"sigs.k8s.io/kustomize/pkg/resmap"
"sigs.k8s.io/kustomize/pkg/types"
"sigs.k8s.io/yaml"
)
type plugin struct {
ldr ifc.Loader
rf *resmap.Factory
types.GeneratorOptions
types.SecretArgs
}
var KustomizePlugin plugin
func (p *plugin) Config(
ldr ifc.Loader, rf *resmap.Factory, config []byte) (err error) {
p.GeneratorOptions = types.GeneratorOptions{}
p.SecretArgs = types.SecretArgs{}
err = yaml.Unmarshal(config, p)
p.ldr = ldr
p.rf = rf
return
}
func (p *plugin) Generate() (resmap.ResMap, error) {
argsList := make([]types.SecretArgs, 1)
argsList[0] = p.SecretArgs
return p.rf.NewResMapFromSecretArgs(
p.ldr, &p.GeneratorOptions, argsList)
}

View File

@@ -11,7 +11,7 @@ import (
)
func TestSecretGenerator(t *testing.T) {
tc := plugin.NewPluginTestEnv(t).Set()
tc := plugin.NewEnvForTest(t).Set()
defer tc.Reset()
tc.BuildGoPlugin(