feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> * feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> --------- Signed-off-by: ci-bot <ci-bot@kubesphere.io> Co-authored-by: ks-ci-bot <ks-ci-bot@example.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
committed by
GitHub
parent
b5015ec7b9
commit
447a51f08b
56
vendor/sigs.k8s.io/kustomize/api/krusty/kustomizer.go
generated
vendored
56
vendor/sigs.k8s.io/kustomize/api/krusty/kustomizer.go
generated
vendored
@@ -5,6 +5,7 @@ package krusty
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/internal/builtins"
|
||||
pLdr "sigs.k8s.io/kustomize/api/internal/plugins/loader"
|
||||
@@ -16,6 +17,7 @@ import (
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
"sigs.k8s.io/kustomize/kyaml/errors"
|
||||
"sigs.k8s.io/kustomize/kyaml/filesys"
|
||||
"sigs.k8s.io/kustomize/kyaml/openapi"
|
||||
)
|
||||
@@ -89,11 +91,9 @@ func (b *Kustomizer) Run(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if b.options.DoLegacyResourceSort {
|
||||
err = builtins.NewLegacyOrderTransformerPlugin().Transform(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = b.applySortOrder(m, kt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if b.options.AddManagedbyLabel || utils.StringSliceContains(kt.Kustomization().BuildMetadata, types.ManagedByLabelOption) {
|
||||
t := builtins.LabelTransformerPlugin{
|
||||
@@ -112,10 +112,52 @@ func (b *Kustomizer) Run(
|
||||
}
|
||||
m.RemoveBuildAnnotations()
|
||||
if !utils.StringSliceContains(kt.Kustomization().BuildMetadata, types.OriginAnnotations) {
|
||||
m.RemoveOriginAnnotations()
|
||||
err = m.RemoveOriginAnnotations()
|
||||
if err != nil {
|
||||
return nil, errors.WrapPrefixf(err, "failed to clean up origin tracking annotations")
|
||||
}
|
||||
}
|
||||
if !utils.StringSliceContains(kt.Kustomization().BuildMetadata, types.TransformerAnnotations) {
|
||||
m.RemoveTransformerAnnotations()
|
||||
err = m.RemoveTransformerAnnotations()
|
||||
if err != nil {
|
||||
return nil, errors.WrapPrefixf(err, "failed to clean up transformer annotations")
|
||||
}
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (b *Kustomizer) applySortOrder(m resmap.ResMap, kt *target.KustTarget) error {
|
||||
// Sort order can be defined in two places:
|
||||
// - (new) kustomization file
|
||||
// - (old) CLI flag
|
||||
//
|
||||
// We want the kustomization file to take precedence over the CLI flag.
|
||||
// Eventually, we may want to move away from having a CLI flag altogether:
|
||||
// https://github.com/kubernetes-sigs/kustomize/issues/3947
|
||||
|
||||
// Case 1: Sort order set in kustomization file.
|
||||
if kt.Kustomization().SortOptions != nil {
|
||||
// If set in CLI flag too, warn the user.
|
||||
if b.options.Reorder != ReorderOptionUnspecified {
|
||||
log.Println("Warning: Sorting order is set both in 'kustomization.yaml'" +
|
||||
" ('sortOptions') and in a CLI flag ('--reorder'). Using the" +
|
||||
" kustomization file over the CLI flag.")
|
||||
}
|
||||
pl := &builtins.SortOrderTransformerPlugin{
|
||||
SortOptions: kt.Kustomization().SortOptions,
|
||||
}
|
||||
err := pl.Transform(m)
|
||||
if err != nil {
|
||||
return errors.Wrap(err)
|
||||
}
|
||||
} else if b.options.Reorder == ReorderOptionLegacy || b.options.Reorder == ReorderOptionUnspecified {
|
||||
// Case 2: Sort order set in CLI flag only or not at all.
|
||||
pl := &builtins.SortOrderTransformerPlugin{
|
||||
SortOptions: &types.SortOptions{
|
||||
Order: types.LegacySortOrder,
|
||||
},
|
||||
}
|
||||
return errors.Wrap(pl.Transform(m))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
30
vendor/sigs.k8s.io/kustomize/api/krusty/options.go
generated
vendored
30
vendor/sigs.k8s.io/kustomize/api/krusty/options.go
generated
vendored
@@ -8,6 +8,14 @@ import (
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
)
|
||||
|
||||
type ReorderOption string
|
||||
|
||||
const (
|
||||
ReorderOptionLegacy ReorderOption = "legacy"
|
||||
ReorderOptionNone ReorderOption = "none"
|
||||
ReorderOptionUnspecified ReorderOption = "unspecified"
|
||||
)
|
||||
|
||||
// Options holds high-level kustomize configuration options,
|
||||
// e.g. are plugins enabled, should the loader be restricted
|
||||
// to the kustomization root, etc.
|
||||
@@ -16,7 +24,15 @@ type Options struct {
|
||||
// per a particular sort order. When false, don't do the
|
||||
// sort, and instead respect the depth-first resource input
|
||||
// order as specified by the kustomization file(s).
|
||||
DoLegacyResourceSort bool
|
||||
|
||||
// Sort the resources before emitting them. Possible values:
|
||||
// - "legacy": Use a fixed order that kustomize provides for backwards
|
||||
// compatibility.
|
||||
// - "none": Respect the depth-first resource input order as specified by the
|
||||
// kustomization file.
|
||||
// - "unspecified": The user didn't specify any preference. Kustomize will
|
||||
// select the appropriate default.
|
||||
Reorder ReorderOption
|
||||
|
||||
// When true, a label
|
||||
// app.kubernetes.io/managed-by: kustomize-<version>
|
||||
@@ -27,9 +43,6 @@ type Options struct {
|
||||
// See type definition.
|
||||
LoadRestrictions types.LoadRestrictions
|
||||
|
||||
// Create an inventory object for pruning.
|
||||
DoPrune bool
|
||||
|
||||
// Options related to kustomize plugins.
|
||||
PluginConfig *types.PluginConfig
|
||||
}
|
||||
@@ -37,11 +50,10 @@ type Options struct {
|
||||
// MakeDefaultOptions returns a default instance of Options.
|
||||
func MakeDefaultOptions() *Options {
|
||||
return &Options{
|
||||
DoLegacyResourceSort: false,
|
||||
AddManagedbyLabel: false,
|
||||
LoadRestrictions: types.LoadRestrictionsRootOnly,
|
||||
DoPrune: false,
|
||||
PluginConfig: types.DisabledPluginConfig(),
|
||||
Reorder: ReorderOptionNone,
|
||||
AddManagedbyLabel: false,
|
||||
LoadRestrictions: types.LoadRestrictionsRootOnly,
|
||||
PluginConfig: types.DisabledPluginConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user