| 1 |
// Copyright 2019 The Kubernetes Authors. |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package krusty |
| 5 |
|
| 6 |
import ( |
| 7 |
"sigs.k8s.io/kustomize/api/internal/plugins/builtinhelpers" |
| 8 |
"sigs.k8s.io/kustomize/api/types" |
| 9 |
) |
| 10 |
|
| 11 |
type ReorderOption string |
| 12 |
|
| 13 |
const ( |
| 14 |
ReorderOptionLegacy ReorderOption = "legacy" |
| 15 |
ReorderOptionNone ReorderOption = "none" |
| 16 |
ReorderOptionUnspecified ReorderOption = "unspecified" |
| 17 |
) |
| 18 |
|
| 19 |
// Options holds high-level kustomize configuration options, |
| 20 |
// e.g. are plugins enabled, should the loader be restricted |
| 21 |
// to the kustomization root, etc. |
| 22 |
type Options struct { |
| 23 |
// When true, sort the resources before emitting them, |
| 24 |
// per a particular sort order. When false, don't do the |
| 25 |
// sort, and instead respect the depth-first resource input |
| 26 |
// order as specified by the kustomization file(s). |
| 27 |
|
| 28 |
// Sort the resources before emitting them. Possible values: |
| 29 |
// - "legacy": Use a fixed order that kustomize provides for backwards |
| 30 |
// compatibility. |
| 31 |
// - "none": Respect the depth-first resource input order as specified by the |
| 32 |
// kustomization file. |
| 33 |
// - "unspecified": The user didn't specify any preference. Kustomize will |
| 34 |
// select the appropriate default. |
| 35 |
Reorder ReorderOption |
| 36 |
|
| 37 |
// When true, a label |
| 38 |
// app.kubernetes.io/managed-by: kustomize-<version> |
| 39 |
// is added to all the resources in the build out. |
| 40 |
AddManagedbyLabel bool |
| 41 |
|
| 42 |
// Restrictions on what can be loaded from the file system. |
| 43 |
// See type definition. |
| 44 |
LoadRestrictions types.LoadRestrictions |
| 45 |
|
| 46 |
// Options related to kustomize plugins. |
| 47 |
PluginConfig *types.PluginConfig |
| 48 |
} |
| 49 |
|
| 50 |
// MakeDefaultOptions returns a default instance of Options. |
| 51 |
func MakeDefaultOptions() *Options { |
| 52 |
return &Options{ |
| 53 |
Reorder: ReorderOptionNone, |
| 54 |
AddManagedbyLabel: false, |
| 55 |
LoadRestrictions: types.LoadRestrictionsRootOnly, |
| 56 |
PluginConfig: types.DisabledPluginConfig(), |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
// GetBuiltinPluginNames returns a list of builtin plugin names |
| 61 |
func GetBuiltinPluginNames() []string { |
| 62 |
var ret []string |
| 63 |
for k := range builtinhelpers.GeneratorFactories { |
| 64 |
ret = append(ret, k.String()) |
| 65 |
} |
| 66 |
for k := range builtinhelpers.TransformerFactories { |
| 67 |
ret = append(ret, k.String()) |
| 68 |
} |
| 69 |
return ret |
| 70 |
} |