mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 09:24:23 +00:00
Rename fs package to filesys
This commit is contained in:
2
go.mod
2
go.mod
@@ -11,6 +11,8 @@ require (
|
||||
github.com/monopole/mdrip v1.0.0
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/spf13/pflag v1.0.5
|
||||
golang.org/x/net v0.0.0-20191011234655-491137f69257 // indirect
|
||||
golang.org/x/tools v0.0.0-20191014141550-5fa5b1782b2c // indirect
|
||||
gopkg.in/yaml.v2 v2.2.2
|
||||
k8s.io/api v0.0.0-20190313235455-40a48860b5ab
|
||||
k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1
|
||||
|
||||
7
go.sum
7
go.sum
@@ -343,10 +343,13 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwL
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b h1:XfVGCX+0T4WOStkaOsJRllbsiImhB2jgVBGc9L0lPGc=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191011234655-491137f69257 h1:ry8e2D+cwaV6hk7lb3aRTjjZo24shrbK0e11QEOkTIg=
|
||||
golang.org/x/net v0.0.0-20191011234655-491137f69257/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -388,6 +391,9 @@ golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.0.0-20190911230505-6bfd74cf029c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190912215617-3720d1ec3678 h1:rM1Udd0CgtYI3KUIhu9ROz0QCqjW+n/ODp/hH7c60Xc=
|
||||
golang.org/x/tools v0.0.0-20190912215617-3720d1ec3678/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191014141550-5fa5b1782b2c h1:PCDsQ/i3XTQEuyIMOOa9pgQZsQi3ETM+3at2Z02nBo4=
|
||||
golang.org/x/tools v0.0.0-20191014141550-5fa5b1782b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
@@ -432,6 +438,7 @@ mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b h1:DxJ5nJdkhDlLok9K6qO+5290kphD
|
||||
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4=
|
||||
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f h1:Cq7MalBHYACRd6EesksG1Q8EoIAKOsiZviGKbOLIej4=
|
||||
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
|
||||
sigs.k8s.io/kustomize/pluginator v1.0.0 h1:aeLqD8CIaqr++49YrcuRUcXl5vVKYLhCSfwXUi3ifQ4=
|
||||
sigs.k8s.io/kustomize/pluginator v1.0.0/go.mod h1:i8HdU5FdH1zDjCKiFf5CNl7slsc0QffyKsY2OuPynJ0=
|
||||
sigs.k8s.io/kustomize/v3 v3.2.0/go.mod h1:ztX4zYc/QIww3gSripwF7TBOarBTm5BvyAMem0kCzOE=
|
||||
|
||||
@@ -7,7 +7,7 @@ package loadertest
|
||||
import (
|
||||
"log"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/loader"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
// FakeLoader encapsulates the delegate Loader and the fake file system.
|
||||
type FakeLoader struct {
|
||||
fs fs.FileSystem
|
||||
fs filesys.FileSystem
|
||||
delegate ifc.Loader
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func NewFakeLoader(initialDir string) FakeLoader {
|
||||
func NewFakeLoaderWithRestrictor(
|
||||
lr loader.LoadRestrictorFunc, initialDir string) FakeLoader {
|
||||
// Create fake filesystem and inject it into initial Loader.
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.Mkdir(initialDir)
|
||||
ldr, err := loader.NewLoader(
|
||||
lr, validators.MakeFakeValidator(), initialDir, fSys)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/loader"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/validators"
|
||||
@@ -131,15 +131,15 @@ func TestConstructConfigMap(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.WriteFile(
|
||||
fs.RPath("configmap", "app.env"),
|
||||
filesys.RPath("configmap", "app.env"),
|
||||
[]byte("DB_USERNAME=admin\nDB_PASSWORD=somepw\n"))
|
||||
fSys.WriteFile(
|
||||
fs.RPath("configmap", "app-init.ini"),
|
||||
filesys.RPath("configmap", "app-init.ini"),
|
||||
[]byte("FOO=bar\nBAR=baz\n"))
|
||||
fSys.WriteFile(
|
||||
fs.RPath("configmap", "app.bin"),
|
||||
filesys.RPath("configmap", "app.bin"),
|
||||
[]byte{0xff, 0xfd})
|
||||
ldr := loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys)
|
||||
for _, tc := range testCases {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/loader"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/validators"
|
||||
@@ -123,7 +123,7 @@ func TestConstructSecret(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.WriteFile("/secret/app.env", []byte("DB_USERNAME=admin\nDB_PASSWORD=somepw\n"))
|
||||
fSys.WriteFile("/secret/app-init.ini", []byte("FOO=bar\nBAR=baz\n"))
|
||||
ldr := loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys)
|
||||
|
||||
@@ -6,8 +6,8 @@ require (
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/spf13/cobra v0.0.5
|
||||
github.com/spf13/pflag v1.0.5
|
||||
sigs.k8s.io/kustomize/v3 v3.3.0
|
||||
sigs.k8s.io/kustomize/v3 v3.3.1
|
||||
sigs.k8s.io/yaml v1.1.0
|
||||
)
|
||||
|
||||
replace sigs.k8s.io/kustomize/v3 v3.3.0 => ../
|
||||
replace sigs.k8s.io/kustomize/v3 v3.3.1 => ../
|
||||
|
||||
@@ -287,6 +287,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwL
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b h1:XfVGCX+0T4WOStkaOsJRllbsiImhB2jgVBGc9L0lPGc=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191011234655-491137f69257 h1:ry8e2D+cwaV6hk7lb3aRTjjZo24shrbK0e11QEOkTIg=
|
||||
golang.org/x/net v0.0.0-20191011234655-491137f69257/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -331,6 +333,7 @@ golang.org/x/tools v0.0.0-20190719005602-e377ae9d6386/go.mod h1:jcCCGcm9btYwXyDq
|
||||
golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911230505-6bfd74cf029c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190912215617-3720d1ec3678/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191014141550-5fa5b1782b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
@@ -372,8 +375,11 @@ k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208/go.mod h1:nfDlWeOsu3pUf4y
|
||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4=
|
||||
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
|
||||
sigs.k8s.io/kustomize/pluginator v1.0.0/go.mod h1:i8HdU5FdH1zDjCKiFf5CNl7slsc0QffyKsY2OuPynJ0=
|
||||
sigs.k8s.io/kustomize/v3 v3.2.0/go.mod h1:ztX4zYc/QIww3gSripwF7TBOarBTm5BvyAMem0kCzOE=
|
||||
sigs.k8s.io/kustomize/v3 v3.3.1 h1:UOhJqkRINRODnKq24DoDAr4gxk2z2p9iFJWDT3OLBx8=
|
||||
sigs.k8s.io/kustomize/v3 v3.3.1/go.mod h1:2ojB+51Z+YIBpEOknAFX3U8f0XXa94PFcfXPccDxAfg=
|
||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
||||
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/loader"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
@@ -58,7 +58,7 @@ https://github.com/hashicorp/go-getter#url-format
|
||||
|
||||
// NewCmdBuild creates a new build command.
|
||||
func NewCmdBuild(
|
||||
out io.Writer, fSys fs.FileSystem,
|
||||
out io.Writer, fSys filesys.FileSystem,
|
||||
v ifc.Validator, rf *resmap.Factory,
|
||||
ptf resmap.PatchFactory) *cobra.Command {
|
||||
var o Options
|
||||
@@ -115,7 +115,7 @@ func (o *Options) Validate(args []string) (err error) {
|
||||
|
||||
// RunBuild runs build command.
|
||||
func (o *Options) RunBuild(
|
||||
out io.Writer, v ifc.Validator, fSys fs.FileSystem,
|
||||
out io.Writer, v ifc.Validator, fSys filesys.FileSystem,
|
||||
rf *resmap.Factory, ptf resmap.PatchFactory,
|
||||
pl *plugins.Loader) error {
|
||||
ldr, err := loader.NewLoader(
|
||||
@@ -136,7 +136,7 @@ func (o *Options) RunBuild(
|
||||
}
|
||||
|
||||
func (o *Options) RunBuildPrune(
|
||||
out io.Writer, v ifc.Validator, fSys fs.FileSystem,
|
||||
out io.Writer, v ifc.Validator, fSys filesys.FileSystem,
|
||||
rf *resmap.Factory, ptf resmap.PatchFactory,
|
||||
pl *plugins.Loader) error {
|
||||
ldr, err := loader.NewLoader(
|
||||
@@ -157,7 +157,7 @@ func (o *Options) RunBuildPrune(
|
||||
}
|
||||
|
||||
func (o *Options) emitResources(
|
||||
out io.Writer, fSys fs.FileSystem, m resmap.ResMap) error {
|
||||
out io.Writer, fSys filesys.FileSystem, m resmap.ResMap) error {
|
||||
if o.outputPath != "" && fSys.IsDir(o.outputPath) {
|
||||
return writeIndividualFiles(fSys, o.outputPath, m)
|
||||
}
|
||||
@@ -180,7 +180,7 @@ func (o *Options) emitResources(
|
||||
}
|
||||
|
||||
func NewCmdBuildPrune(
|
||||
out io.Writer, v ifc.Validator, fSys fs.FileSystem,
|
||||
out io.Writer, v ifc.Validator, fSys filesys.FileSystem,
|
||||
rf *resmap.Factory, ptf resmap.PatchFactory,
|
||||
pl *plugins.Loader) *cobra.Command {
|
||||
var o Options
|
||||
@@ -202,7 +202,7 @@ func NewCmdBuildPrune(
|
||||
}
|
||||
|
||||
func writeIndividualFiles(
|
||||
fSys fs.FileSystem, folderPath string, m resmap.ResMap) error {
|
||||
fSys filesys.FileSystem, folderPath string, m resmap.ResMap) error {
|
||||
byNamespace := m.GroupedByCurrentNamespace()
|
||||
for namespace, resList := range byNamespace {
|
||||
for _, res := range resList {
|
||||
@@ -231,7 +231,7 @@ func fileName(res *resource.Resource) string {
|
||||
}
|
||||
|
||||
func writeFile(
|
||||
fSys fs.FileSystem, path, fName string, res *resource.Resource) error {
|
||||
fSys filesys.FileSystem, path, fName string, res *resource.Resource) error {
|
||||
out, err := yaml.Marshal(res.Map())
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/v3/k8sdeps/transformer"
|
||||
"sigs.k8s.io/kustomize/v3/k8sdeps/validator"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resmap"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resource"
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
|
||||
// NewDefaultCommand returns the default (aka root) command for kustomize command.
|
||||
func NewDefaultCommand() *cobra.Command {
|
||||
fSys := fs.MakeFsOnDisk()
|
||||
fSys := filesys.MakeFsOnDisk()
|
||||
stdOut := os.Stdout
|
||||
|
||||
c := &cobra.Command{
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/transformers/config/defaultconfig"
|
||||
)
|
||||
|
||||
// NewCmdConfig returns an instance of 'config' subcommand.
|
||||
func NewCmdConfig(fsys fs.FileSystem) *cobra.Command {
|
||||
func NewCmdConfig(fSys filesys.FileSystem) *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "config",
|
||||
Short: "Config Kustomize transformers",
|
||||
@@ -26,7 +26,7 @@ func NewCmdConfig(fsys fs.FileSystem) *cobra.Command {
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
}
|
||||
c.AddCommand(
|
||||
newCmdSave(fsys),
|
||||
newCmdSave(fSys),
|
||||
)
|
||||
return c
|
||||
}
|
||||
@@ -35,7 +35,7 @@ type saveOptions struct {
|
||||
saveDirectory string
|
||||
}
|
||||
|
||||
func newCmdSave(fsys fs.FileSystem) *cobra.Command {
|
||||
func newCmdSave(fSys filesys.FileSystem) *cobra.Command {
|
||||
var o saveOptions
|
||||
|
||||
c := &cobra.Command{
|
||||
@@ -52,11 +52,11 @@ func newCmdSave(fsys fs.FileSystem) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = o.Complete(fsys)
|
||||
err = o.Complete(fSys)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunSave(fsys)
|
||||
return o.RunSave(fSys)
|
||||
},
|
||||
}
|
||||
c.Flags().StringVarP(
|
||||
@@ -77,22 +77,22 @@ func (o *saveOptions) Validate() error {
|
||||
}
|
||||
|
||||
// Complete creates the save directory when the directory doesn't exist
|
||||
func (o *saveOptions) Complete(fsys fs.FileSystem) error {
|
||||
if !fsys.Exists(o.saveDirectory) {
|
||||
return fsys.MkdirAll(o.saveDirectory)
|
||||
func (o *saveOptions) Complete(fSys filesys.FileSystem) error {
|
||||
if !fSys.Exists(o.saveDirectory) {
|
||||
return fSys.MkdirAll(o.saveDirectory)
|
||||
}
|
||||
if fsys.IsDir(o.saveDirectory) {
|
||||
if fSys.IsDir(o.saveDirectory) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("%s is not a directory", o.saveDirectory)
|
||||
}
|
||||
|
||||
// RunSave saves the default transformer configurations local directory
|
||||
func (o *saveOptions) RunSave(fsys fs.FileSystem) error {
|
||||
func (o *saveOptions) RunSave(fSys filesys.FileSystem) error {
|
||||
m := defaultconfig.GetDefaultFieldSpecsAsMap()
|
||||
for tname, tcfg := range m {
|
||||
filename := filepath.Join(o.saveDirectory, tname+".yaml")
|
||||
err := fsys.WriteFile(filename, []byte(tcfg))
|
||||
err := fSys.WriteFile(filename, []byte(tcfg))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
func TestValidate(t *testing.T) {
|
||||
@@ -29,7 +29,7 @@ func TestValidate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestComplete(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.Mkdir("/some/dir")
|
||||
fSys.WriteFile("/some/file", []byte(`some file`))
|
||||
|
||||
@@ -62,7 +62,7 @@ func TestComplete(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRunSave(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
o := saveOptions{saveDirectory: "/some/dir"}
|
||||
err := o.RunSave(fSys)
|
||||
if err != nil {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
)
|
||||
@@ -30,7 +30,7 @@ type createFlags struct {
|
||||
}
|
||||
|
||||
// NewCmdCreate returns an instance of 'create' subcommand.
|
||||
func NewCmdCreate(fSys fs.FileSystem, uf ifc.KunstructuredFactory) *cobra.Command {
|
||||
func NewCmdCreate(fSys filesys.FileSystem, uf ifc.KunstructuredFactory) *cobra.Command {
|
||||
opts := createFlags{path: "."}
|
||||
c := &cobra.Command{
|
||||
Use: "create",
|
||||
@@ -93,7 +93,7 @@ func NewCmdCreate(fSys fs.FileSystem, uf ifc.KunstructuredFactory) *cobra.Comman
|
||||
return c
|
||||
}
|
||||
|
||||
func runCreate(opts createFlags, fSys fs.FileSystem, uf ifc.KunstructuredFactory) error {
|
||||
func runCreate(opts createFlags, fSys filesys.FileSystem, uf ifc.KunstructuredFactory) error {
|
||||
var resources []string
|
||||
var err error
|
||||
if opts.resources != "" {
|
||||
@@ -147,7 +147,7 @@ func runCreate(opts createFlags, fSys fs.FileSystem, uf ifc.KunstructuredFactory
|
||||
return mf.Write(m)
|
||||
}
|
||||
|
||||
func detectResources(fSys fs.FileSystem, uf ifc.KunstructuredFactory, base string, recursive bool) ([]string, error) {
|
||||
func detectResources(fSys filesys.FileSystem, uf ifc.KunstructuredFactory, base string, recursive bool) ([]string, error) {
|
||||
var paths []string
|
||||
err := fSys.Walk(base, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
|
||||
@@ -9,13 +9,13 @@ import (
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
)
|
||||
|
||||
var factory = kunstruct.NewKunstructuredFactoryImpl()
|
||||
|
||||
func readKustomizationFS(t *testing.T, fSys fs.FileSystem) *types.Kustomization {
|
||||
func readKustomizationFS(t *testing.T, fSys filesys.FileSystem) *types.Kustomization {
|
||||
kf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected new error %v", err)
|
||||
@@ -27,7 +27,7 @@ func readKustomizationFS(t *testing.T, fSys fs.FileSystem) *types.Kustomization
|
||||
return m
|
||||
}
|
||||
func TestCreateNoArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
cmd := NewCmdCreate(fSys, factory)
|
||||
err := cmd.RunE(cmd, []string{})
|
||||
if err != nil {
|
||||
@@ -37,7 +37,7 @@ func TestCreateNoArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithResources(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.WriteFile("foo.yaml", []byte(""))
|
||||
fSys.WriteFile("bar.yaml", []byte(""))
|
||||
opts := createFlags{resources: "foo.yaml,bar.yaml"}
|
||||
@@ -53,7 +53,7 @@ func TestCreateWithResources(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithNamespace(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
want := "foo"
|
||||
opts := createFlags{namespace: want}
|
||||
err := runCreate(opts, fSys, factory)
|
||||
@@ -68,7 +68,7 @@ func TestCreateWithNamespace(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithLabels(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
opts := createFlags{labels: "foo:bar"}
|
||||
err := runCreate(opts, fSys, factory)
|
||||
if err != nil {
|
||||
@@ -82,7 +82,7 @@ func TestCreateWithLabels(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithAnnotations(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
opts := createFlags{annotations: "foo:bar"}
|
||||
err := runCreate(opts, fSys, factory)
|
||||
if err != nil {
|
||||
@@ -96,7 +96,7 @@ func TestCreateWithAnnotations(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithNamePrefix(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
want := "foo-"
|
||||
opts := createFlags{prefix: want}
|
||||
err := runCreate(opts, fSys, factory)
|
||||
@@ -111,7 +111,7 @@ func TestCreateWithNamePrefix(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithNameSuffix(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
opts := createFlags{suffix: "-foo"}
|
||||
err := runCreate(opts, fSys, factory)
|
||||
if err != nil {
|
||||
@@ -123,7 +123,7 @@ func TestCreateWithNameSuffix(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func writeDetectContent(fSys fs.FileSystem) {
|
||||
func writeDetectContent(fSys filesys.FileSystem) {
|
||||
fSys.WriteFile("/test.yaml", []byte(`
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
@@ -165,7 +165,7 @@ resources:
|
||||
}
|
||||
|
||||
func TestCreateWithDetect(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
writeDetectContent(fSys)
|
||||
opts := createFlags{path: "/", detectResources: true}
|
||||
err := runCreate(opts, fSys, factory)
|
||||
@@ -180,7 +180,7 @@ func TestCreateWithDetect(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithDetectRecursive(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
writeDetectContent(fSys)
|
||||
opts := createFlags{path: "/", detectResources: true, detectRecursive: true}
|
||||
err := runCreate(opts, fSys, factory)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
type addBaseOptions struct {
|
||||
@@ -18,7 +18,7 @@ type addBaseOptions struct {
|
||||
}
|
||||
|
||||
// newCmdAddBase adds the file path of the kustomize base to the kustomization file.
|
||||
func newCmdAddBase(fsys fs.FileSystem) *cobra.Command {
|
||||
func newCmdAddBase(fSys filesys.FileSystem) *cobra.Command {
|
||||
var o addBaseOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -35,7 +35,7 @@ func newCmdAddBase(fsys fs.FileSystem) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunAddBase(fsys)
|
||||
return o.RunAddBase(fSys)
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
@@ -56,7 +56,7 @@ func (o *addBaseOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// RunAddBase runs addBase command (do real work).
|
||||
func (o *addBaseOptions) RunAddBase(fSys fs.FileSystem) error {
|
||||
func (o *addBaseOptions) RunAddBase(fSys filesys.FileSystem) error {
|
||||
mf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -17,7 +17,7 @@ const (
|
||||
)
|
||||
|
||||
func TestAddBaseHappyPath(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
bases := strings.Split(baseDirectoryPaths, ",")
|
||||
for _, base := range bases {
|
||||
fSys.Mkdir(base)
|
||||
@@ -43,7 +43,7 @@ func TestAddBaseHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddBaseAlreadyThere(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
// Create fake directories
|
||||
bases := strings.Split(baseDirectoryPaths, ",")
|
||||
for _, base := range bases {
|
||||
@@ -73,7 +73,7 @@ func TestAddBaseAlreadyThere(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddBaseNoArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdAddBase(fSys)
|
||||
err := cmd.Execute()
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
)
|
||||
@@ -41,7 +41,7 @@ type addMetadataOptions struct {
|
||||
}
|
||||
|
||||
// newCmdAddAnnotation adds one or more commonAnnotations to the kustomization file.
|
||||
func newCmdAddAnnotation(fSys fs.FileSystem, v func(map[string]string) error) *cobra.Command {
|
||||
func newCmdAddAnnotation(fSys filesys.FileSystem, v func(map[string]string) error) *cobra.Command {
|
||||
var o addMetadataOptions
|
||||
o.kind = annotation
|
||||
o.mapValidator = v
|
||||
@@ -62,7 +62,7 @@ func newCmdAddAnnotation(fSys fs.FileSystem, v func(map[string]string) error) *c
|
||||
}
|
||||
|
||||
// newCmdAddLabel adds one or more commonLabels to the kustomization file.
|
||||
func newCmdAddLabel(fSys fs.FileSystem, v func(map[string]string) error) *cobra.Command {
|
||||
func newCmdAddLabel(fSys filesys.FileSystem, v func(map[string]string) error) *cobra.Command {
|
||||
var o addMetadataOptions
|
||||
o.kind = label
|
||||
o.mapValidator = v
|
||||
@@ -83,7 +83,7 @@ func newCmdAddLabel(fSys fs.FileSystem, v func(map[string]string) error) *cobra.
|
||||
}
|
||||
|
||||
func (o *addMetadataOptions) runE(
|
||||
args []string, fSys fs.FileSystem, adder func(*types.Kustomization) error) error {
|
||||
args []string, fSys filesys.FileSystem, adder func(*types.Kustomization) error) error {
|
||||
err := o.validateAndParse(args)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -8,13 +8,13 @@ import (
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/validators"
|
||||
)
|
||||
|
||||
func makeKustomization(t *testing.T) *types.Kustomization {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
kf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
@@ -50,7 +50,7 @@ func TestRunAddAnnotation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationNoArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
err := cmd.Execute()
|
||||
@@ -64,7 +64,7 @@ func TestAddAnnotationNoArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationInvalidFormat(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
v := validators.MakeSadMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
args := []string{"whatever:whatever"}
|
||||
@@ -79,7 +79,7 @@ func TestAddAnnotationInvalidFormat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationManyArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
@@ -92,7 +92,7 @@ func TestAddAnnotationManyArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationValueQuoted(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
@@ -105,7 +105,7 @@ func TestAddAnnotationValueQuoted(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationValueWithColon(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
@@ -118,7 +118,7 @@ func TestAddAnnotationValueWithColon(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationNoKey(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
args := []string{":nokey"}
|
||||
@@ -133,7 +133,7 @@ func TestAddAnnotationNoKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationTooManyColons(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
@@ -146,7 +146,7 @@ func TestAddAnnotationTooManyColons(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationNoValue(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
@@ -159,7 +159,7 @@ func TestAddAnnotationNoValue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationMultipleArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
@@ -175,7 +175,7 @@ func TestAddAnnotationMultipleArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationForce(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
@@ -231,7 +231,7 @@ func TestRunAddLabel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelNoArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
err := cmd.Execute()
|
||||
@@ -245,7 +245,7 @@ func TestAddLabelNoArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelInvalidFormat(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
v := validators.MakeSadMapValidator(t)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
args := []string{"exclamation!:point"}
|
||||
@@ -260,7 +260,7 @@ func TestAddLabelInvalidFormat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelNoKey(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
args := []string{":nokey"}
|
||||
@@ -275,7 +275,7 @@ func TestAddLabelNoKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelTooManyColons(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
@@ -288,7 +288,7 @@ func TestAddLabelTooManyColons(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelNoValue(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
@@ -301,7 +301,7 @@ func TestAddLabelNoValue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelMultipleArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
@@ -317,7 +317,7 @@ func TestAddLabelMultipleArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelForce(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/patch"
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ type addPatchOptions struct {
|
||||
}
|
||||
|
||||
// newCmdAddPatch adds the name of a file containing a patch to the kustomization file.
|
||||
func newCmdAddPatch(fsys fs.FileSystem) *cobra.Command {
|
||||
func newCmdAddPatch(fSys filesys.FileSystem) *cobra.Command {
|
||||
var o addPatchOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -36,7 +36,7 @@ func newCmdAddPatch(fsys fs.FileSystem) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunAddPatch(fsys)
|
||||
return o.RunAddPatch(fSys)
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
@@ -57,7 +57,7 @@ func (o *addPatchOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// RunAddPatch runs addPatch command (do real work).
|
||||
func (o *addPatchOptions) RunAddPatch(fSys fs.FileSystem) error {
|
||||
func (o *addPatchOptions) RunAddPatch(fSys filesys.FileSystem) error {
|
||||
patches, err := util.GlobPatterns(fSys, o.patchFilePaths)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -20,7 +20,7 @@ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
)
|
||||
|
||||
func TestAddPatchHappyPath(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.WriteFile(patchFileName, []byte(patchFileContent))
|
||||
fSys.WriteFile(patchFileName+"another", []byte(patchFileContent))
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
@@ -44,7 +44,7 @@ func TestAddPatchHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddPatchAlreadyThere(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.WriteFile(patchFileName, []byte(patchFileContent))
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestAddPatchAlreadyThere(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddPatchNoArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdAddPatch(fSys)
|
||||
err := cmd.Execute()
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
type addResourceOptions struct {
|
||||
@@ -18,7 +18,7 @@ type addResourceOptions struct {
|
||||
}
|
||||
|
||||
// newCmdAddResource adds the name of a file containing a resource to the kustomization file.
|
||||
func newCmdAddResource(fsys fs.FileSystem) *cobra.Command {
|
||||
func newCmdAddResource(fSys filesys.FileSystem) *cobra.Command {
|
||||
var o addResourceOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -35,7 +35,7 @@ func newCmdAddResource(fsys fs.FileSystem) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunAddResource(fsys)
|
||||
return o.RunAddResource(fSys)
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
@@ -56,7 +56,7 @@ func (o *addResourceOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// RunAddResource runs addResource command (do real work).
|
||||
func (o *addResourceOptions) RunAddResource(fSys fs.FileSystem) error {
|
||||
func (o *addResourceOptions) RunAddResource(fSys filesys.FileSystem) error {
|
||||
resources, err := util.GlobPatterns(fSys, o.resourceFilePaths)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -20,7 +20,7 @@ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
)
|
||||
|
||||
func TestAddResourceHappyPath(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.WriteFile(resourceFileName, []byte(resourceFileContent))
|
||||
fSys.WriteFile(resourceFileName+"another", []byte(resourceFileContent))
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
@@ -44,7 +44,7 @@ func TestAddResourceHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddResourceAlreadyThere(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.WriteFile(resourceFileName, []byte(resourceFileContent))
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestAddResourceAlreadyThere(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddResourceNoArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdAddResource(fSys)
|
||||
err := cmd.Execute()
|
||||
|
||||
@@ -5,13 +5,13 @@ package add
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
)
|
||||
|
||||
// NewCmdAdd returns an instance of 'add' subcommand.
|
||||
func NewCmdAdd(
|
||||
fSys fs.FileSystem,
|
||||
fSys filesys.FileSystem,
|
||||
ldr ifc.Loader,
|
||||
kf ifc.KunstructuredFactory) *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
|
||||
@@ -6,14 +6,14 @@ package add
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
)
|
||||
|
||||
// newCmdAddConfigMap returns a new command.
|
||||
func newCmdAddConfigMap(
|
||||
fSys fs.FileSystem,
|
||||
fSys filesys.FileSystem,
|
||||
ldr ifc.Loader,
|
||||
kf ifc.KunstructuredFactory) *cobra.Command {
|
||||
var flags flagsAndArgs
|
||||
|
||||
@@ -6,14 +6,14 @@ package add
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/loader"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/validators"
|
||||
)
|
||||
|
||||
func TestNewAddConfigMapIsNotNil(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
ldr := loader.NewFileLoaderAtCwd(validators.MakeFakeValidator(), fSys)
|
||||
if newCmdAddConfigMap(fSys, ldr, nil) == nil {
|
||||
t.Fatal("newCmdAddConfigMap shouldn't be nil")
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
// flagsAndArgs encapsulates the options for add secret/configmap commands.
|
||||
@@ -59,7 +59,7 @@ func (a *flagsAndArgs) Validate(args []string) error {
|
||||
// and the key, if missing, is the same as the value.
|
||||
// In the case where the key is explicitly declared,
|
||||
// the globbing, if present, must have exactly one match.
|
||||
func (a *flagsAndArgs) ExpandFileSource(fSys fs.FileSystem) error {
|
||||
func (a *flagsAndArgs) ExpandFileSource(fSys filesys.FileSystem) error {
|
||||
var results []string
|
||||
for _, pattern := range a.FileSources {
|
||||
var patterns []string
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
func TestDataValidation_NoName(t *testing.T) {
|
||||
@@ -73,7 +73,7 @@ func TestDataConfigValidation_Flags(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExpandFileSource(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.Create("dir/fa1")
|
||||
fSys.Create("dir/fa2")
|
||||
fSys.Create("dir/readme")
|
||||
@@ -91,7 +91,7 @@ func TestExpandFileSource(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExpandFileSourceWithKey(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.Create("dir/faaaaaaaaaabbbbbbbbbccccccccccccccccc")
|
||||
fSys.Create("dir/foobar")
|
||||
fSys.Create("dir/simplebar")
|
||||
@@ -111,7 +111,7 @@ func TestExpandFileSourceWithKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExpandFileSourceWithKeyAndError(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.Create("dir/fa1")
|
||||
fSys.Create("dir/fa2")
|
||||
fSys.Create("dir/readme")
|
||||
|
||||
@@ -6,14 +6,14 @@ package add
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
)
|
||||
|
||||
// newCmdAddSecret returns a new command.
|
||||
func newCmdAddSecret(
|
||||
fSys fs.FileSystem,
|
||||
fSys filesys.FileSystem,
|
||||
ldr ifc.Loader,
|
||||
kf ifc.KunstructuredFactory) *cobra.Command {
|
||||
var flags flagsAndArgs
|
||||
|
||||
@@ -6,14 +6,14 @@ package add
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/loader"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/validators"
|
||||
)
|
||||
|
||||
func TestNewCmdAddSecretIsNotNil(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
ldr := loader.NewFileLoaderAtCwd(validators.MakeFakeValidator(), fSys)
|
||||
if newCmdAddSecret(fSys, ldr, nil) == nil {
|
||||
t.Fatal("newCmdAddSecret shouldn't be nil")
|
||||
|
||||
@@ -9,14 +9,14 @@ import (
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/edit/fix"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/edit/remove"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/edit/set"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/loader"
|
||||
)
|
||||
|
||||
// NewCmdEdit returns an instance of 'edit' subcommand.
|
||||
func NewCmdEdit(
|
||||
fSys fs.FileSystem, v ifc.Validator, kf ifc.KunstructuredFactory) *cobra.Command {
|
||||
fSys filesys.FileSystem, v ifc.Validator, kf ifc.KunstructuredFactory) *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "edit",
|
||||
Short: "Edits a kustomization file",
|
||||
|
||||
@@ -6,11 +6,11 @@ package fix
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
// NewCmdFix returns an instance of 'fix' subcommand.
|
||||
func NewCmdFix(fSys fs.FileSystem) *cobra.Command {
|
||||
func NewCmdFix(fSys filesys.FileSystem) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "fix",
|
||||
Short: "Fix the missing fields in kustomization file",
|
||||
@@ -28,7 +28,7 @@ func NewCmdFix(fSys fs.FileSystem) *cobra.Command {
|
||||
}
|
||||
|
||||
// RunFix runs `fix` command
|
||||
func RunFix(fSys fs.FileSystem) error {
|
||||
func RunFix(fSys filesys.FileSystem) error {
|
||||
mf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
func TestFix(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(`nameprefix: some-prefix-`))
|
||||
|
||||
cmd := NewCmdFix(fSys)
|
||||
|
||||
@@ -5,13 +5,13 @@ package remove
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
)
|
||||
|
||||
// NewCmdRemove returns an instance of 'remove' subcommand.
|
||||
func NewCmdRemove(
|
||||
fsys fs.FileSystem,
|
||||
fSys filesys.FileSystem,
|
||||
ldr ifc.Loader) *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "remove",
|
||||
@@ -34,10 +34,10 @@ func NewCmdRemove(
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
}
|
||||
c.AddCommand(
|
||||
newCmdRemoveResource(fsys),
|
||||
newCmdRemoveLabel(fsys, ldr.Validator().MakeLabelNameValidator()),
|
||||
newCmdRemoveAnnotation(fsys, ldr.Validator().MakeAnnotationNameValidator()),
|
||||
newCmdRemovePatch(fsys),
|
||||
newCmdRemoveResource(fSys),
|
||||
newCmdRemoveLabel(fSys, ldr.Validator().MakeLabelNameValidator()),
|
||||
newCmdRemoveAnnotation(fSys, ldr.Validator().MakeAnnotationNameValidator()),
|
||||
newCmdRemovePatch(fSys),
|
||||
)
|
||||
return c
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
)
|
||||
@@ -41,7 +41,7 @@ type removeMetadataOptions struct {
|
||||
}
|
||||
|
||||
// newCmdRemoveLabel removes one or more commonAnnotations from the kustomization file.
|
||||
func newCmdRemoveAnnotation(fSys fs.FileSystem, v func([]string) error) *cobra.Command {
|
||||
func newCmdRemoveAnnotation(fSys filesys.FileSystem, v func([]string) error) *cobra.Command {
|
||||
var o removeMetadataOptions
|
||||
o.kind = label
|
||||
o.arrayValidator = v
|
||||
@@ -62,7 +62,7 @@ func newCmdRemoveAnnotation(fSys fs.FileSystem, v func([]string) error) *cobra.C
|
||||
}
|
||||
|
||||
// newCmdRemoveLabel removes one or more commonLabels from the kustomization file.
|
||||
func newCmdRemoveLabel(fSys fs.FileSystem, v func([]string) error) *cobra.Command {
|
||||
func newCmdRemoveLabel(fSys filesys.FileSystem, v func([]string) error) *cobra.Command {
|
||||
var o removeMetadataOptions
|
||||
o.kind = label
|
||||
o.arrayValidator = v
|
||||
@@ -83,7 +83,7 @@ func newCmdRemoveLabel(fSys fs.FileSystem, v func([]string) error) *cobra.Comman
|
||||
}
|
||||
|
||||
func (o *removeMetadataOptions) runE(
|
||||
args []string, fSys fs.FileSystem, remover func(*types.Kustomization) error) error {
|
||||
args []string, fSys filesys.FileSystem, remover func(*types.Kustomization) error) error {
|
||||
err := o.validateAndParse(args)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -10,13 +10,13 @@ import (
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/validators"
|
||||
)
|
||||
|
||||
func makeKustomizationFS() fs.FileSystem {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
func makeKustomizationFS() filesys.FileSystem {
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
commonLabels := []string{"label1: val1", "label2: val2"}
|
||||
commonAnnotations := []string{"annotation1: val1", "annotation2: val2"}
|
||||
|
||||
@@ -26,7 +26,7 @@ func makeKustomizationFS() fs.FileSystem {
|
||||
return fSys
|
||||
}
|
||||
|
||||
func readKustomizationFS(t *testing.T, fSys fs.FileSystem) *types.Kustomization {
|
||||
func readKustomizationFS(t *testing.T, fSys filesys.FileSystem) *types.Kustomization {
|
||||
kf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected new error %v", err)
|
||||
@@ -86,7 +86,7 @@ func TestRemoveAnnotationIgnore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveAnnotationNoDefinition(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(""))
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
@@ -104,7 +104,7 @@ func TestRemoveAnnotationNoDefinition(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveAnnotationNoDefinitionIgnore(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(""))
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
@@ -234,7 +234,7 @@ func TestRemoveLabelIgnore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLabelNoDefinition(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(""))
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
@@ -252,7 +252,7 @@ func TestRemoveLabelNoDefinition(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLabelNoDefinitionIgnore(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(""))
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/patch"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
)
|
||||
@@ -20,7 +20,7 @@ type removePatchOptions struct {
|
||||
}
|
||||
|
||||
// newCmdRemovePatch removes the name of a file containing a patch from the kustomization file.
|
||||
func newCmdRemovePatch(fsys fs.FileSystem) *cobra.Command {
|
||||
func newCmdRemovePatch(fSys filesys.FileSystem) *cobra.Command {
|
||||
var o removePatchOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -38,7 +38,7 @@ func newCmdRemovePatch(fsys fs.FileSystem) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunRemovePatch(fsys)
|
||||
return o.RunRemovePatch(fSys)
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
@@ -59,7 +59,7 @@ func (o *removePatchOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// RunRemovePatch runs removePatch command (do real work).
|
||||
func (o *removePatchOptions) RunRemovePatch(fSys fs.FileSystem) error {
|
||||
func (o *removePatchOptions) RunRemovePatch(fSys filesys.FileSystem) error {
|
||||
patches, err := util.GlobPatterns(fSys, o.patchFilePaths)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/patch"
|
||||
)
|
||||
|
||||
@@ -20,8 +20,8 @@ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
`
|
||||
)
|
||||
|
||||
func makeKustomizationPatchFS() fs.FileSystem {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
func makeKustomizationPatchFS() filesys.FileSystem {
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
patches := []string{"patch1.yaml", "patch2.yaml"}
|
||||
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ type removeResourceOptions struct {
|
||||
}
|
||||
|
||||
// newCmdRemoveResource remove the name of a file containing a resource to the kustomization file.
|
||||
func newCmdRemoveResource(fsys fs.FileSystem) *cobra.Command {
|
||||
func newCmdRemoveResource(fSys filesys.FileSystem) *cobra.Command {
|
||||
var o removeResourceOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -39,7 +39,7 @@ func newCmdRemoveResource(fsys fs.FileSystem) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunRemoveResource(fsys)
|
||||
return o.RunRemoveResource(fSys)
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
@@ -60,7 +60,7 @@ func (o *removeResourceOptions) Complete(cmd *cobra.Command, args []string) erro
|
||||
}
|
||||
|
||||
// RunRemoveResource runs Resource command (do real work).
|
||||
func (o *removeResourceOptions) RunRemoveResource(fSys fs.FileSystem) error {
|
||||
func (o *removeResourceOptions) RunRemoveResource(fSys filesys.FileSystem) error {
|
||||
|
||||
mf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
func TestRemoveResources(t *testing.T) {
|
||||
@@ -125,7 +125,7 @@ func TestRemoveResources(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(
|
||||
fSys,
|
||||
[]byte(fmt.Sprintf(
|
||||
|
||||
@@ -5,12 +5,12 @@ package set
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
)
|
||||
|
||||
// NewCmdSet returns an instance of 'set' subcommand.
|
||||
func NewCmdSet(fsys fs.FileSystem, v ifc.Validator) *cobra.Command {
|
||||
func NewCmdSet(fSys filesys.FileSystem, v ifc.Validator) *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "set",
|
||||
Short: "Sets the value of different fields in kustomization file.",
|
||||
@@ -26,10 +26,10 @@ func NewCmdSet(fsys fs.FileSystem, v ifc.Validator) *cobra.Command {
|
||||
}
|
||||
|
||||
c.AddCommand(
|
||||
newCmdSetNamePrefix(fsys),
|
||||
newCmdSetNameSuffix(fsys),
|
||||
newCmdSetNamespace(fsys, v),
|
||||
newCmdSetImage(fsys),
|
||||
newCmdSetNamePrefix(fSys),
|
||||
newCmdSetNameSuffix(fSys),
|
||||
newCmdSetNamespace(fSys, v),
|
||||
newCmdSetImage(fSys),
|
||||
)
|
||||
return c
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
type setNamePrefixOptions struct {
|
||||
@@ -16,7 +16,7 @@ type setNamePrefixOptions struct {
|
||||
}
|
||||
|
||||
// newCmdSetNamePrefix sets the value of the namePrefix field in the kustomization.
|
||||
func newCmdSetNamePrefix(fsys fs.FileSystem) *cobra.Command {
|
||||
func newCmdSetNamePrefix(fSys filesys.FileSystem) *cobra.Command {
|
||||
var o setNamePrefixOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -37,7 +37,7 @@ and overwrite the value with "acme-" if the field does exist.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunSetNamePrefix(fsys)
|
||||
return o.RunSetNamePrefix(fSys)
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
@@ -59,7 +59,7 @@ func (o *setNamePrefixOptions) Complete(cmd *cobra.Command, args []string) error
|
||||
}
|
||||
|
||||
// RunSetNamePrefix runs setNamePrefix command (does real work).
|
||||
func (o *setNamePrefixOptions) RunSetNamePrefix(fSys fs.FileSystem) error {
|
||||
func (o *setNamePrefixOptions) RunSetNamePrefix(fSys filesys.FileSystem) error {
|
||||
mf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -16,7 +16,7 @@ const (
|
||||
)
|
||||
|
||||
func TestSetNamePrefixHappyPath(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdSetNamePrefix(fSys)
|
||||
@@ -35,7 +35,7 @@ func TestSetNamePrefixHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetNamePrefixNoArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdSetNamePrefix(fSys)
|
||||
err := cmd.Execute()
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
type setNameSuffixOptions struct {
|
||||
@@ -16,7 +16,7 @@ type setNameSuffixOptions struct {
|
||||
}
|
||||
|
||||
// newCmdSetNameSuffix sets the value of the nameSuffix field in the kustomization.
|
||||
func newCmdSetNameSuffix(fsys fs.FileSystem) *cobra.Command {
|
||||
func newCmdSetNameSuffix(fSys filesys.FileSystem) *cobra.Command {
|
||||
var o setNameSuffixOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -37,7 +37,7 @@ and overwrite the value with "-acme" if the field does exist.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunSetNameSuffix(fsys)
|
||||
return o.RunSetNameSuffix(fSys)
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
@@ -59,7 +59,7 @@ func (o *setNameSuffixOptions) Complete(cmd *cobra.Command, args []string) error
|
||||
}
|
||||
|
||||
// RunSetNameSuffix runs setNameSuffix command (does real work).
|
||||
func (o *setNameSuffixOptions) RunSetNameSuffix(fSys fs.FileSystem) error {
|
||||
func (o *setNameSuffixOptions) RunSetNameSuffix(fSys filesys.FileSystem) error {
|
||||
mf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -16,7 +16,7 @@ const (
|
||||
)
|
||||
|
||||
func TestSetNameSuffixHappyPath(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdSetNameSuffix(fSys)
|
||||
@@ -35,7 +35,7 @@ func TestSetNameSuffixHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetNameSuffixNoArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
cmd := newCmdSetNameSuffix(fSys)
|
||||
err := cmd.Execute()
|
||||
if err == nil {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/image"
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ var (
|
||||
const separator = "="
|
||||
|
||||
// newCmdSetImage sets the new names, tags or digests for images in the kustomization.
|
||||
func newCmdSetImage(fsys fs.FileSystem) *cobra.Command {
|
||||
func newCmdSetImage(fSys filesys.FileSystem) *cobra.Command {
|
||||
var o setImageOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -78,7 +78,7 @@ and overwrite the previous ones if the image name exists.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunSetImage(fsys)
|
||||
return o.RunSetImage(fSys)
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
@@ -110,7 +110,7 @@ func (o *setImageOptions) Validate(args []string) error {
|
||||
}
|
||||
|
||||
// RunSetImage runs setImage command.
|
||||
func (o *setImageOptions) RunSetImage(fSys fs.FileSystem) error {
|
||||
func (o *setImageOptions) RunSetImage(fSys filesys.FileSystem) error {
|
||||
mf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
func TestSetImage(t *testing.T) {
|
||||
@@ -190,7 +190,7 @@ func TestSetImage(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(fmt.Sprintf("%s%v", tc.description, tc.given.args), func(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
cmd := newCmdSetImage(fSys)
|
||||
|
||||
if len(tc.given.infileImages) > 0 {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
)
|
||||
|
||||
@@ -20,7 +20,7 @@ type setNamespaceOptions struct {
|
||||
}
|
||||
|
||||
// newCmdSetNamespace sets the value of the namespace field in the kustomization.
|
||||
func newCmdSetNamespace(fsys fs.FileSystem, v ifc.Validator) *cobra.Command {
|
||||
func newCmdSetNamespace(fSys filesys.FileSystem, v ifc.Validator) *cobra.Command {
|
||||
var o setNamespaceOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -38,7 +38,7 @@ and overwrite the value with "staging" if the field does exist.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunSetNamespace(fsys)
|
||||
return o.RunSetNamespace(fSys)
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
@@ -58,7 +58,7 @@ func (o *setNamespaceOptions) Validate(args []string) error {
|
||||
}
|
||||
|
||||
// RunSetNamespace runs setNamespace command (does real work).
|
||||
func (o *setNamespaceOptions) RunSetNamespace(fSys fs.FileSystem) error {
|
||||
func (o *setNamespaceOptions) RunSetNamespace(fSys filesys.FileSystem) error {
|
||||
mf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/validators"
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ const (
|
||||
)
|
||||
|
||||
func TestSetNamespaceHappyPath(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
|
||||
@@ -38,7 +38,7 @@ func TestSetNamespaceHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetNamespaceOverride(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
|
||||
@@ -63,7 +63,7 @@ func TestSetNamespaceOverride(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetNamespaceNoArgs(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
|
||||
err := cmd.Execute()
|
||||
@@ -76,7 +76,7 @@ func TestSetNamespaceNoArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetNamespaceInvalid(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
|
||||
args := []string{"/badnamespace/"}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
"sigs.k8s.io/yaml"
|
||||
@@ -102,12 +102,12 @@ func squash(x [][]byte) []byte {
|
||||
|
||||
type kustomizationFile struct {
|
||||
path string
|
||||
fSys fs.FileSystem
|
||||
fSys filesys.FileSystem
|
||||
originalFields []*commentedField
|
||||
}
|
||||
|
||||
// NewKustomizationFile returns a new instance.
|
||||
func NewKustomizationFile(fSys fs.FileSystem) (*kustomizationFile, error) { // nolint
|
||||
func NewKustomizationFile(fSys filesys.FileSystem) (*kustomizationFile, error) { // nolint
|
||||
mf := &kustomizationFile{fSys: fSys}
|
||||
err := mf.validate()
|
||||
if err != nil {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
)
|
||||
@@ -57,7 +57,7 @@ func TestWriteAndRead(t *testing.T) {
|
||||
NamePrefix: "prefix",
|
||||
}
|
||||
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
mf, err := NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
@@ -79,7 +79,7 @@ func TestWriteAndRead(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewNotExist(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
_, err := NewKustomizationFile(fSys)
|
||||
if err == nil {
|
||||
t.Fatalf("expect an error")
|
||||
@@ -106,7 +106,7 @@ configMapGenerator:
|
||||
name: my-configmap
|
||||
`
|
||||
for _, n := range pgmconfig.RecognizedKustomizationFileNames() {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.WriteFile(n, []byte(kcontent))
|
||||
k, err := NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
@@ -143,7 +143,7 @@ patchesStrategicMerge:
|
||||
- service.yaml
|
||||
- pod.yaml
|
||||
`)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, kustomizationContentWithComments)
|
||||
mf, err := NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
@@ -235,7 +235,7 @@ patchesStrategicMerge:
|
||||
generatorOptions:
|
||||
disableNameSuffixHash: true
|
||||
`)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(
|
||||
fSys, kustomizationContentWithComments)
|
||||
mf, err := NewKustomizationFile(fSys)
|
||||
@@ -273,7 +273,7 @@ patchesStrategicMerge:
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
`)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(
|
||||
fSys, kustomizationContentWithComments)
|
||||
mf, err := NewKustomizationFile(fSys)
|
||||
@@ -319,7 +319,7 @@ patches:
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
`)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, kustomizationContentWithComments)
|
||||
mf, err := NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
package testutils
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
)
|
||||
|
||||
@@ -32,16 +32,16 @@ secretGenerator: []
|
||||
)
|
||||
|
||||
// WriteTestKustomization writes a standard test file.
|
||||
func WriteTestKustomization(fSys fs.FileSystem) {
|
||||
func WriteTestKustomization(fSys filesys.FileSystem) {
|
||||
WriteTestKustomizationWith(fSys, []byte(kustomizationContent))
|
||||
}
|
||||
|
||||
// WriteTestKustomizationWith writes content to a well known file name.
|
||||
func WriteTestKustomizationWith(fSys fs.FileSystem, bytes []byte) {
|
||||
func WriteTestKustomizationWith(fSys filesys.FileSystem, bytes []byte) {
|
||||
fSys.WriteFile(pgmconfig.DefaultKustomizationFileName(), bytes)
|
||||
}
|
||||
|
||||
// ReadTestKustomization reads content from a well known file name.
|
||||
func ReadTestKustomization(fSys fs.FileSystem) ([]byte, error) {
|
||||
func ReadTestKustomization(fSys filesys.FileSystem) ([]byte, error) {
|
||||
return fSys.ReadFile(pgmconfig.DefaultKustomizationFileName())
|
||||
}
|
||||
|
||||
@@ -8,15 +8,15 @@ import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
// GlobPatterns accepts a slice of glob strings and returns the set of
|
||||
// matching file paths.
|
||||
func GlobPatterns(fsys fs.FileSystem, patterns []string) ([]string, error) {
|
||||
func GlobPatterns(fSys filesys.FileSystem, patterns []string) ([]string, error) {
|
||||
var result []string
|
||||
for _, pattern := range patterns {
|
||||
files, err := fsys.Glob(pattern)
|
||||
files, err := fSys.Glob(pattern)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
package filesys
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
package filesys
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
package filesys
|
||||
|
||||
import (
|
||||
"os"
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
package filesys
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
package filesys
|
||||
|
||||
import (
|
||||
"os"
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package fs provides a file system abstraction layer.
|
||||
package fs
|
||||
// Package filesys provides a file system abstraction layer.
|
||||
package filesys
|
||||
|
||||
import (
|
||||
"io"
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
package filesys
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
package filesys
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
package filesys
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
package filesys
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
package filesys
|
||||
|
||||
import "path/filepath"
|
||||
|
||||
@@ -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 git
|
||||
|
||||
@@ -22,7 +9,7 @@ import (
|
||||
"os/exec"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
// Cloner is a function that can clone a git repo.
|
||||
@@ -36,7 +23,7 @@ func ClonerUsingGitExec(repoSpec *RepoSpec) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "no 'git' program on path")
|
||||
}
|
||||
repoSpec.Dir, err = fs.NewTmpConfirmedDir()
|
||||
repoSpec.Dir, err = filesys.NewTmpConfirmedDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -126,7 +113,7 @@ func ClonerUsingGitExec(repoSpec *RepoSpec) error {
|
||||
// cloneDir field in the repoSpec. It's assumed that
|
||||
// the cloneDir is associated with some fake filesystem
|
||||
// used in a test.
|
||||
func DoNothingCloner(dir fs.ConfirmedDir) Cloner {
|
||||
func DoNothingCloner(dir filesys.ConfirmedDir) Cloner {
|
||||
return func(rs *RepoSpec) error {
|
||||
rs.Dir = dir
|
||||
return nil
|
||||
|
||||
@@ -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 git
|
||||
|
||||
@@ -22,7 +9,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
// Used as a temporary non-empty occupant of the cloneDir
|
||||
@@ -30,7 +17,7 @@ import (
|
||||
// in various outputs (especially tests). Not using an
|
||||
// actual directory name here, as that's a temporary directory
|
||||
// with a unique name that isn't created until clone time.
|
||||
const notCloned = fs.ConfirmedDir("/notCloned")
|
||||
const notCloned = filesys.ConfirmedDir("/notCloned")
|
||||
|
||||
// RepoSpec specifies a git repository and a branch and path therein.
|
||||
type RepoSpec struct {
|
||||
@@ -46,7 +33,7 @@ type RepoSpec struct {
|
||||
OrgRepo string
|
||||
|
||||
// Dir where the orgRepo is cloned to.
|
||||
Dir fs.ConfirmedDir
|
||||
Dir filesys.ConfirmedDir
|
||||
|
||||
// Relative path in the repository, and in the cloneDir,
|
||||
// to a Kustomization.
|
||||
@@ -67,7 +54,7 @@ func (x *RepoSpec) CloneSpec() string {
|
||||
return x.Host + x.OrgRepo + x.GitSuffix
|
||||
}
|
||||
|
||||
func (x *RepoSpec) CloneDir() fs.ConfirmedDir {
|
||||
func (x *RepoSpec) CloneDir() filesys.ConfirmedDir {
|
||||
return x.Dir
|
||||
}
|
||||
|
||||
@@ -79,7 +66,7 @@ func (x *RepoSpec) AbsPath() string {
|
||||
return x.Dir.Join(x.Path)
|
||||
}
|
||||
|
||||
func (x *RepoSpec) Cleaner(fSys fs.FileSystem) func() error {
|
||||
func (x *RepoSpec) Cleaner(fSys filesys.FileSystem) func() error {
|
||||
return func() error { return fSys.RemoveAll(x.Dir.String()) }
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/git"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
)
|
||||
@@ -74,7 +74,7 @@ type fileLoader struct {
|
||||
// An absolute, cleaned path to a directory.
|
||||
// The Load function will read non-absolute
|
||||
// paths relative to this directory.
|
||||
root fs.ConfirmedDir
|
||||
root filesys.ConfirmedDir
|
||||
|
||||
// Restricts behavior of Load function.
|
||||
loadRestrictor LoadRestrictorFunc
|
||||
@@ -87,7 +87,7 @@ type fileLoader struct {
|
||||
repoSpec *git.RepoSpec
|
||||
|
||||
// File system utilities.
|
||||
fSys fs.FileSystem
|
||||
fSys filesys.FileSystem
|
||||
|
||||
// Used to clone repositories.
|
||||
cloner git.Cloner
|
||||
@@ -100,14 +100,14 @@ const CWD = "."
|
||||
|
||||
// NewFileLoaderAtCwd returns a loader that loads from ".".
|
||||
// A convenience for kustomize edit commands.
|
||||
func NewFileLoaderAtCwd(v ifc.Validator, fSys fs.FileSystem) *fileLoader {
|
||||
func NewFileLoaderAtCwd(v ifc.Validator, fSys filesys.FileSystem) *fileLoader {
|
||||
return newLoaderOrDie(
|
||||
RestrictionRootOnly, v, fSys, CWD)
|
||||
}
|
||||
|
||||
// NewFileLoaderAtRoot returns a loader that loads from "/".
|
||||
// A convenience for tests.
|
||||
func NewFileLoaderAtRoot(v ifc.Validator, fSys fs.FileSystem) *fileLoader {
|
||||
func NewFileLoaderAtRoot(v ifc.Validator, fSys filesys.FileSystem) *fileLoader {
|
||||
return newLoaderOrDie(
|
||||
RestrictionRootOnly, v, fSys, string(filepath.Separator))
|
||||
}
|
||||
@@ -120,7 +120,7 @@ func (fl *fileLoader) Root() string {
|
||||
|
||||
func newLoaderOrDie(
|
||||
lr LoadRestrictorFunc, v ifc.Validator,
|
||||
fSys fs.FileSystem, path string) *fileLoader {
|
||||
fSys filesys.FileSystem, path string) *fileLoader {
|
||||
root, err := demandDirectoryRoot(fSys, path)
|
||||
if err != nil {
|
||||
log.Fatalf("unable to make loader at '%s'; %v", path, err)
|
||||
@@ -133,7 +133,7 @@ func newLoaderOrDie(
|
||||
func newLoaderAtConfirmedDir(
|
||||
lr LoadRestrictorFunc,
|
||||
v ifc.Validator,
|
||||
root fs.ConfirmedDir, fSys fs.FileSystem,
|
||||
root filesys.ConfirmedDir, fSys filesys.FileSystem,
|
||||
referrer *fileLoader, cloner git.Cloner) *fileLoader {
|
||||
return &fileLoader{
|
||||
loadRestrictor: lr,
|
||||
@@ -148,7 +148,7 @@ func newLoaderAtConfirmedDir(
|
||||
|
||||
// Assure that the given path is in fact a directory.
|
||||
func demandDirectoryRoot(
|
||||
fSys fs.FileSystem, path string) (fs.ConfirmedDir, error) {
|
||||
fSys filesys.FileSystem, path string) (filesys.ConfirmedDir, error) {
|
||||
if path == "" {
|
||||
return "", fmt.Errorf(
|
||||
"loader root cannot be empty")
|
||||
@@ -202,7 +202,7 @@ func (fl *fileLoader) New(path string) (ifc.Loader, error) {
|
||||
// directory holding a cloned git repo.
|
||||
func newLoaderAtGitClone(
|
||||
repoSpec *git.RepoSpec,
|
||||
v ifc.Validator, fSys fs.FileSystem,
|
||||
v ifc.Validator, fSys filesys.FileSystem,
|
||||
referrer *fileLoader, cloner git.Cloner) (ifc.Loader, error) {
|
||||
cleaner := repoSpec.Cleaner(fSys)
|
||||
err := cloner(repoSpec)
|
||||
@@ -239,7 +239,7 @@ func newLoaderAtGitClone(
|
||||
}
|
||||
|
||||
func (fl *fileLoader) errIfGitContainmentViolation(
|
||||
base fs.ConfirmedDir) error {
|
||||
base filesys.ConfirmedDir) error {
|
||||
containingRepo := fl.containingRepo()
|
||||
if containingRepo == nil {
|
||||
return nil
|
||||
@@ -269,7 +269,7 @@ func (fl *fileLoader) containingRepo() *git.RepoSpec {
|
||||
// errIfArgEqualOrHigher tests whether the argument,
|
||||
// is equal to or above the root of any ancestor.
|
||||
func (fl *fileLoader) errIfArgEqualOrHigher(
|
||||
candidateRoot fs.ConfirmedDir) error {
|
||||
candidateRoot filesys.ConfirmedDir) error {
|
||||
if fl.root.HasPrefix(candidateRoot) {
|
||||
return fmt.Errorf(
|
||||
"cycle detected: candidate root '%s' contains visited root '%s'",
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/git"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
@@ -56,8 +56,8 @@ var testCases = []testData{
|
||||
},
|
||||
}
|
||||
|
||||
func MakeFakeFs(td []testData) fs.FileSystem {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
func MakeFakeFs(td []testData) filesys.FileSystem {
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
for _, x := range td {
|
||||
fSys.WriteFile("/"+x.path, []byte(x.expectedContent))
|
||||
}
|
||||
@@ -225,12 +225,12 @@ const (
|
||||
// │ └── symLinkToExteriorData -> ../exteriorData
|
||||
// └── exteriorData
|
||||
//
|
||||
func commonSetupForLoaderRestrictionTest() (string, fs.FileSystem, error) {
|
||||
func commonSetupForLoaderRestrictionTest() (string, filesys.FileSystem, error) {
|
||||
dir, err := ioutil.TempDir("", "kustomize-test-")
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
fSys := fs.MakeFsOnDisk()
|
||||
fSys := filesys.MakeFsOnDisk()
|
||||
fSys.Mkdir(filepath.Join(dir, "base"))
|
||||
|
||||
fSys.WriteFile(
|
||||
@@ -385,7 +385,7 @@ func TestNewLoaderAtGitClone(t *testing.T) {
|
||||
pathInRepo := "foo/base"
|
||||
url := rootUrl + "/" + pathInRepo
|
||||
coRoot := "/tmp"
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.MkdirAll(coRoot)
|
||||
fSys.MkdirAll(coRoot + "/" + pathInRepo)
|
||||
fSys.WriteFile(
|
||||
@@ -401,7 +401,7 @@ whatever
|
||||
}
|
||||
l, err := newLoaderAtGitClone(
|
||||
repoSpec, validators.MakeFakeValidator(), fSys, nil,
|
||||
git.DoNothingCloner(fs.ConfirmedDir(coRoot)))
|
||||
git.DoNothingCloner(filesys.ConfirmedDir(coRoot)))
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v\n", err)
|
||||
}
|
||||
@@ -433,7 +433,7 @@ func TestLoaderDisallowsLocalBaseFromRemoteOverlay(t *testing.T) {
|
||||
// Define an overlay-base structure in the file system.
|
||||
topDir := "/whatever"
|
||||
cloneRoot := topDir + "/someClone"
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.MkdirAll(topDir + "/highBase")
|
||||
fSys.MkdirAll(cloneRoot + "/foo/base")
|
||||
fSys.MkdirAll(cloneRoot + "/foo/overlay")
|
||||
@@ -480,7 +480,7 @@ func TestLoaderDisallowsLocalBaseFromRemoteOverlay(t *testing.T) {
|
||||
}
|
||||
l1, err = newLoaderAtGitClone(
|
||||
repoSpec, validators.MakeFakeValidator(), fSys, nil,
|
||||
git.DoNothingCloner(fs.ConfirmedDir(cloneRoot)))
|
||||
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v\n", err)
|
||||
}
|
||||
@@ -509,7 +509,7 @@ func TestLoaderDisallowsLocalBaseFromRemoteOverlay(t *testing.T) {
|
||||
func TestLocalLoaderReferencingGitBase(t *testing.T) {
|
||||
topDir := "/whatever"
|
||||
cloneRoot := topDir + "/someClone"
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.MkdirAll(topDir)
|
||||
fSys.MkdirAll(cloneRoot + "/foo/base")
|
||||
|
||||
@@ -519,7 +519,7 @@ func TestLocalLoaderReferencingGitBase(t *testing.T) {
|
||||
}
|
||||
l1 := newLoaderAtConfirmedDir(
|
||||
RestrictionRootOnly, validators.MakeFakeValidator(), root, fSys, nil,
|
||||
git.DoNothingCloner(fs.ConfirmedDir(cloneRoot)))
|
||||
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
|
||||
if l1.Root() != topDir {
|
||||
t.Fatalf("unexpected root %s", l1.Root())
|
||||
}
|
||||
@@ -535,7 +535,7 @@ func TestLocalLoaderReferencingGitBase(t *testing.T) {
|
||||
func TestRepoDirectCycleDetection(t *testing.T) {
|
||||
topDir := "/cycles"
|
||||
cloneRoot := topDir + "/someClone"
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.MkdirAll(topDir)
|
||||
fSys.MkdirAll(cloneRoot)
|
||||
|
||||
@@ -545,7 +545,7 @@ func TestRepoDirectCycleDetection(t *testing.T) {
|
||||
}
|
||||
l1 := newLoaderAtConfirmedDir(
|
||||
RestrictionRootOnly, validators.MakeFakeValidator(), root, fSys, nil,
|
||||
git.DoNothingCloner(fs.ConfirmedDir(cloneRoot)))
|
||||
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
|
||||
p1 := "github.com/someOrg/someRepo/foo"
|
||||
rs1, err := git.NewRepoSpecFromUrl(p1)
|
||||
if err != nil {
|
||||
@@ -564,7 +564,7 @@ func TestRepoDirectCycleDetection(t *testing.T) {
|
||||
func TestRepoIndirectCycleDetection(t *testing.T) {
|
||||
topDir := "/cycles"
|
||||
cloneRoot := topDir + "/someClone"
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.MkdirAll(topDir)
|
||||
fSys.MkdirAll(cloneRoot)
|
||||
|
||||
@@ -574,7 +574,7 @@ func TestRepoIndirectCycleDetection(t *testing.T) {
|
||||
}
|
||||
l0 := newLoaderAtConfirmedDir(
|
||||
RestrictionRootOnly, validators.MakeFakeValidator(), root, fSys, nil,
|
||||
git.DoNothingCloner(fs.ConfirmedDir(cloneRoot)))
|
||||
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
|
||||
|
||||
p1 := "github.com/someOrg/someRepo1"
|
||||
p2 := "github.com/someOrg/someRepo2"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/validators"
|
||||
)
|
||||
@@ -46,7 +46,7 @@ func TestKeyValuesFromLines(t *testing.T) {
|
||||
}
|
||||
|
||||
l := NewFileLoaderAtRoot(
|
||||
validators.MakeFakeValidator(), fs.MakeFsInMemory())
|
||||
validators.MakeFakeValidator(), filesys.MakeFsInMemory())
|
||||
for _, test := range tests {
|
||||
pairs, err := l.keyValuesFromLines([]byte(test.content))
|
||||
if test.expectedErr && err == nil {
|
||||
@@ -76,7 +76,7 @@ func TestKeyValuesFromFileSources(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.WriteFile("/files/app-init.ini", []byte("FOO=bar"))
|
||||
l := NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys)
|
||||
for _, tc := range tests {
|
||||
|
||||
@@ -1,24 +1,11 @@
|
||||
/*
|
||||
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 loader has a data loading interface and various implementations.
|
||||
package loader
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/git"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
)
|
||||
@@ -32,7 +19,7 @@ import (
|
||||
func NewLoader(
|
||||
lr LoadRestrictorFunc,
|
||||
v ifc.Validator,
|
||||
target string, fSys fs.FileSystem) (ifc.Loader, error) {
|
||||
target string, fSys filesys.FileSystem) (ifc.Loader, error) {
|
||||
repoSpec, err := git.NewRepoSpecFromUrl(target)
|
||||
if err == nil {
|
||||
// The target qualifies as a remote git target.
|
||||
|
||||
@@ -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 loader
|
||||
|
||||
@@ -20,7 +7,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
//go:generate stringer -type=loadRestrictions
|
||||
@@ -64,10 +51,10 @@ func ValidateFlagLoadRestrictor() (LoadRestrictorFunc, error) {
|
||||
}
|
||||
|
||||
type LoadRestrictorFunc func(
|
||||
fs.FileSystem, fs.ConfirmedDir, string) (string, error)
|
||||
filesys.FileSystem, filesys.ConfirmedDir, string) (string, error)
|
||||
|
||||
func RestrictionRootOnly(
|
||||
fSys fs.FileSystem, root fs.ConfirmedDir, path string) (string, error) {
|
||||
fSys filesys.FileSystem, root filesys.ConfirmedDir, path string) (string, error) {
|
||||
d, f, err := fSys.CleanedAbs(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -84,6 +71,6 @@ func RestrictionRootOnly(
|
||||
}
|
||||
|
||||
func RestrictionNone(
|
||||
_ fs.FileSystem, _ fs.ConfirmedDir, path string) (string, error) {
|
||||
_ filesys.FileSystem, _ filesys.ConfirmedDir, path string) (string, error) {
|
||||
return path, nil
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
)
|
||||
|
||||
func TestRestrictionNone(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
root := fs.ConfirmedDir("irrelevant")
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
root := filesys.ConfirmedDir("irrelevant")
|
||||
path := "whatever"
|
||||
p, err := RestrictionNone(fSys, root, path)
|
||||
if err != nil {
|
||||
@@ -37,8 +37,8 @@ func TestRestrictionNone(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRestrictionRootOnly(t *testing.T) {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
root := fs.ConfirmedDir("/tmp/foo")
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
root := filesys.ConfirmedDir("/tmp/foo")
|
||||
|
||||
path := "/tmp/foo/whatever/beans"
|
||||
p, err := RestrictionRootOnly(fSys, root, path)
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/internal/loadertest"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/gvk"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/loader"
|
||||
@@ -234,7 +234,7 @@ func TestNewResMapFromSecretArgs(t *testing.T) {
|
||||
Type: ifc.SecretTypeOpaque,
|
||||
},
|
||||
}
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
fSys.Mkdir(".")
|
||||
actual, err := rmF.NewResMapFromSecretArgs(
|
||||
loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys), nil, secrets)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/v3/k8sdeps/transformer"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/filesys"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/loader"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins"
|
||||
@@ -39,7 +39,7 @@ func TestPluginDir(t *testing.T) {
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
fSys := fs.MakeFsOnDisk()
|
||||
fSys := filesys.MakeFsOnDisk()
|
||||
err = fSys.WriteFile(filepath.Join(dir, "kustomization.yaml"), []byte(`
|
||||
generators:
|
||||
- config.yaml
|
||||
|
||||
@@ -2,6 +2,15 @@ module sigs.k8s.io/kustomize/pluginator
|
||||
|
||||
go 1.13
|
||||
|
||||
require sigs.k8s.io/kustomize/v3 v3.3.0
|
||||
require (
|
||||
github.com/emicklei/go-restful v2.9.6+incompatible // indirect
|
||||
github.com/google/gofuzz v1.0.0 // indirect
|
||||
github.com/googleapis/gnostic v0.3.0 // indirect
|
||||
github.com/json-iterator/go v1.1.6 // indirect
|
||||
github.com/mailru/easyjson v0.0.0-20190620125010-da37f6c1e481 // indirect
|
||||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||
k8s.io/klog v0.3.3 // indirect
|
||||
sigs.k8s.io/kustomize/v3 v3.3.1
|
||||
)
|
||||
|
||||
replace sigs.k8s.io/kustomize/v3 v3.3.0 => ../
|
||||
replace sigs.k8s.io/kustomize/v3 v3.3.1 => ../
|
||||
|
||||
@@ -280,6 +280,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwL
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b h1:XfVGCX+0T4WOStkaOsJRllbsiImhB2jgVBGc9L0lPGc=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191011234655-491137f69257 h1:ry8e2D+cwaV6hk7lb3aRTjjZo24shrbK0e11QEOkTIg=
|
||||
golang.org/x/net v0.0.0-20191011234655-491137f69257/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -322,6 +324,7 @@ golang.org/x/tools v0.0.0-20190719005602-e377ae9d6386/go.mod h1:jcCCGcm9btYwXyDq
|
||||
golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911230505-6bfd74cf029c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190912215617-3720d1ec3678/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191014141550-5fa5b1782b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
@@ -365,6 +368,7 @@ mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jC
|
||||
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||
sigs.k8s.io/kustomize/pluginator v1.0.0/go.mod h1:i8HdU5FdH1zDjCKiFf5CNl7slsc0QffyKsY2OuPynJ0=
|
||||
sigs.k8s.io/kustomize/v3 v3.2.0/go.mod h1:ztX4zYc/QIww3gSripwF7TBOarBTm5BvyAMem0kCzOE=
|
||||
sigs.k8s.io/kustomize/v3 v3.3.1/go.mod h1:2ojB+51Z+YIBpEOknAFX3U8f0XXa94PFcfXPccDxAfg=
|
||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
||||
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
|
||||
Reference in New Issue
Block a user