mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
change field name: prune -> inventory
This commit is contained in:
@@ -19,8 +19,8 @@ package transformer
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/k8sdeps/transformer/hash"
|
||||
"sigs.k8s.io/kustomize/k8sdeps/transformer/inventory"
|
||||
"sigs.k8s.io/kustomize/k8sdeps/transformer/patch"
|
||||
"sigs.k8s.io/kustomize/k8sdeps/transformer/prune"
|
||||
"sigs.k8s.io/kustomize/pkg/resource"
|
||||
"sigs.k8s.io/kustomize/pkg/transformers"
|
||||
"sigs.k8s.io/kustomize/pkg/types"
|
||||
@@ -44,6 +44,6 @@ func (p *FactoryImpl) MakeHashTransformer() transformers.Transformer {
|
||||
return hash.NewNameHashTransformer()
|
||||
}
|
||||
|
||||
func (p *FactoryImpl) MakePruneTransformer(arg *types.Prune, namespace string, append bool) transformers.Transformer {
|
||||
return prune.NewPruneTransformer(arg, namespace, append)
|
||||
func (p *FactoryImpl) MakeInventoryTransformer(arg *types.Inventory, namespace string, append bool) transformers.Transformer {
|
||||
return inventory.NewInventoryTransformer(arg, namespace, append)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package prune
|
||||
package inventory
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -31,33 +31,33 @@ import (
|
||||
//const PruneAnnotation = "kustomize.k8s.io/PruneRevision"
|
||||
const PruneAnnotation = "current"
|
||||
|
||||
// pruneTransformer compute the ConfigMap used in prune
|
||||
type pruneTransformer struct {
|
||||
// inventoryTransformer compute the ConfigMap used in prune
|
||||
type inventoryTransformer struct {
|
||||
append bool
|
||||
cmName string
|
||||
cmNamespace string
|
||||
}
|
||||
|
||||
var _ transformers.Transformer = &pruneTransformer{}
|
||||
var _ transformers.Transformer = &inventoryTransformer{}
|
||||
|
||||
// NewPruneTransformer makes a pruneTransformer.
|
||||
func NewPruneTransformer(p *types.Prune, namespace string, append bool) transformers.Transformer {
|
||||
// NewInventoryTransformer makes a inventoryTransformer.
|
||||
func NewInventoryTransformer(p *types.Inventory, namespace string, append bool) transformers.Transformer {
|
||||
if p == nil || p.Type != "ConfigMap" || p.ConfigMap.Namespace != namespace {
|
||||
return transformers.NewNoOpTransformer()
|
||||
}
|
||||
return &pruneTransformer{
|
||||
return &inventoryTransformer{
|
||||
append: append,
|
||||
cmName: p.ConfigMap.Name,
|
||||
cmNamespace: p.ConfigMap.Namespace,
|
||||
}
|
||||
}
|
||||
|
||||
// Transform generates a prune ConfigMap based on the input ResMap.
|
||||
// Transform generates an inventory ConfigMap based on the input ResMap.
|
||||
// this tranformer doesn't change existing resources -
|
||||
// it just visits resources and accumulates information to make a new ConfigMap.
|
||||
// The prune ConfigMap is used to support the pruning command in the client side tool,
|
||||
// which is proposed in https://github.com/kubernetes/enhancements/pull/810
|
||||
func (o *pruneTransformer) Transform(m resmap.ResMap) error {
|
||||
func (o *inventoryTransformer) Transform(m resmap.ResMap) error {
|
||||
var keys []string
|
||||
for _, r := range m {
|
||||
s := r.PruneString()
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package prune
|
||||
package inventory
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
@@ -103,7 +103,7 @@ func makeResMap() resmap.ResMap {
|
||||
return objs
|
||||
}
|
||||
|
||||
func TestPruneTransformer(t *testing.T) {
|
||||
func TestInventoryTransformer(t *testing.T) {
|
||||
rf := resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl())
|
||||
|
||||
@@ -138,7 +138,7 @@ func TestPruneTransformer(t *testing.T) {
|
||||
resid.NewResIdWithPrefixNamespace(cmap, "pruneCM", "", "default"): pruneMap,
|
||||
}
|
||||
|
||||
p := &types.Prune{
|
||||
p := &types.Inventory{
|
||||
Type: "ConfigMap",
|
||||
ConfigMap: types.NameArgs{
|
||||
Name: "pruneCM",
|
||||
@@ -148,7 +148,7 @@ func TestPruneTransformer(t *testing.T) {
|
||||
objs := makeResMap()
|
||||
|
||||
// include the original resmap; only return the ConfigMap for pruning
|
||||
tran := NewPruneTransformer(p, "default", false)
|
||||
tran := NewInventoryTransformer(p, "default", false)
|
||||
tran.Transform(objs)
|
||||
|
||||
if !reflect.DeepEqual(objs, expected) {
|
||||
@@ -160,7 +160,7 @@ func TestPruneTransformer(t *testing.T) {
|
||||
expected = objs.DeepCopy(rf)
|
||||
expected[resid.NewResIdWithPrefixNamespace(cmap, "pruneCM", "", "default")] = pruneMap
|
||||
// append the ConfigMap for pruning to the original resmap
|
||||
tran = NewPruneTransformer(p, "default", true)
|
||||
tran = NewInventoryTransformer(p, "default", true)
|
||||
tran.Transform(objs)
|
||||
|
||||
if !reflect.DeepEqual(objs, expected) {
|
||||
Reference in New Issue
Block a user