mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
// 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
|
|
}
|