mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 10:00:56 +00:00
One plugin per dir.
This commit is contained in:
38
plugin/someteam.example.com/v1/dateprefixer/DatePrefixer.go
Normal file
38
plugin/someteam.example.com/v1/dateprefixer/DatePrefixer.go
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
type plugin struct{}
|
||||
|
||||
var KustomizePlugin plugin
|
||||
|
||||
func (p *plugin) Config(
|
||||
ldr ifc.Loader, rf *resmap.Factory, c []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Returns a constant, rather than
|
||||
// time.Now().Format("2006-01-02")
|
||||
// to make tests happy.
|
||||
// This is just an example.
|
||||
func getDate() string {
|
||||
return "2018-05-11"
|
||||
}
|
||||
|
||||
func (p *plugin) Transform(m resmap.ResMap) error {
|
||||
tr, err := transformers.NewNamePrefixSuffixTransformer(
|
||||
getDate()+"-", "",
|
||||
config.MakeDefaultConfig().NamePrefix)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return tr.Transform(m)
|
||||
}
|
||||
Reference in New Issue
Block a user