mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
e8381db778
* Update Kubernetes to v1.21.0 * Update to golang v1.16.2 * Update dependent modules to track with upstream * Switch to upstream flannel * Track changes to upstream cloud-controller-manager and FeatureGates Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
41 lines
890 B
Go
41 lines
890 B
Go
// Code generated by pluginator on HashTransformer; DO NOT EDIT.
|
|
// pluginator {unknown 1970-01-01T00:00:00Z }
|
|
|
|
package builtins
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"sigs.k8s.io/kustomize/api/ifc"
|
|
"sigs.k8s.io/kustomize/api/resmap"
|
|
)
|
|
|
|
type HashTransformerPlugin struct {
|
|
hasher ifc.KunstructuredHasher
|
|
}
|
|
|
|
func (p *HashTransformerPlugin) Config(
|
|
h *resmap.PluginHelpers, _ []byte) (err error) {
|
|
p.hasher = h.ResmapFactory().RF().Hasher()
|
|
return nil
|
|
}
|
|
|
|
// Transform appends hash to generated resources.
|
|
func (p *HashTransformerPlugin) Transform(m resmap.ResMap) error {
|
|
for _, res := range m.Resources() {
|
|
if res.NeedHashSuffix() {
|
|
h, err := p.hasher.Hash(res)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
res.StorePreviousId()
|
|
res.SetName(fmt.Sprintf("%s-%s", res.GetName(), h))
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func NewHashTransformerPlugin() resmap.TransformerPlugin {
|
|
return &HashTransformerPlugin{}
|
|
}
|