mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Add --reorder flag.
This commit is contained in:
40
plugin/builtin/LegacyOrderTransformer.go
Normal file
40
plugin/builtin/LegacyOrderTransformer.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Code generated by pluginator on LegacyOrderTransformer; DO NOT EDIT.
|
||||
package builtin
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||
"sigs.k8s.io/kustomize/pkg/resource"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Sort the resources using an ordering defined in the Gvk class.
|
||||
// This puts cluster-wide basic resources with no
|
||||
// dependencies (like Namespace, StorageClass, etc.)
|
||||
// first, and resources with a high number of dependencies
|
||||
// (like ValidatingWebhookConfiguration) last.
|
||||
type LegacyOrderTransformerPlugin struct{}
|
||||
|
||||
func NewLegacyOrderTransformerPlugin() *LegacyOrderTransformerPlugin {
|
||||
return &LegacyOrderTransformerPlugin{}
|
||||
}
|
||||
|
||||
// Nothing needed for configuration.
|
||||
func (p *LegacyOrderTransformerPlugin) Config(
|
||||
ldr ifc.Loader, rf *resmap.Factory, c []byte) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *LegacyOrderTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||
resources := make([]*resource.Resource, m.Size())
|
||||
ids := m.AllIds()
|
||||
sort.Sort(resmap.IdSlice(ids))
|
||||
for i, id := range ids {
|
||||
resources[i] = m.GetById(id)
|
||||
}
|
||||
m.Clear()
|
||||
for i, id := range ids {
|
||||
m.AppendWithId(id, resources[i])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user