mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-22 14:57:01 +00:00
34 lines
938 B
Go
34 lines
938 B
Go
// 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"
|
|
)
|
|
|
|
// Change or set the namespace of non-cluster level resources.
|
|
type plugin struct {
|
|
Namespace string `json:"namespace,omitempty" yaml:"namespace,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.Namespace = ""
|
|
p.FieldSpecs = nil
|
|
return yaml.Unmarshal(c, p)
|
|
}
|
|
|
|
func (p *plugin) Transform(m resmap.ResMap) error {
|
|
return transformers.NewNamespaceTransformer(
|
|
p.Namespace, p.FieldSpecs).Transform(m)
|
|
}
|