mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-30 18:01:21 +00:00
Improve config package names and reduce API exposure.
This commit is contained in:
@@ -12,8 +12,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/krusty"
|
||||
"sigs.k8s.io/kustomize/api/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
"sigs.k8s.io/yaml"
|
||||
@@ -57,7 +57,7 @@ func NewCmdBuild(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "build {path}",
|
||||
Short: "Print configuration per contents of " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
konfig.DefaultKustomizationFileName(),
|
||||
Example: examples,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
@@ -87,7 +87,7 @@ func (o *Options) Validate(args []string) (err error) {
|
||||
if len(args) > 1 {
|
||||
return errors.New(
|
||||
"specify one path to " +
|
||||
pgmconfig.DefaultKustomizationFileName())
|
||||
konfig.DefaultKustomizationFileName())
|
||||
}
|
||||
if len(args) == 0 {
|
||||
o.kustomizationPath = CWD
|
||||
@@ -109,13 +109,13 @@ func (o *Options) makeOptions() *krusty.Options {
|
||||
DoPrune: false,
|
||||
}
|
||||
if isFlagEnablePluginsSet() {
|
||||
c, err := pgmconfig.EnabledPluginConfig()
|
||||
c, err := konfig.EnabledPluginConfig()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
opts.PluginConfig = c
|
||||
} else {
|
||||
opts.PluginConfig = pgmconfig.DisabledPluginConfig()
|
||||
opts.PluginConfig = konfig.DisabledPluginConfig()
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ package build
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
)
|
||||
|
||||
func TestNewOptionsToSilenceCodeInspectionError(t *testing.T) {
|
||||
@@ -28,7 +28,7 @@ func TestBuildValidate(t *testing.T) {
|
||||
{"path", []string{"too", "many"},
|
||||
"",
|
||||
"specify one path to " +
|
||||
pgmconfig.DefaultKustomizationFileName()},
|
||||
konfig.DefaultKustomizationFileName()},
|
||||
}
|
||||
for _, mycase := range cases {
|
||||
opts := Options{}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/validator"
|
||||
"sigs.k8s.io/kustomize/api/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/build"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/config"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/create"
|
||||
@@ -26,7 +26,7 @@ func NewDefaultCommand() *cobra.Command {
|
||||
stdOut := os.Stdout
|
||||
|
||||
c := &cobra.Command{
|
||||
Use: pgmconfig.ProgramName,
|
||||
Use: konfig.ProgramName,
|
||||
Short: "Manages declarative configuration of Kubernetes",
|
||||
Long: `
|
||||
Manages declarative configuration of Kubernetes.
|
||||
|
||||
@@ -8,9 +8,8 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/plugins/builtinconfig/consts"
|
||||
"sigs.k8s.io/kustomize/api/konfig/builtinpluginconsts"
|
||||
)
|
||||
|
||||
// NewCmdConfig returns an instance of 'config' subcommand.
|
||||
@@ -89,7 +88,7 @@ func (o *saveOptions) Complete(fSys filesys.FileSystem) error {
|
||||
|
||||
// RunSave saves the default transformer configurations local directory
|
||||
func (o *saveOptions) RunSave(fSys filesys.FileSystem) error {
|
||||
m := consts.GetDefaultFieldSpecsAsMap()
|
||||
m := builtinpluginconsts.GetDefaultFieldSpecsAsMap()
|
||||
for tname, tcfg := range m {
|
||||
filename := filepath.Join(o.saveDirectory, tname+".yaml")
|
||||
err := fSys.WriteFile(filename, []byte(tcfg))
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/ifc"
|
||||
"sigs.k8s.io/kustomize/api/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
|
||||
)
|
||||
@@ -162,7 +162,7 @@ func detectResources(fSys filesys.FileSystem, uf ifc.KunstructuredFactory, base
|
||||
}
|
||||
// If a sub-directory contains an existing kustomization file add the
|
||||
// directory as a resource and do not decend into it.
|
||||
for _, kfilename := range pgmconfig.RecognizedKustomizationFileNames() {
|
||||
for _, kfilename := range konfig.RecognizedKustomizationFileNames() {
|
||||
if fSys.Exists(filepath.Join(path, kfilename)) {
|
||||
paths = append(paths, path)
|
||||
return filepath.SkipDir
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
|
||||
@@ -48,7 +48,7 @@ func newCmdAddAnnotation(fSys filesys.FileSystem, v func(map[string]string) erro
|
||||
cmd := &cobra.Command{
|
||||
Use: "annotation",
|
||||
Short: "Adds one or more commonAnnotations to " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
konfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
add annotation {annotationKey1:annotationValue1},{annotationKey2:annotationValue2}`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
@@ -69,7 +69,7 @@ func newCmdAddLabel(fSys filesys.FileSystem, v func(map[string]string) error) *c
|
||||
cmd := &cobra.Command{
|
||||
Use: "label",
|
||||
Short: "Adds one or more commonLabels to " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
konfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
add label {labelKey1:labelValue1},{labelKey2:labelValue2}`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
@@ -1,18 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package patch
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
)
|
||||
@@ -48,7 +48,7 @@ func newCmdRemoveAnnotation(fSys filesys.FileSystem, v func([]string) error) *co
|
||||
cmd := &cobra.Command{
|
||||
Use: "annotation",
|
||||
Short: "Removes one or more commonAnnotations from " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
konfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
remove annotation {annotationKey1},{annotationKey2}`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
@@ -69,7 +69,7 @@ func newCmdRemoveLabel(fSys filesys.FileSystem, v func([]string) error) *cobra.C
|
||||
cmd := &cobra.Command{
|
||||
Use: "label",
|
||||
Short: "Removes one or more commonLabels from " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
konfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
remove label {labelKey1},{labelKey2}`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/edit/patch"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
|
||||
@@ -26,7 +26,7 @@ func newCmdRemovePatch(fSys filesys.FileSystem) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "patch",
|
||||
Short: "Removes one or more patches from " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
konfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
remove patch {filepath}`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
)
|
||||
|
||||
@@ -24,7 +24,7 @@ func newCmdRemoveResource(fSys filesys.FileSystem) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "resource",
|
||||
Short: "Removes one or more resource file paths from " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
konfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
remove resource my-resource.yml
|
||||
remove resource resource1.yml resource2.yml resource3.yml
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
@@ -119,7 +119,7 @@ func NewKustomizationFile(fSys filesys.FileSystem) (*kustomizationFile, error) {
|
||||
func (mf *kustomizationFile) validate() error {
|
||||
match := 0
|
||||
var path []string
|
||||
for _, kfilename := range pgmconfig.RecognizedKustomizationFileNames() {
|
||||
for _, kfilename := range konfig.RecognizedKustomizationFileNames() {
|
||||
if mf.fSys.Exists(kfilename) {
|
||||
match += 1
|
||||
path = append(path, kfilename)
|
||||
@@ -130,7 +130,7 @@ func (mf *kustomizationFile) validate() error {
|
||||
case 0:
|
||||
return fmt.Errorf(
|
||||
"Missing kustomization file '%s'.\n",
|
||||
pgmconfig.DefaultKustomizationFileName())
|
||||
konfig.DefaultKustomizationFileName())
|
||||
case 1:
|
||||
mf.path = path[0]
|
||||
default:
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
)
|
||||
@@ -104,7 +104,7 @@ configMapGenerator:
|
||||
- baz=qux
|
||||
name: my-configmap
|
||||
`
|
||||
for _, n := range pgmconfig.RecognizedKustomizationFileNames() {
|
||||
for _, n := range konfig.RecognizedKustomizationFileNames() {
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.WriteFile(n, []byte(kcontent))
|
||||
k, err := NewKustomizationFile(fSys)
|
||||
|
||||
@@ -5,7 +5,7 @@ package testutils_test
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -38,10 +38,10 @@ func WriteTestKustomization(fSys filesys.FileSystem) {
|
||||
|
||||
// WriteTestKustomizationWith writes content to a well known file name.
|
||||
func WriteTestKustomizationWith(fSys filesys.FileSystem, bytes []byte) {
|
||||
fSys.WriteFile(pgmconfig.DefaultKustomizationFileName(), bytes)
|
||||
fSys.WriteFile(konfig.DefaultKustomizationFileName(), bytes)
|
||||
}
|
||||
|
||||
// ReadTestKustomization reads content from a well known file name.
|
||||
func ReadTestKustomization(fSys filesys.FileSystem) ([]byte, error) {
|
||||
return fSys.ReadFile(pgmconfig.DefaultKustomizationFileName())
|
||||
return fSys.ReadFile(konfig.DefaultKustomizationFileName())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user