mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-18 05:35:47 +00:00
[doc]: https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher Per this Go modules [doc] a repo or branch that's already tagged v2 or higher should increment the major version (e.g. go to v3) when releasing their first Go module-based packages. At the moment, the kustomize repo has these top level packages in the sigs.k8s.io/kustomize module: - `cmd` - holds main program for kustomize Conceivably someone can depend on this package for integration tests. - `internal` - intentionally unreleased subpackages - `k8sdeps` - an adapter wrapping k8s dependencies This exists only for use in pre-Go-modules kustomize-into-kubectl integration and won't live much longer (as everything involved is switching to Go modules). - `pkg` - kustomize packages for export This should shrink in later versions, since the surface area is too large, containing sub-packages that should be in 'internal'. - `plugin` - holds main programs for plugins This PR changes the top level go.mod file from ``` module sigs.k8s.io/kustomize ``` to ``` module sigs.k8s.io/kustomize/v3 ``` and adjusts all import statements to reflect the change.
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
// Code generated by pluginator on LegacyOrderTransformer; DO NOT EDIT.
|
|
package builtin
|
|
|
|
import (
|
|
"github.com/pkg/errors"
|
|
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
|
"sigs.k8s.io/kustomize/v3/pkg/resmap"
|
|
"sigs.k8s.io/kustomize/v3/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{}
|
|
|
|
//noinspection GoUnusedGlobalVariable
|
|
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) (err error) {
|
|
resources := make([]*resource.Resource, m.Size())
|
|
ids := m.AllIds()
|
|
sort.Sort(resmap.IdSlice(ids))
|
|
for i, id := range ids {
|
|
resources[i], err = m.GetByCurrentId(id)
|
|
if err != nil {
|
|
return errors.Wrap(err, "expected match for sorting")
|
|
}
|
|
}
|
|
m.Clear()
|
|
for _, r := range resources {
|
|
m.Append(r)
|
|
}
|
|
return nil
|
|
}
|