Rename fs package to filesys

This commit is contained in:
Jeffrey Regan
2019-10-14 10:41:49 -07:00
parent c4eca908ac
commit 9e3b837093
74 changed files with 309 additions and 333 deletions

2
go.mod
View File

@@ -11,6 +11,8 @@ require (
github.com/monopole/mdrip v1.0.0 github.com/monopole/mdrip v1.0.0
github.com/pkg/errors v0.8.1 github.com/pkg/errors v0.8.1
github.com/spf13/pflag v1.0.5 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 gopkg.in/yaml.v2 v2.2.2
k8s.io/api v0.0.0-20190313235455-40a48860b5ab k8s.io/api v0.0.0-20190313235455-40a48860b5ab
k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1 k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1

7
go.sum
View File

@@ -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-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 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-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/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-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-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-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/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-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/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-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 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-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= 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/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 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/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 h1:Cq7MalBHYACRd6EesksG1Q8EoIAKOsiZviGKbOLIej4=
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= 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 h1:aeLqD8CIaqr++49YrcuRUcXl5vVKYLhCSfwXUi3ifQ4=
sigs.k8s.io/kustomize/pluginator v1.0.0/go.mod h1:i8HdU5FdH1zDjCKiFf5CNl7slsc0QffyKsY2OuPynJ0= 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.2.0/go.mod h1:ztX4zYc/QIww3gSripwF7TBOarBTm5BvyAMem0kCzOE=

View File

@@ -7,7 +7,7 @@ package loadertest
import ( import (
"log" "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/ifc"
"sigs.k8s.io/kustomize/v3/pkg/loader" "sigs.k8s.io/kustomize/v3/pkg/loader"
"sigs.k8s.io/kustomize/v3/pkg/types" "sigs.k8s.io/kustomize/v3/pkg/types"
@@ -16,7 +16,7 @@ import (
// FakeLoader encapsulates the delegate Loader and the fake file system. // FakeLoader encapsulates the delegate Loader and the fake file system.
type FakeLoader struct { type FakeLoader struct {
fs fs.FileSystem fs filesys.FileSystem
delegate ifc.Loader delegate ifc.Loader
} }
@@ -34,7 +34,7 @@ func NewFakeLoader(initialDir string) FakeLoader {
func NewFakeLoaderWithRestrictor( func NewFakeLoaderWithRestrictor(
lr loader.LoadRestrictorFunc, initialDir string) FakeLoader { lr loader.LoadRestrictorFunc, initialDir string) FakeLoader {
// Create fake filesystem and inject it into initial Loader. // Create fake filesystem and inject it into initial Loader.
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.Mkdir(initialDir) fSys.Mkdir(initialDir)
ldr, err := loader.NewLoader( ldr, err := loader.NewLoader(
lr, validators.MakeFakeValidator(), initialDir, fSys) lr, validators.MakeFakeValidator(), initialDir, fSys)

View File

@@ -10,7 +10,7 @@ import (
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/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/loader"
"sigs.k8s.io/kustomize/v3/pkg/types" "sigs.k8s.io/kustomize/v3/pkg/types"
"sigs.k8s.io/kustomize/v3/pkg/validators" "sigs.k8s.io/kustomize/v3/pkg/validators"
@@ -131,15 +131,15 @@ func TestConstructConfigMap(t *testing.T) {
}, },
} }
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.WriteFile( fSys.WriteFile(
fs.RPath("configmap", "app.env"), filesys.RPath("configmap", "app.env"),
[]byte("DB_USERNAME=admin\nDB_PASSWORD=somepw\n")) []byte("DB_USERNAME=admin\nDB_PASSWORD=somepw\n"))
fSys.WriteFile( fSys.WriteFile(
fs.RPath("configmap", "app-init.ini"), filesys.RPath("configmap", "app-init.ini"),
[]byte("FOO=bar\nBAR=baz\n")) []byte("FOO=bar\nBAR=baz\n"))
fSys.WriteFile( fSys.WriteFile(
fs.RPath("configmap", "app.bin"), filesys.RPath("configmap", "app.bin"),
[]byte{0xff, 0xfd}) []byte{0xff, 0xfd})
ldr := loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys) ldr := loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys)
for _, tc := range testCases { for _, tc := range testCases {

View File

@@ -9,7 +9,7 @@ import (
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/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/loader"
"sigs.k8s.io/kustomize/v3/pkg/types" "sigs.k8s.io/kustomize/v3/pkg/types"
"sigs.k8s.io/kustomize/v3/pkg/validators" "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.env", []byte("DB_USERNAME=admin\nDB_PASSWORD=somepw\n"))
fSys.WriteFile("/secret/app-init.ini", []byte("FOO=bar\nBAR=baz\n")) fSys.WriteFile("/secret/app-init.ini", []byte("FOO=bar\nBAR=baz\n"))
ldr := loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys) ldr := loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys)

View File

@@ -6,8 +6,8 @@ require (
github.com/pkg/errors v0.8.1 github.com/pkg/errors v0.8.1
github.com/spf13/cobra v0.0.5 github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.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 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 => ../

View File

@@ -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-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 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-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/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-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-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-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-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-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= 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/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 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/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/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= 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/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.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/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 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=

View File

@@ -10,7 +10,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "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/ifc"
"sigs.k8s.io/kustomize/v3/pkg/loader" "sigs.k8s.io/kustomize/v3/pkg/loader"
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig" "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. // NewCmdBuild creates a new build command.
func NewCmdBuild( func NewCmdBuild(
out io.Writer, fSys fs.FileSystem, out io.Writer, fSys filesys.FileSystem,
v ifc.Validator, rf *resmap.Factory, v ifc.Validator, rf *resmap.Factory,
ptf resmap.PatchFactory) *cobra.Command { ptf resmap.PatchFactory) *cobra.Command {
var o Options var o Options
@@ -115,7 +115,7 @@ func (o *Options) Validate(args []string) (err error) {
// RunBuild runs build command. // RunBuild runs build command.
func (o *Options) RunBuild( 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, rf *resmap.Factory, ptf resmap.PatchFactory,
pl *plugins.Loader) error { pl *plugins.Loader) error {
ldr, err := loader.NewLoader( ldr, err := loader.NewLoader(
@@ -136,7 +136,7 @@ func (o *Options) RunBuild(
} }
func (o *Options) RunBuildPrune( 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, rf *resmap.Factory, ptf resmap.PatchFactory,
pl *plugins.Loader) error { pl *plugins.Loader) error {
ldr, err := loader.NewLoader( ldr, err := loader.NewLoader(
@@ -157,7 +157,7 @@ func (o *Options) RunBuildPrune(
} }
func (o *Options) emitResources( 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) { if o.outputPath != "" && fSys.IsDir(o.outputPath) {
return writeIndividualFiles(fSys, o.outputPath, m) return writeIndividualFiles(fSys, o.outputPath, m)
} }
@@ -180,7 +180,7 @@ func (o *Options) emitResources(
} }
func NewCmdBuildPrune( 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, rf *resmap.Factory, ptf resmap.PatchFactory,
pl *plugins.Loader) *cobra.Command { pl *plugins.Loader) *cobra.Command {
var o Options var o Options
@@ -202,7 +202,7 @@ func NewCmdBuildPrune(
} }
func writeIndividualFiles( func writeIndividualFiles(
fSys fs.FileSystem, folderPath string, m resmap.ResMap) error { fSys filesys.FileSystem, folderPath string, m resmap.ResMap) error {
byNamespace := m.GroupedByCurrentNamespace() byNamespace := m.GroupedByCurrentNamespace()
for namespace, resList := range byNamespace { for namespace, resList := range byNamespace {
for _, res := range resList { for _, res := range resList {
@@ -231,7 +231,7 @@ func fileName(res *resource.Resource) string {
} }
func writeFile( 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()) out, err := yaml.Marshal(res.Map())
if err != nil { if err != nil {
return err return err

View File

@@ -17,7 +17,7 @@ import (
"sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct" "sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct"
"sigs.k8s.io/kustomize/v3/k8sdeps/transformer" "sigs.k8s.io/kustomize/v3/k8sdeps/transformer"
"sigs.k8s.io/kustomize/v3/k8sdeps/validator" "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/pgmconfig"
"sigs.k8s.io/kustomize/v3/pkg/resmap" "sigs.k8s.io/kustomize/v3/pkg/resmap"
"sigs.k8s.io/kustomize/v3/pkg/resource" "sigs.k8s.io/kustomize/v3/pkg/resource"
@@ -25,7 +25,7 @@ import (
// NewDefaultCommand returns the default (aka root) command for kustomize command. // NewDefaultCommand returns the default (aka root) command for kustomize command.
func NewDefaultCommand() *cobra.Command { func NewDefaultCommand() *cobra.Command {
fSys := fs.MakeFsOnDisk() fSys := filesys.MakeFsOnDisk()
stdOut := os.Stdout stdOut := os.Stdout
c := &cobra.Command{ c := &cobra.Command{

View File

@@ -9,12 +9,12 @@ import (
"github.com/spf13/cobra" "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" "sigs.k8s.io/kustomize/v3/pkg/transformers/config/defaultconfig"
) )
// NewCmdConfig returns an instance of 'config' subcommand. // NewCmdConfig returns an instance of 'config' subcommand.
func NewCmdConfig(fsys fs.FileSystem) *cobra.Command { func NewCmdConfig(fSys filesys.FileSystem) *cobra.Command {
c := &cobra.Command{ c := &cobra.Command{
Use: "config", Use: "config",
Short: "Config Kustomize transformers", Short: "Config Kustomize transformers",
@@ -26,7 +26,7 @@ func NewCmdConfig(fsys fs.FileSystem) *cobra.Command {
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
} }
c.AddCommand( c.AddCommand(
newCmdSave(fsys), newCmdSave(fSys),
) )
return c return c
} }
@@ -35,7 +35,7 @@ type saveOptions struct {
saveDirectory string saveDirectory string
} }
func newCmdSave(fsys fs.FileSystem) *cobra.Command { func newCmdSave(fSys filesys.FileSystem) *cobra.Command {
var o saveOptions var o saveOptions
c := &cobra.Command{ c := &cobra.Command{
@@ -52,11 +52,11 @@ func newCmdSave(fsys fs.FileSystem) *cobra.Command {
if err != nil { if err != nil {
return err return err
} }
err = o.Complete(fsys) err = o.Complete(fSys)
if err != nil { if err != nil {
return err return err
} }
return o.RunSave(fsys) return o.RunSave(fSys)
}, },
} }
c.Flags().StringVarP( c.Flags().StringVarP(
@@ -77,22 +77,22 @@ func (o *saveOptions) Validate() error {
} }
// Complete creates the save directory when the directory doesn't exist // Complete creates the save directory when the directory doesn't exist
func (o *saveOptions) Complete(fsys fs.FileSystem) error { func (o *saveOptions) Complete(fSys filesys.FileSystem) error {
if !fsys.Exists(o.saveDirectory) { if !fSys.Exists(o.saveDirectory) {
return fsys.MkdirAll(o.saveDirectory) return fSys.MkdirAll(o.saveDirectory)
} }
if fsys.IsDir(o.saveDirectory) { if fSys.IsDir(o.saveDirectory) {
return nil return nil
} }
return fmt.Errorf("%s is not a directory", o.saveDirectory) return fmt.Errorf("%s is not a directory", o.saveDirectory)
} }
// RunSave saves the default transformer configurations local directory // 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() m := defaultconfig.GetDefaultFieldSpecsAsMap()
for tname, tcfg := range m { for tname, tcfg := range m {
filename := filepath.Join(o.saveDirectory, tname+".yaml") filename := filepath.Join(o.saveDirectory, tname+".yaml")
err := fsys.WriteFile(filename, []byte(tcfg)) err := fSys.WriteFile(filename, []byte(tcfg))
if err != nil { if err != nil {
return err return err
} }

View File

@@ -9,7 +9,7 @@ import (
"strings" "strings"
"testing" "testing"
"sigs.k8s.io/kustomize/v3/pkg/fs" "sigs.k8s.io/kustomize/v3/pkg/filesys"
) )
func TestValidate(t *testing.T) { func TestValidate(t *testing.T) {
@@ -29,7 +29,7 @@ func TestValidate(t *testing.T) {
} }
func TestComplete(t *testing.T) { func TestComplete(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.Mkdir("/some/dir") fSys.Mkdir("/some/dir")
fSys.WriteFile("/some/file", []byte(`some file`)) fSys.WriteFile("/some/file", []byte(`some file`))
@@ -62,7 +62,7 @@ func TestComplete(t *testing.T) {
} }
func TestRunSave(t *testing.T) { func TestRunSave(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
o := saveOptions{saveDirectory: "/some/dir"} o := saveOptions{saveDirectory: "/some/dir"}
err := o.RunSave(fSys) err := o.RunSave(fSys)
if err != nil { if err != nil {

View File

@@ -12,7 +12,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util" "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/ifc"
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig" "sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
) )
@@ -30,7 +30,7 @@ type createFlags struct {
} }
// NewCmdCreate returns an instance of 'create' subcommand. // 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: "."} opts := createFlags{path: "."}
c := &cobra.Command{ c := &cobra.Command{
Use: "create", Use: "create",
@@ -93,7 +93,7 @@ func NewCmdCreate(fSys fs.FileSystem, uf ifc.KunstructuredFactory) *cobra.Comman
return c 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 resources []string
var err error var err error
if opts.resources != "" { if opts.resources != "" {
@@ -147,7 +147,7 @@ func runCreate(opts createFlags, fSys fs.FileSystem, uf ifc.KunstructuredFactory
return mf.Write(m) 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 var paths []string
err := fSys.Walk(base, func(path string, info os.FileInfo, err error) error { err := fSys.Walk(base, func(path string, info os.FileInfo, err error) error {
if err != nil { if err != nil {

View File

@@ -9,13 +9,13 @@ import (
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct" "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" "sigs.k8s.io/kustomize/v3/pkg/types"
) )
var factory = kunstruct.NewKunstructuredFactoryImpl() 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) kf, err := kustfile.NewKustomizationFile(fSys)
if err != nil { if err != nil {
t.Errorf("unexpected new error %v", err) t.Errorf("unexpected new error %v", err)
@@ -27,7 +27,7 @@ func readKustomizationFS(t *testing.T, fSys fs.FileSystem) *types.Kustomization
return m return m
} }
func TestCreateNoArgs(t *testing.T) { func TestCreateNoArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
cmd := NewCmdCreate(fSys, factory) cmd := NewCmdCreate(fSys, factory)
err := cmd.RunE(cmd, []string{}) err := cmd.RunE(cmd, []string{})
if err != nil { if err != nil {
@@ -37,7 +37,7 @@ func TestCreateNoArgs(t *testing.T) {
} }
func TestCreateWithResources(t *testing.T) { func TestCreateWithResources(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.WriteFile("foo.yaml", []byte("")) fSys.WriteFile("foo.yaml", []byte(""))
fSys.WriteFile("bar.yaml", []byte("")) fSys.WriteFile("bar.yaml", []byte(""))
opts := createFlags{resources: "foo.yaml,bar.yaml"} opts := createFlags{resources: "foo.yaml,bar.yaml"}
@@ -53,7 +53,7 @@ func TestCreateWithResources(t *testing.T) {
} }
func TestCreateWithNamespace(t *testing.T) { func TestCreateWithNamespace(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
want := "foo" want := "foo"
opts := createFlags{namespace: want} opts := createFlags{namespace: want}
err := runCreate(opts, fSys, factory) err := runCreate(opts, fSys, factory)
@@ -68,7 +68,7 @@ func TestCreateWithNamespace(t *testing.T) {
} }
func TestCreateWithLabels(t *testing.T) { func TestCreateWithLabels(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
opts := createFlags{labels: "foo:bar"} opts := createFlags{labels: "foo:bar"}
err := runCreate(opts, fSys, factory) err := runCreate(opts, fSys, factory)
if err != nil { if err != nil {
@@ -82,7 +82,7 @@ func TestCreateWithLabels(t *testing.T) {
} }
func TestCreateWithAnnotations(t *testing.T) { func TestCreateWithAnnotations(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
opts := createFlags{annotations: "foo:bar"} opts := createFlags{annotations: "foo:bar"}
err := runCreate(opts, fSys, factory) err := runCreate(opts, fSys, factory)
if err != nil { if err != nil {
@@ -96,7 +96,7 @@ func TestCreateWithAnnotations(t *testing.T) {
} }
func TestCreateWithNamePrefix(t *testing.T) { func TestCreateWithNamePrefix(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
want := "foo-" want := "foo-"
opts := createFlags{prefix: want} opts := createFlags{prefix: want}
err := runCreate(opts, fSys, factory) err := runCreate(opts, fSys, factory)
@@ -111,7 +111,7 @@ func TestCreateWithNamePrefix(t *testing.T) {
} }
func TestCreateWithNameSuffix(t *testing.T) { func TestCreateWithNameSuffix(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
opts := createFlags{suffix: "-foo"} opts := createFlags{suffix: "-foo"}
err := runCreate(opts, fSys, factory) err := runCreate(opts, fSys, factory)
if err != nil { 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(` fSys.WriteFile("/test.yaml", []byte(`
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@@ -165,7 +165,7 @@ resources:
} }
func TestCreateWithDetect(t *testing.T) { func TestCreateWithDetect(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
writeDetectContent(fSys) writeDetectContent(fSys)
opts := createFlags{path: "/", detectResources: true} opts := createFlags{path: "/", detectResources: true}
err := runCreate(opts, fSys, factory) err := runCreate(opts, fSys, factory)
@@ -180,7 +180,7 @@ func TestCreateWithDetect(t *testing.T) {
} }
func TestCreateWithDetectRecursive(t *testing.T) { func TestCreateWithDetectRecursive(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
writeDetectContent(fSys) writeDetectContent(fSys)
opts := createFlags{path: "/", detectResources: true, detectRecursive: true} opts := createFlags{path: "/", detectResources: true, detectRecursive: true}
err := runCreate(opts, fSys, factory) err := runCreate(opts, fSys, factory)

View File

@@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "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 { type addBaseOptions struct {
@@ -18,7 +18,7 @@ type addBaseOptions struct {
} }
// newCmdAddBase adds the file path of the kustomize base to the kustomization file. // 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 var o addBaseOptions
cmd := &cobra.Command{ cmd := &cobra.Command{
@@ -35,7 +35,7 @@ func newCmdAddBase(fsys fs.FileSystem) *cobra.Command {
if err != nil { if err != nil {
return err return err
} }
return o.RunAddBase(fsys) return o.RunAddBase(fSys)
}, },
} }
return cmd return cmd
@@ -56,7 +56,7 @@ func (o *addBaseOptions) Complete(cmd *cobra.Command, args []string) error {
} }
// RunAddBase runs addBase command (do real work). // 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) mf, err := kustfile.NewKustomizationFile(fSys)
if err != nil { if err != nil {
return err return err

View File

@@ -9,7 +9,7 @@ import (
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/v3/pkg/fs" "sigs.k8s.io/kustomize/v3/pkg/filesys"
) )
const ( const (
@@ -17,7 +17,7 @@ const (
) )
func TestAddBaseHappyPath(t *testing.T) { func TestAddBaseHappyPath(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
bases := strings.Split(baseDirectoryPaths, ",") bases := strings.Split(baseDirectoryPaths, ",")
for _, base := range bases { for _, base := range bases {
fSys.Mkdir(base) fSys.Mkdir(base)
@@ -43,7 +43,7 @@ func TestAddBaseHappyPath(t *testing.T) {
} }
func TestAddBaseAlreadyThere(t *testing.T) { func TestAddBaseAlreadyThere(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
// Create fake directories // Create fake directories
bases := strings.Split(baseDirectoryPaths, ",") bases := strings.Split(baseDirectoryPaths, ",")
for _, base := range bases { for _, base := range bases {
@@ -73,7 +73,7 @@ func TestAddBaseAlreadyThere(t *testing.T) {
} }
func TestAddBaseNoArgs(t *testing.T) { func TestAddBaseNoArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
cmd := newCmdAddBase(fSys) cmd := newCmdAddBase(fSys)
err := cmd.Execute() err := cmd.Execute()

View File

@@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util" "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/pgmconfig"
"sigs.k8s.io/kustomize/v3/pkg/types" "sigs.k8s.io/kustomize/v3/pkg/types"
) )
@@ -41,7 +41,7 @@ type addMetadataOptions struct {
} }
// newCmdAddAnnotation adds one or more commonAnnotations to the kustomization file. // 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 var o addMetadataOptions
o.kind = annotation o.kind = annotation
o.mapValidator = v 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. // 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 var o addMetadataOptions
o.kind = label o.kind = label
o.mapValidator = v o.mapValidator = v
@@ -83,7 +83,7 @@ func newCmdAddLabel(fSys fs.FileSystem, v func(map[string]string) error) *cobra.
} }
func (o *addMetadataOptions) runE( 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) err := o.validateAndParse(args)
if err != nil { if err != nil {
return err return err

View File

@@ -8,13 +8,13 @@ import (
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "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/types"
"sigs.k8s.io/kustomize/v3/pkg/validators" "sigs.k8s.io/kustomize/v3/pkg/validators"
) )
func makeKustomization(t *testing.T) *types.Kustomization { func makeKustomization(t *testing.T) *types.Kustomization {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
kf, err := kustfile.NewKustomizationFile(fSys) kf, err := kustfile.NewKustomizationFile(fSys)
if err != nil { if err != nil {
@@ -50,7 +50,7 @@ func TestRunAddAnnotation(t *testing.T) {
} }
func TestAddAnnotationNoArgs(t *testing.T) { func TestAddAnnotationNoArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddAnnotation(fSys, v.Validator) cmd := newCmdAddAnnotation(fSys, v.Validator)
err := cmd.Execute() err := cmd.Execute()
@@ -64,7 +64,7 @@ func TestAddAnnotationNoArgs(t *testing.T) {
} }
func TestAddAnnotationInvalidFormat(t *testing.T) { func TestAddAnnotationInvalidFormat(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
v := validators.MakeSadMapValidator(t) v := validators.MakeSadMapValidator(t)
cmd := newCmdAddAnnotation(fSys, v.Validator) cmd := newCmdAddAnnotation(fSys, v.Validator)
args := []string{"whatever:whatever"} args := []string{"whatever:whatever"}
@@ -79,7 +79,7 @@ func TestAddAnnotationInvalidFormat(t *testing.T) {
} }
func TestAddAnnotationManyArgs(t *testing.T) { func TestAddAnnotationManyArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddAnnotation(fSys, v.Validator) cmd := newCmdAddAnnotation(fSys, v.Validator)
@@ -92,7 +92,7 @@ func TestAddAnnotationManyArgs(t *testing.T) {
} }
func TestAddAnnotationValueQuoted(t *testing.T) { func TestAddAnnotationValueQuoted(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddAnnotation(fSys, v.Validator) cmd := newCmdAddAnnotation(fSys, v.Validator)
@@ -105,7 +105,7 @@ func TestAddAnnotationValueQuoted(t *testing.T) {
} }
func TestAddAnnotationValueWithColon(t *testing.T) { func TestAddAnnotationValueWithColon(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddAnnotation(fSys, v.Validator) cmd := newCmdAddAnnotation(fSys, v.Validator)
@@ -118,7 +118,7 @@ func TestAddAnnotationValueWithColon(t *testing.T) {
} }
func TestAddAnnotationNoKey(t *testing.T) { func TestAddAnnotationNoKey(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddAnnotation(fSys, v.Validator) cmd := newCmdAddAnnotation(fSys, v.Validator)
args := []string{":nokey"} args := []string{":nokey"}
@@ -133,7 +133,7 @@ func TestAddAnnotationNoKey(t *testing.T) {
} }
func TestAddAnnotationTooManyColons(t *testing.T) { func TestAddAnnotationTooManyColons(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddAnnotation(fSys, v.Validator) cmd := newCmdAddAnnotation(fSys, v.Validator)
@@ -146,7 +146,7 @@ func TestAddAnnotationTooManyColons(t *testing.T) {
} }
func TestAddAnnotationNoValue(t *testing.T) { func TestAddAnnotationNoValue(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddAnnotation(fSys, v.Validator) cmd := newCmdAddAnnotation(fSys, v.Validator)
@@ -159,7 +159,7 @@ func TestAddAnnotationNoValue(t *testing.T) {
} }
func TestAddAnnotationMultipleArgs(t *testing.T) { func TestAddAnnotationMultipleArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddAnnotation(fSys, v.Validator) cmd := newCmdAddAnnotation(fSys, v.Validator)
@@ -175,7 +175,7 @@ func TestAddAnnotationMultipleArgs(t *testing.T) {
} }
func TestAddAnnotationForce(t *testing.T) { func TestAddAnnotationForce(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddAnnotation(fSys, v.Validator) cmd := newCmdAddAnnotation(fSys, v.Validator)
@@ -231,7 +231,7 @@ func TestRunAddLabel(t *testing.T) {
} }
func TestAddLabelNoArgs(t *testing.T) { func TestAddLabelNoArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddLabel(fSys, v.Validator) cmd := newCmdAddLabel(fSys, v.Validator)
err := cmd.Execute() err := cmd.Execute()
@@ -245,7 +245,7 @@ func TestAddLabelNoArgs(t *testing.T) {
} }
func TestAddLabelInvalidFormat(t *testing.T) { func TestAddLabelInvalidFormat(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
v := validators.MakeSadMapValidator(t) v := validators.MakeSadMapValidator(t)
cmd := newCmdAddLabel(fSys, v.Validator) cmd := newCmdAddLabel(fSys, v.Validator)
args := []string{"exclamation!:point"} args := []string{"exclamation!:point"}
@@ -260,7 +260,7 @@ func TestAddLabelInvalidFormat(t *testing.T) {
} }
func TestAddLabelNoKey(t *testing.T) { func TestAddLabelNoKey(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddLabel(fSys, v.Validator) cmd := newCmdAddLabel(fSys, v.Validator)
args := []string{":nokey"} args := []string{":nokey"}
@@ -275,7 +275,7 @@ func TestAddLabelNoKey(t *testing.T) {
} }
func TestAddLabelTooManyColons(t *testing.T) { func TestAddLabelTooManyColons(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddLabel(fSys, v.Validator) cmd := newCmdAddLabel(fSys, v.Validator)
@@ -288,7 +288,7 @@ func TestAddLabelTooManyColons(t *testing.T) {
} }
func TestAddLabelNoValue(t *testing.T) { func TestAddLabelNoValue(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddLabel(fSys, v.Validator) cmd := newCmdAddLabel(fSys, v.Validator)
@@ -301,7 +301,7 @@ func TestAddLabelNoValue(t *testing.T) {
} }
func TestAddLabelMultipleArgs(t *testing.T) { func TestAddLabelMultipleArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddLabel(fSys, v.Validator) cmd := newCmdAddLabel(fSys, v.Validator)
@@ -317,7 +317,7 @@ func TestAddLabelMultipleArgs(t *testing.T) {
} }
func TestAddLabelForce(t *testing.T) { func TestAddLabelForce(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
cmd := newCmdAddLabel(fSys, v.Validator) cmd := newCmdAddLabel(fSys, v.Validator)

View File

@@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util" "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/patch"
) )
@@ -19,7 +19,7 @@ type addPatchOptions struct {
} }
// newCmdAddPatch adds the name of a file containing a patch to the kustomization file. // 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 var o addPatchOptions
cmd := &cobra.Command{ cmd := &cobra.Command{
@@ -36,7 +36,7 @@ func newCmdAddPatch(fsys fs.FileSystem) *cobra.Command {
if err != nil { if err != nil {
return err return err
} }
return o.RunAddPatch(fsys) return o.RunAddPatch(fSys)
}, },
} }
return cmd return cmd
@@ -57,7 +57,7 @@ func (o *addPatchOptions) Complete(cmd *cobra.Command, args []string) error {
} }
// RunAddPatch runs addPatch command (do real work). // 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) patches, err := util.GlobPatterns(fSys, o.patchFilePaths)
if err != nil { if err != nil {
return err return err

View File

@@ -8,7 +8,7 @@ import (
"testing" "testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/v3/pkg/fs" "sigs.k8s.io/kustomize/v3/pkg/filesys"
) )
const ( const (
@@ -20,7 +20,7 @@ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
) )
func TestAddPatchHappyPath(t *testing.T) { func TestAddPatchHappyPath(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.WriteFile(patchFileName, []byte(patchFileContent)) fSys.WriteFile(patchFileName, []byte(patchFileContent))
fSys.WriteFile(patchFileName+"another", []byte(patchFileContent)) fSys.WriteFile(patchFileName+"another", []byte(patchFileContent))
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
@@ -44,7 +44,7 @@ func TestAddPatchHappyPath(t *testing.T) {
} }
func TestAddPatchAlreadyThere(t *testing.T) { func TestAddPatchAlreadyThere(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.WriteFile(patchFileName, []byte(patchFileContent)) fSys.WriteFile(patchFileName, []byte(patchFileContent))
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
@@ -63,7 +63,7 @@ func TestAddPatchAlreadyThere(t *testing.T) {
} }
func TestAddPatchNoArgs(t *testing.T) { func TestAddPatchNoArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
cmd := newCmdAddPatch(fSys) cmd := newCmdAddPatch(fSys)
err := cmd.Execute() err := cmd.Execute()

View File

@@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util" "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 { type addResourceOptions struct {
@@ -18,7 +18,7 @@ type addResourceOptions struct {
} }
// newCmdAddResource adds the name of a file containing a resource to the kustomization file. // 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 var o addResourceOptions
cmd := &cobra.Command{ cmd := &cobra.Command{
@@ -35,7 +35,7 @@ func newCmdAddResource(fsys fs.FileSystem) *cobra.Command {
if err != nil { if err != nil {
return err return err
} }
return o.RunAddResource(fsys) return o.RunAddResource(fSys)
}, },
} }
return cmd return cmd
@@ -56,7 +56,7 @@ func (o *addResourceOptions) Complete(cmd *cobra.Command, args []string) error {
} }
// RunAddResource runs addResource command (do real work). // 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) resources, err := util.GlobPatterns(fSys, o.resourceFilePaths)
if err != nil { if err != nil {
return err return err

View File

@@ -8,7 +8,7 @@ import (
"testing" "testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/v3/pkg/fs" "sigs.k8s.io/kustomize/v3/pkg/filesys"
) )
const ( const (
@@ -20,7 +20,7 @@ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
) )
func TestAddResourceHappyPath(t *testing.T) { func TestAddResourceHappyPath(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.WriteFile(resourceFileName, []byte(resourceFileContent)) fSys.WriteFile(resourceFileName, []byte(resourceFileContent))
fSys.WriteFile(resourceFileName+"another", []byte(resourceFileContent)) fSys.WriteFile(resourceFileName+"another", []byte(resourceFileContent))
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
@@ -44,7 +44,7 @@ func TestAddResourceHappyPath(t *testing.T) {
} }
func TestAddResourceAlreadyThere(t *testing.T) { func TestAddResourceAlreadyThere(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.WriteFile(resourceFileName, []byte(resourceFileContent)) fSys.WriteFile(resourceFileName, []byte(resourceFileContent))
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
@@ -63,7 +63,7 @@ func TestAddResourceAlreadyThere(t *testing.T) {
} }
func TestAddResourceNoArgs(t *testing.T) { func TestAddResourceNoArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
cmd := newCmdAddResource(fSys) cmd := newCmdAddResource(fSys)
err := cmd.Execute() err := cmd.Execute()

View File

@@ -5,13 +5,13 @@ package add
import ( import (
"github.com/spf13/cobra" "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/ifc"
) )
// NewCmdAdd returns an instance of 'add' subcommand. // NewCmdAdd returns an instance of 'add' subcommand.
func NewCmdAdd( func NewCmdAdd(
fSys fs.FileSystem, fSys filesys.FileSystem,
ldr ifc.Loader, ldr ifc.Loader,
kf ifc.KunstructuredFactory) *cobra.Command { kf ifc.KunstructuredFactory) *cobra.Command {
c := &cobra.Command{ c := &cobra.Command{

View File

@@ -6,14 +6,14 @@ package add
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "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/ifc"
"sigs.k8s.io/kustomize/v3/pkg/types" "sigs.k8s.io/kustomize/v3/pkg/types"
) )
// newCmdAddConfigMap returns a new command. // newCmdAddConfigMap returns a new command.
func newCmdAddConfigMap( func newCmdAddConfigMap(
fSys fs.FileSystem, fSys filesys.FileSystem,
ldr ifc.Loader, ldr ifc.Loader,
kf ifc.KunstructuredFactory) *cobra.Command { kf ifc.KunstructuredFactory) *cobra.Command {
var flags flagsAndArgs var flags flagsAndArgs

View File

@@ -6,14 +6,14 @@ package add
import ( import (
"testing" "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/loader"
"sigs.k8s.io/kustomize/v3/pkg/types" "sigs.k8s.io/kustomize/v3/pkg/types"
"sigs.k8s.io/kustomize/v3/pkg/validators" "sigs.k8s.io/kustomize/v3/pkg/validators"
) )
func TestNewAddConfigMapIsNotNil(t *testing.T) { func TestNewAddConfigMapIsNotNil(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
ldr := loader.NewFileLoaderAtCwd(validators.MakeFakeValidator(), fSys) ldr := loader.NewFileLoaderAtCwd(validators.MakeFakeValidator(), fSys)
if newCmdAddConfigMap(fSys, ldr, nil) == nil { if newCmdAddConfigMap(fSys, ldr, nil) == nil {
t.Fatal("newCmdAddConfigMap shouldn't be nil") t.Fatal("newCmdAddConfigMap shouldn't be nil")

View File

@@ -8,7 +8,7 @@ import (
"strings" "strings"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util" "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. // 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. // and the key, if missing, is the same as the value.
// In the case where the key is explicitly declared, // In the case where the key is explicitly declared,
// the globbing, if present, must have exactly one match. // 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 var results []string
for _, pattern := range a.FileSources { for _, pattern := range a.FileSources {
var patterns []string var patterns []string

View File

@@ -7,7 +7,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"sigs.k8s.io/kustomize/v3/pkg/fs" "sigs.k8s.io/kustomize/v3/pkg/filesys"
) )
func TestDataValidation_NoName(t *testing.T) { func TestDataValidation_NoName(t *testing.T) {
@@ -73,7 +73,7 @@ func TestDataConfigValidation_Flags(t *testing.T) {
} }
func TestExpandFileSource(t *testing.T) { func TestExpandFileSource(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.Create("dir/fa1") fSys.Create("dir/fa1")
fSys.Create("dir/fa2") fSys.Create("dir/fa2")
fSys.Create("dir/readme") fSys.Create("dir/readme")
@@ -91,7 +91,7 @@ func TestExpandFileSource(t *testing.T) {
} }
func TestExpandFileSourceWithKey(t *testing.T) { func TestExpandFileSourceWithKey(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.Create("dir/faaaaaaaaaabbbbbbbbbccccccccccccccccc") fSys.Create("dir/faaaaaaaaaabbbbbbbbbccccccccccccccccc")
fSys.Create("dir/foobar") fSys.Create("dir/foobar")
fSys.Create("dir/simplebar") fSys.Create("dir/simplebar")
@@ -111,7 +111,7 @@ func TestExpandFileSourceWithKey(t *testing.T) {
} }
func TestExpandFileSourceWithKeyAndError(t *testing.T) { func TestExpandFileSourceWithKeyAndError(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.Create("dir/fa1") fSys.Create("dir/fa1")
fSys.Create("dir/fa2") fSys.Create("dir/fa2")
fSys.Create("dir/readme") fSys.Create("dir/readme")

View File

@@ -6,14 +6,14 @@ package add
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "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/ifc"
"sigs.k8s.io/kustomize/v3/pkg/types" "sigs.k8s.io/kustomize/v3/pkg/types"
) )
// newCmdAddSecret returns a new command. // newCmdAddSecret returns a new command.
func newCmdAddSecret( func newCmdAddSecret(
fSys fs.FileSystem, fSys filesys.FileSystem,
ldr ifc.Loader, ldr ifc.Loader,
kf ifc.KunstructuredFactory) *cobra.Command { kf ifc.KunstructuredFactory) *cobra.Command {
var flags flagsAndArgs var flags flagsAndArgs

View File

@@ -6,14 +6,14 @@ package add
import ( import (
"testing" "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/loader"
"sigs.k8s.io/kustomize/v3/pkg/types" "sigs.k8s.io/kustomize/v3/pkg/types"
"sigs.k8s.io/kustomize/v3/pkg/validators" "sigs.k8s.io/kustomize/v3/pkg/validators"
) )
func TestNewCmdAddSecretIsNotNil(t *testing.T) { func TestNewCmdAddSecretIsNotNil(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
ldr := loader.NewFileLoaderAtCwd(validators.MakeFakeValidator(), fSys) ldr := loader.NewFileLoaderAtCwd(validators.MakeFakeValidator(), fSys)
if newCmdAddSecret(fSys, ldr, nil) == nil { if newCmdAddSecret(fSys, ldr, nil) == nil {
t.Fatal("newCmdAddSecret shouldn't be nil") t.Fatal("newCmdAddSecret shouldn't be nil")

View File

@@ -9,14 +9,14 @@ import (
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/edit/fix" "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/remove"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/edit/set" "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/ifc"
"sigs.k8s.io/kustomize/v3/pkg/loader" "sigs.k8s.io/kustomize/v3/pkg/loader"
) )
// NewCmdEdit returns an instance of 'edit' subcommand. // NewCmdEdit returns an instance of 'edit' subcommand.
func NewCmdEdit( 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{ c := &cobra.Command{
Use: "edit", Use: "edit",
Short: "Edits a kustomization file", Short: "Edits a kustomization file",

View File

@@ -6,11 +6,11 @@ package fix
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "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. // NewCmdFix returns an instance of 'fix' subcommand.
func NewCmdFix(fSys fs.FileSystem) *cobra.Command { func NewCmdFix(fSys filesys.FileSystem) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "fix", Use: "fix",
Short: "Fix the missing fields in kustomization file", Short: "Fix the missing fields in kustomization file",
@@ -28,7 +28,7 @@ func NewCmdFix(fSys fs.FileSystem) *cobra.Command {
} }
// RunFix runs `fix` command // RunFix runs `fix` command
func RunFix(fSys fs.FileSystem) error { func RunFix(fSys filesys.FileSystem) error {
mf, err := kustfile.NewKustomizationFile(fSys) mf, err := kustfile.NewKustomizationFile(fSys)
if err != nil { if err != nil {
return err return err

View File

@@ -8,11 +8,11 @@ import (
"testing" "testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "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) { func TestFix(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomizationWith(fSys, []byte(`nameprefix: some-prefix-`)) testutils.WriteTestKustomizationWith(fSys, []byte(`nameprefix: some-prefix-`))
cmd := NewCmdFix(fSys) cmd := NewCmdFix(fSys)

View File

@@ -5,13 +5,13 @@ package remove
import ( import (
"github.com/spf13/cobra" "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/ifc"
) )
// NewCmdRemove returns an instance of 'remove' subcommand. // NewCmdRemove returns an instance of 'remove' subcommand.
func NewCmdRemove( func NewCmdRemove(
fsys fs.FileSystem, fSys filesys.FileSystem,
ldr ifc.Loader) *cobra.Command { ldr ifc.Loader) *cobra.Command {
c := &cobra.Command{ c := &cobra.Command{
Use: "remove", Use: "remove",
@@ -34,10 +34,10 @@ func NewCmdRemove(
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
} }
c.AddCommand( c.AddCommand(
newCmdRemoveResource(fsys), newCmdRemoveResource(fSys),
newCmdRemoveLabel(fsys, ldr.Validator().MakeLabelNameValidator()), newCmdRemoveLabel(fSys, ldr.Validator().MakeLabelNameValidator()),
newCmdRemoveAnnotation(fsys, ldr.Validator().MakeAnnotationNameValidator()), newCmdRemoveAnnotation(fSys, ldr.Validator().MakeAnnotationNameValidator()),
newCmdRemovePatch(fsys), newCmdRemovePatch(fSys),
) )
return c return c
} }

View File

@@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "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/pgmconfig"
"sigs.k8s.io/kustomize/v3/pkg/types" "sigs.k8s.io/kustomize/v3/pkg/types"
) )
@@ -41,7 +41,7 @@ type removeMetadataOptions struct {
} }
// newCmdRemoveLabel removes one or more commonAnnotations from the kustomization file. // 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 var o removeMetadataOptions
o.kind = label o.kind = label
o.arrayValidator = v 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. // 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 var o removeMetadataOptions
o.kind = label o.kind = label
o.arrayValidator = v o.arrayValidator = v
@@ -83,7 +83,7 @@ func newCmdRemoveLabel(fSys fs.FileSystem, v func([]string) error) *cobra.Comman
} }
func (o *removeMetadataOptions) runE( 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) err := o.validateAndParse(args)
if err != nil { if err != nil {
return err return err

View File

@@ -10,13 +10,13 @@ import (
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "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/types"
"sigs.k8s.io/kustomize/v3/pkg/validators" "sigs.k8s.io/kustomize/v3/pkg/validators"
) )
func makeKustomizationFS() fs.FileSystem { func makeKustomizationFS() filesys.FileSystem {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
commonLabels := []string{"label1: val1", "label2: val2"} commonLabels := []string{"label1: val1", "label2: val2"}
commonAnnotations := []string{"annotation1: val1", "annotation2: val2"} commonAnnotations := []string{"annotation1: val1", "annotation2: val2"}
@@ -26,7 +26,7 @@ func makeKustomizationFS() fs.FileSystem {
return fSys 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) kf, err := kustfile.NewKustomizationFile(fSys)
if err != nil { if err != nil {
t.Errorf("unexpected new error %v", err) t.Errorf("unexpected new error %v", err)
@@ -86,7 +86,7 @@ func TestRemoveAnnotationIgnore(t *testing.T) {
} }
func TestRemoveAnnotationNoDefinition(t *testing.T) { func TestRemoveAnnotationNoDefinition(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomizationWith(fSys, []byte("")) testutils.WriteTestKustomizationWith(fSys, []byte(""))
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
@@ -104,7 +104,7 @@ func TestRemoveAnnotationNoDefinition(t *testing.T) {
} }
func TestRemoveAnnotationNoDefinitionIgnore(t *testing.T) { func TestRemoveAnnotationNoDefinitionIgnore(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomizationWith(fSys, []byte("")) testutils.WriteTestKustomizationWith(fSys, []byte(""))
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
@@ -234,7 +234,7 @@ func TestRemoveLabelIgnore(t *testing.T) {
} }
func TestRemoveLabelNoDefinition(t *testing.T) { func TestRemoveLabelNoDefinition(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomizationWith(fSys, []byte("")) testutils.WriteTestKustomizationWith(fSys, []byte(""))
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)
@@ -252,7 +252,7 @@ func TestRemoveLabelNoDefinition(t *testing.T) {
} }
func TestRemoveLabelNoDefinitionIgnore(t *testing.T) { func TestRemoveLabelNoDefinitionIgnore(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomizationWith(fSys, []byte("")) testutils.WriteTestKustomizationWith(fSys, []byte(""))
v := validators.MakeHappyMapValidator(t) v := validators.MakeHappyMapValidator(t)

View File

@@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util" "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/patch"
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig" "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. // 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 var o removePatchOptions
cmd := &cobra.Command{ cmd := &cobra.Command{
@@ -38,7 +38,7 @@ func newCmdRemovePatch(fsys fs.FileSystem) *cobra.Command {
if err != nil { if err != nil {
return err return err
} }
return o.RunRemovePatch(fsys) return o.RunRemovePatch(fSys)
}, },
} }
return cmd return cmd
@@ -59,7 +59,7 @@ func (o *removePatchOptions) Complete(cmd *cobra.Command, args []string) error {
} }
// RunRemovePatch runs removePatch command (do real work). // 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) patches, err := util.GlobPatterns(fSys, o.patchFilePaths)
if err != nil { if err != nil {
return err return err

View File

@@ -9,7 +9,7 @@ import (
"testing" "testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "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" "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 { func makeKustomizationPatchFS() filesys.FileSystem {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
patches := []string{"patch1.yaml", "patch2.yaml"} patches := []string{"patch1.yaml", "patch2.yaml"}
testutils.WriteTestKustomizationWith(fSys, []byte( testutils.WriteTestKustomizationWith(fSys, []byte(

View File

@@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "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/pgmconfig"
) )
@@ -18,7 +18,7 @@ type removeResourceOptions struct {
} }
// newCmdRemoveResource remove the name of a file containing a resource to the kustomization file. // 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 var o removeResourceOptions
cmd := &cobra.Command{ cmd := &cobra.Command{
@@ -39,7 +39,7 @@ func newCmdRemoveResource(fsys fs.FileSystem) *cobra.Command {
if err != nil { if err != nil {
return err return err
} }
return o.RunRemoveResource(fsys) return o.RunRemoveResource(fSys)
}, },
} }
return cmd return cmd
@@ -60,7 +60,7 @@ func (o *removeResourceOptions) Complete(cmd *cobra.Command, args []string) erro
} }
// RunRemoveResource runs Resource command (do real work). // 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) mf, err := kustfile.NewKustomizationFile(fSys)
if err != nil { if err != nil {

View File

@@ -10,7 +10,7 @@ import (
"testing" "testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "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) { func TestRemoveResources(t *testing.T) {
@@ -125,7 +125,7 @@ func TestRemoveResources(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) { t.Run(tc.description, func(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomizationWith( testutils.WriteTestKustomizationWith(
fSys, fSys,
[]byte(fmt.Sprintf( []byte(fmt.Sprintf(

View File

@@ -5,12 +5,12 @@ package set
import ( import (
"github.com/spf13/cobra" "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/ifc"
) )
// NewCmdSet returns an instance of 'set' subcommand. // 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{ c := &cobra.Command{
Use: "set", Use: "set",
Short: "Sets the value of different fields in kustomization file.", 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( c.AddCommand(
newCmdSetNamePrefix(fsys), newCmdSetNamePrefix(fSys),
newCmdSetNameSuffix(fsys), newCmdSetNameSuffix(fSys),
newCmdSetNamespace(fsys, v), newCmdSetNamespace(fSys, v),
newCmdSetImage(fsys), newCmdSetImage(fSys),
) )
return c return c
} }

View File

@@ -8,7 +8,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "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 { type setNamePrefixOptions struct {
@@ -16,7 +16,7 @@ type setNamePrefixOptions struct {
} }
// newCmdSetNamePrefix sets the value of the namePrefix field in the kustomization. // 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 var o setNamePrefixOptions
cmd := &cobra.Command{ cmd := &cobra.Command{
@@ -37,7 +37,7 @@ and overwrite the value with "acme-" if the field does exist.
if err != nil { if err != nil {
return err return err
} }
return o.RunSetNamePrefix(fsys) return o.RunSetNamePrefix(fSys)
}, },
} }
return cmd return cmd
@@ -59,7 +59,7 @@ func (o *setNamePrefixOptions) Complete(cmd *cobra.Command, args []string) error
} }
// RunSetNamePrefix runs setNamePrefix command (does real work). // 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) mf, err := kustfile.NewKustomizationFile(fSys)
if err != nil { if err != nil {
return err return err

View File

@@ -8,7 +8,7 @@ import (
"testing" "testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/v3/pkg/fs" "sigs.k8s.io/kustomize/v3/pkg/filesys"
) )
const ( const (
@@ -16,7 +16,7 @@ const (
) )
func TestSetNamePrefixHappyPath(t *testing.T) { func TestSetNamePrefixHappyPath(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
cmd := newCmdSetNamePrefix(fSys) cmd := newCmdSetNamePrefix(fSys)
@@ -35,7 +35,7 @@ func TestSetNamePrefixHappyPath(t *testing.T) {
} }
func TestSetNamePrefixNoArgs(t *testing.T) { func TestSetNamePrefixNoArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
cmd := newCmdSetNamePrefix(fSys) cmd := newCmdSetNamePrefix(fSys)
err := cmd.Execute() err := cmd.Execute()

View File

@@ -8,7 +8,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "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 { type setNameSuffixOptions struct {
@@ -16,7 +16,7 @@ type setNameSuffixOptions struct {
} }
// newCmdSetNameSuffix sets the value of the nameSuffix field in the kustomization. // 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 var o setNameSuffixOptions
cmd := &cobra.Command{ cmd := &cobra.Command{
@@ -37,7 +37,7 @@ and overwrite the value with "-acme" if the field does exist.
if err != nil { if err != nil {
return err return err
} }
return o.RunSetNameSuffix(fsys) return o.RunSetNameSuffix(fSys)
}, },
} }
return cmd return cmd
@@ -59,7 +59,7 @@ func (o *setNameSuffixOptions) Complete(cmd *cobra.Command, args []string) error
} }
// RunSetNameSuffix runs setNameSuffix command (does real work). // 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) mf, err := kustfile.NewKustomizationFile(fSys)
if err != nil { if err != nil {
return err return err

View File

@@ -8,7 +8,7 @@ import (
"testing" "testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/v3/pkg/fs" "sigs.k8s.io/kustomize/v3/pkg/filesys"
) )
const ( const (
@@ -16,7 +16,7 @@ const (
) )
func TestSetNameSuffixHappyPath(t *testing.T) { func TestSetNameSuffixHappyPath(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
cmd := newCmdSetNameSuffix(fSys) cmd := newCmdSetNameSuffix(fSys)
@@ -35,7 +35,7 @@ func TestSetNameSuffixHappyPath(t *testing.T) {
} }
func TestSetNameSuffixNoArgs(t *testing.T) { func TestSetNameSuffixNoArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
cmd := newCmdSetNameSuffix(fSys) cmd := newCmdSetNameSuffix(fSys)
err := cmd.Execute() err := cmd.Execute()
if err == nil { if err == nil {

View File

@@ -11,7 +11,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "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" "sigs.k8s.io/kustomize/v3/pkg/image"
) )
@@ -36,7 +36,7 @@ var (
const separator = "=" const separator = "="
// newCmdSetImage sets the new names, tags or digests for images in the kustomization. // 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 var o setImageOptions
cmd := &cobra.Command{ cmd := &cobra.Command{
@@ -78,7 +78,7 @@ and overwrite the previous ones if the image name exists.
if err != nil { if err != nil {
return err return err
} }
return o.RunSetImage(fsys) return o.RunSetImage(fSys)
}, },
} }
return cmd return cmd
@@ -110,7 +110,7 @@ func (o *setImageOptions) Validate(args []string) error {
} }
// RunSetImage runs setImage command. // 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) mf, err := kustfile.NewKustomizationFile(fSys)
if err != nil { if err != nil {
return err return err

View File

@@ -9,7 +9,7 @@ import (
"testing" "testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "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) { func TestSetImage(t *testing.T) {
@@ -190,7 +190,7 @@ func TestSetImage(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
t.Run(fmt.Sprintf("%s%v", tc.description, tc.given.args), func(t *testing.T) { t.Run(fmt.Sprintf("%s%v", tc.description, tc.given.args), func(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
cmd := newCmdSetImage(fSys) cmd := newCmdSetImage(fSys)
if len(tc.given.infileImages) > 0 { if len(tc.given.infileImages) > 0 {

View File

@@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile" "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/ifc"
) )
@@ -20,7 +20,7 @@ type setNamespaceOptions struct {
} }
// newCmdSetNamespace sets the value of the namespace field in the kustomization. // 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 var o setNamespaceOptions
cmd := &cobra.Command{ cmd := &cobra.Command{
@@ -38,7 +38,7 @@ and overwrite the value with "staging" if the field does exist.
if err != nil { if err != nil {
return err return err
} }
return o.RunSetNamespace(fsys) return o.RunSetNamespace(fSys)
}, },
} }
return cmd return cmd
@@ -58,7 +58,7 @@ func (o *setNamespaceOptions) Validate(args []string) error {
} }
// RunSetNamespace runs setNamespace command (does real work). // 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) mf, err := kustfile.NewKustomizationFile(fSys)
if err != nil { if err != nil {
return err return err

View File

@@ -9,7 +9,7 @@ import (
"testing" "testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "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" "sigs.k8s.io/kustomize/v3/pkg/validators"
) )
@@ -18,7 +18,7 @@ const (
) )
func TestSetNamespaceHappyPath(t *testing.T) { func TestSetNamespaceHappyPath(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator()) cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
@@ -38,7 +38,7 @@ func TestSetNamespaceHappyPath(t *testing.T) {
} }
func TestSetNamespaceOverride(t *testing.T) { func TestSetNamespaceOverride(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator()) cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
@@ -63,7 +63,7 @@ func TestSetNamespaceOverride(t *testing.T) {
} }
func TestSetNamespaceNoArgs(t *testing.T) { func TestSetNamespaceNoArgs(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator()) cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
err := cmd.Execute() err := cmd.Execute()
@@ -76,7 +76,7 @@ func TestSetNamespaceNoArgs(t *testing.T) {
} }
func TestSetNamespaceInvalid(t *testing.T) { func TestSetNamespaceInvalid(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator()) cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
args := []string{"/badnamespace/"} args := []string{"/badnamespace/"}

View File

@@ -13,7 +13,7 @@ import (
"regexp" "regexp"
"strings" "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/pgmconfig"
"sigs.k8s.io/kustomize/v3/pkg/types" "sigs.k8s.io/kustomize/v3/pkg/types"
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
@@ -102,12 +102,12 @@ func squash(x [][]byte) []byte {
type kustomizationFile struct { type kustomizationFile struct {
path string path string
fSys fs.FileSystem fSys filesys.FileSystem
originalFields []*commentedField originalFields []*commentedField
} }
// NewKustomizationFile returns a new instance. // 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} mf := &kustomizationFile{fSys: fSys}
err := mf.validate() err := mf.validate()
if err != nil { if err != nil {

View File

@@ -10,7 +10,7 @@ import (
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils" "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/pgmconfig"
"sigs.k8s.io/kustomize/v3/pkg/types" "sigs.k8s.io/kustomize/v3/pkg/types"
) )
@@ -57,7 +57,7 @@ func TestWriteAndRead(t *testing.T) {
NamePrefix: "prefix", NamePrefix: "prefix",
} }
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomization(fSys) testutils.WriteTestKustomization(fSys)
mf, err := NewKustomizationFile(fSys) mf, err := NewKustomizationFile(fSys)
if err != nil { if err != nil {
@@ -79,7 +79,7 @@ func TestWriteAndRead(t *testing.T) {
} }
func TestNewNotExist(t *testing.T) { func TestNewNotExist(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
_, err := NewKustomizationFile(fSys) _, err := NewKustomizationFile(fSys)
if err == nil { if err == nil {
t.Fatalf("expect an error") t.Fatalf("expect an error")
@@ -106,7 +106,7 @@ configMapGenerator:
name: my-configmap name: my-configmap
` `
for _, n := range pgmconfig.RecognizedKustomizationFileNames() { for _, n := range pgmconfig.RecognizedKustomizationFileNames() {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.WriteFile(n, []byte(kcontent)) fSys.WriteFile(n, []byte(kcontent))
k, err := NewKustomizationFile(fSys) k, err := NewKustomizationFile(fSys)
if err != nil { if err != nil {
@@ -143,7 +143,7 @@ patchesStrategicMerge:
- service.yaml - service.yaml
- pod.yaml - pod.yaml
`) `)
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomizationWith(fSys, kustomizationContentWithComments) testutils.WriteTestKustomizationWith(fSys, kustomizationContentWithComments)
mf, err := NewKustomizationFile(fSys) mf, err := NewKustomizationFile(fSys)
if err != nil { if err != nil {
@@ -235,7 +235,7 @@ patchesStrategicMerge:
generatorOptions: generatorOptions:
disableNameSuffixHash: true disableNameSuffixHash: true
`) `)
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomizationWith( testutils.WriteTestKustomizationWith(
fSys, kustomizationContentWithComments) fSys, kustomizationContentWithComments)
mf, err := NewKustomizationFile(fSys) mf, err := NewKustomizationFile(fSys)
@@ -273,7 +273,7 @@ patchesStrategicMerge:
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
`) `)
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomizationWith( testutils.WriteTestKustomizationWith(
fSys, kustomizationContentWithComments) fSys, kustomizationContentWithComments)
mf, err := NewKustomizationFile(fSys) mf, err := NewKustomizationFile(fSys)
@@ -319,7 +319,7 @@ patches:
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
`) `)
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
testutils.WriteTestKustomizationWith(fSys, kustomizationContentWithComments) testutils.WriteTestKustomizationWith(fSys, kustomizationContentWithComments)
mf, err := NewKustomizationFile(fSys) mf, err := NewKustomizationFile(fSys)
if err != nil { if err != nil {

View File

@@ -4,7 +4,7 @@
package testutils package testutils
import ( import (
"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/pgmconfig"
) )
@@ -32,16 +32,16 @@ secretGenerator: []
) )
// WriteTestKustomization writes a standard test file. // WriteTestKustomization writes a standard test file.
func WriteTestKustomization(fSys fs.FileSystem) { func WriteTestKustomization(fSys filesys.FileSystem) {
WriteTestKustomizationWith(fSys, []byte(kustomizationContent)) WriteTestKustomizationWith(fSys, []byte(kustomizationContent))
} }
// WriteTestKustomizationWith writes content to a well known file name. // 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) fSys.WriteFile(pgmconfig.DefaultKustomizationFileName(), bytes)
} }
// ReadTestKustomization reads content from a well known file name. // 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()) return fSys.ReadFile(pgmconfig.DefaultKustomizationFileName())
} }

View File

@@ -8,15 +8,15 @@ import (
"log" "log"
"strings" "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 // GlobPatterns accepts a slice of glob strings and returns the set of
// matching file paths. // matching file paths.
func GlobPatterns(fsys fs.FileSystem, patterns []string) ([]string, error) { func GlobPatterns(fSys filesys.FileSystem, patterns []string) ([]string, error) {
var result []string var result []string
for _, pattern := range patterns { for _, pattern := range patterns {
files, err := fsys.Glob(pattern) files, err := fSys.Glob(pattern)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -1,7 +1,7 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
package fs package filesys
import ( import (
"io/ioutil" "io/ioutil"

View File

@@ -1,7 +1,7 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
package fs package filesys
import ( import (
"path/filepath" "path/filepath"

View File

@@ -1,7 +1,7 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
package fs package filesys
import ( import (
"os" "os"

View File

@@ -1,7 +1,7 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
package fs package filesys
import ( import (
"bytes" "bytes"

View File

@@ -1,7 +1,7 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
package fs package filesys
import ( import (
"os" "os"

View File

@@ -1,8 +1,8 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// Package fs provides a file system abstraction layer. // Package filesys provides a file system abstraction layer.
package fs package filesys
import ( import (
"io" "io"

View File

@@ -1,7 +1,7 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
package fs package filesys
import ( import (
"fmt" "fmt"

View File

@@ -1,7 +1,7 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
package fs package filesys
import ( import (
"bytes" "bytes"

View File

@@ -1,7 +1,7 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
package fs package filesys
import ( import (
"fmt" "fmt"

View File

@@ -1,7 +1,7 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
package fs package filesys
import ( import (
"io/ioutil" "io/ioutil"

View File

@@ -1,7 +1,7 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
package fs package filesys
import "path/filepath" import "path/filepath"

View File

@@ -1,18 +1,5 @@
/* // Copyright 2019 The Kubernetes Authors.
Copyright 2018 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0
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.
*/
package git package git
@@ -22,7 +9,7 @@ import (
"os/exec" "os/exec"
"github.com/pkg/errors" "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. // Cloner is a function that can clone a git repo.
@@ -36,7 +23,7 @@ func ClonerUsingGitExec(repoSpec *RepoSpec) error {
if err != nil { if err != nil {
return errors.Wrap(err, "no 'git' program on path") return errors.Wrap(err, "no 'git' program on path")
} }
repoSpec.Dir, err = fs.NewTmpConfirmedDir() repoSpec.Dir, err = filesys.NewTmpConfirmedDir()
if err != nil { if err != nil {
return err return err
} }
@@ -126,7 +113,7 @@ func ClonerUsingGitExec(repoSpec *RepoSpec) error {
// cloneDir field in the repoSpec. It's assumed that // cloneDir field in the repoSpec. It's assumed that
// the cloneDir is associated with some fake filesystem // the cloneDir is associated with some fake filesystem
// used in a test. // used in a test.
func DoNothingCloner(dir fs.ConfirmedDir) Cloner { func DoNothingCloner(dir filesys.ConfirmedDir) Cloner {
return func(rs *RepoSpec) error { return func(rs *RepoSpec) error {
rs.Dir = dir rs.Dir = dir
return nil return nil

View File

@@ -1,18 +1,5 @@
/* // Copyright 2019 The Kubernetes Authors.
Copyright 2018 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0
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.
*/
package git package git
@@ -22,7 +9,7 @@ import (
"regexp" "regexp"
"strings" "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 // Used as a temporary non-empty occupant of the cloneDir
@@ -30,7 +17,7 @@ import (
// in various outputs (especially tests). Not using an // in various outputs (especially tests). Not using an
// actual directory name here, as that's a temporary directory // actual directory name here, as that's a temporary directory
// with a unique name that isn't created until clone time. // 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. // RepoSpec specifies a git repository and a branch and path therein.
type RepoSpec struct { type RepoSpec struct {
@@ -46,7 +33,7 @@ type RepoSpec struct {
OrgRepo string OrgRepo string
// Dir where the orgRepo is cloned to. // Dir where the orgRepo is cloned to.
Dir fs.ConfirmedDir Dir filesys.ConfirmedDir
// Relative path in the repository, and in the cloneDir, // Relative path in the repository, and in the cloneDir,
// to a Kustomization. // to a Kustomization.
@@ -67,7 +54,7 @@ func (x *RepoSpec) CloneSpec() string {
return x.Host + x.OrgRepo + x.GitSuffix return x.Host + x.OrgRepo + x.GitSuffix
} }
func (x *RepoSpec) CloneDir() fs.ConfirmedDir { func (x *RepoSpec) CloneDir() filesys.ConfirmedDir {
return x.Dir return x.Dir
} }
@@ -79,7 +66,7 @@ func (x *RepoSpec) AbsPath() string {
return x.Dir.Join(x.Path) 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()) } return func() error { return fSys.RemoveAll(x.Dir.String()) }
} }

View File

@@ -9,7 +9,7 @@ import (
"path/filepath" "path/filepath"
"strings" "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/git"
"sigs.k8s.io/kustomize/v3/pkg/ifc" "sigs.k8s.io/kustomize/v3/pkg/ifc"
) )
@@ -74,7 +74,7 @@ type fileLoader struct {
// An absolute, cleaned path to a directory. // An absolute, cleaned path to a directory.
// The Load function will read non-absolute // The Load function will read non-absolute
// paths relative to this directory. // paths relative to this directory.
root fs.ConfirmedDir root filesys.ConfirmedDir
// Restricts behavior of Load function. // Restricts behavior of Load function.
loadRestrictor LoadRestrictorFunc loadRestrictor LoadRestrictorFunc
@@ -87,7 +87,7 @@ type fileLoader struct {
repoSpec *git.RepoSpec repoSpec *git.RepoSpec
// File system utilities. // File system utilities.
fSys fs.FileSystem fSys filesys.FileSystem
// Used to clone repositories. // Used to clone repositories.
cloner git.Cloner cloner git.Cloner
@@ -100,14 +100,14 @@ const CWD = "."
// NewFileLoaderAtCwd returns a loader that loads from ".". // NewFileLoaderAtCwd returns a loader that loads from ".".
// A convenience for kustomize edit commands. // 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( return newLoaderOrDie(
RestrictionRootOnly, v, fSys, CWD) RestrictionRootOnly, v, fSys, CWD)
} }
// NewFileLoaderAtRoot returns a loader that loads from "/". // NewFileLoaderAtRoot returns a loader that loads from "/".
// A convenience for tests. // A convenience for tests.
func NewFileLoaderAtRoot(v ifc.Validator, fSys fs.FileSystem) *fileLoader { func NewFileLoaderAtRoot(v ifc.Validator, fSys filesys.FileSystem) *fileLoader {
return newLoaderOrDie( return newLoaderOrDie(
RestrictionRootOnly, v, fSys, string(filepath.Separator)) RestrictionRootOnly, v, fSys, string(filepath.Separator))
} }
@@ -120,7 +120,7 @@ func (fl *fileLoader) Root() string {
func newLoaderOrDie( func newLoaderOrDie(
lr LoadRestrictorFunc, v ifc.Validator, lr LoadRestrictorFunc, v ifc.Validator,
fSys fs.FileSystem, path string) *fileLoader { fSys filesys.FileSystem, path string) *fileLoader {
root, err := demandDirectoryRoot(fSys, path) root, err := demandDirectoryRoot(fSys, path)
if err != nil { if err != nil {
log.Fatalf("unable to make loader at '%s'; %v", path, err) log.Fatalf("unable to make loader at '%s'; %v", path, err)
@@ -133,7 +133,7 @@ func newLoaderOrDie(
func newLoaderAtConfirmedDir( func newLoaderAtConfirmedDir(
lr LoadRestrictorFunc, lr LoadRestrictorFunc,
v ifc.Validator, v ifc.Validator,
root fs.ConfirmedDir, fSys fs.FileSystem, root filesys.ConfirmedDir, fSys filesys.FileSystem,
referrer *fileLoader, cloner git.Cloner) *fileLoader { referrer *fileLoader, cloner git.Cloner) *fileLoader {
return &fileLoader{ return &fileLoader{
loadRestrictor: lr, loadRestrictor: lr,
@@ -148,7 +148,7 @@ func newLoaderAtConfirmedDir(
// Assure that the given path is in fact a directory. // Assure that the given path is in fact a directory.
func demandDirectoryRoot( func demandDirectoryRoot(
fSys fs.FileSystem, path string) (fs.ConfirmedDir, error) { fSys filesys.FileSystem, path string) (filesys.ConfirmedDir, error) {
if path == "" { if path == "" {
return "", fmt.Errorf( return "", fmt.Errorf(
"loader root cannot be empty") "loader root cannot be empty")
@@ -202,7 +202,7 @@ func (fl *fileLoader) New(path string) (ifc.Loader, error) {
// directory holding a cloned git repo. // directory holding a cloned git repo.
func newLoaderAtGitClone( func newLoaderAtGitClone(
repoSpec *git.RepoSpec, repoSpec *git.RepoSpec,
v ifc.Validator, fSys fs.FileSystem, v ifc.Validator, fSys filesys.FileSystem,
referrer *fileLoader, cloner git.Cloner) (ifc.Loader, error) { referrer *fileLoader, cloner git.Cloner) (ifc.Loader, error) {
cleaner := repoSpec.Cleaner(fSys) cleaner := repoSpec.Cleaner(fSys)
err := cloner(repoSpec) err := cloner(repoSpec)
@@ -239,7 +239,7 @@ func newLoaderAtGitClone(
} }
func (fl *fileLoader) errIfGitContainmentViolation( func (fl *fileLoader) errIfGitContainmentViolation(
base fs.ConfirmedDir) error { base filesys.ConfirmedDir) error {
containingRepo := fl.containingRepo() containingRepo := fl.containingRepo()
if containingRepo == nil { if containingRepo == nil {
return nil return nil
@@ -269,7 +269,7 @@ func (fl *fileLoader) containingRepo() *git.RepoSpec {
// errIfArgEqualOrHigher tests whether the argument, // errIfArgEqualOrHigher tests whether the argument,
// is equal to or above the root of any ancestor. // is equal to or above the root of any ancestor.
func (fl *fileLoader) errIfArgEqualOrHigher( func (fl *fileLoader) errIfArgEqualOrHigher(
candidateRoot fs.ConfirmedDir) error { candidateRoot filesys.ConfirmedDir) error {
if fl.root.HasPrefix(candidateRoot) { if fl.root.HasPrefix(candidateRoot) {
return fmt.Errorf( return fmt.Errorf(
"cycle detected: candidate root '%s' contains visited root '%s'", "cycle detected: candidate root '%s' contains visited root '%s'",

View File

@@ -25,7 +25,7 @@ import (
"strings" "strings"
"testing" "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/git"
"sigs.k8s.io/kustomize/v3/pkg/ifc" "sigs.k8s.io/kustomize/v3/pkg/ifc"
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig" "sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
@@ -56,8 +56,8 @@ var testCases = []testData{
}, },
} }
func MakeFakeFs(td []testData) fs.FileSystem { func MakeFakeFs(td []testData) filesys.FileSystem {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
for _, x := range td { for _, x := range td {
fSys.WriteFile("/"+x.path, []byte(x.expectedContent)) fSys.WriteFile("/"+x.path, []byte(x.expectedContent))
} }
@@ -225,12 +225,12 @@ const (
// │ └── symLinkToExteriorData -> ../exteriorData // │ └── symLinkToExteriorData -> ../exteriorData
// └── exteriorData // └── exteriorData
// //
func commonSetupForLoaderRestrictionTest() (string, fs.FileSystem, error) { func commonSetupForLoaderRestrictionTest() (string, filesys.FileSystem, error) {
dir, err := ioutil.TempDir("", "kustomize-test-") dir, err := ioutil.TempDir("", "kustomize-test-")
if err != nil { if err != nil {
return "", nil, err return "", nil, err
} }
fSys := fs.MakeFsOnDisk() fSys := filesys.MakeFsOnDisk()
fSys.Mkdir(filepath.Join(dir, "base")) fSys.Mkdir(filepath.Join(dir, "base"))
fSys.WriteFile( fSys.WriteFile(
@@ -385,7 +385,7 @@ func TestNewLoaderAtGitClone(t *testing.T) {
pathInRepo := "foo/base" pathInRepo := "foo/base"
url := rootUrl + "/" + pathInRepo url := rootUrl + "/" + pathInRepo
coRoot := "/tmp" coRoot := "/tmp"
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.MkdirAll(coRoot) fSys.MkdirAll(coRoot)
fSys.MkdirAll(coRoot + "/" + pathInRepo) fSys.MkdirAll(coRoot + "/" + pathInRepo)
fSys.WriteFile( fSys.WriteFile(
@@ -401,7 +401,7 @@ whatever
} }
l, err := newLoaderAtGitClone( l, err := newLoaderAtGitClone(
repoSpec, validators.MakeFakeValidator(), fSys, nil, repoSpec, validators.MakeFakeValidator(), fSys, nil,
git.DoNothingCloner(fs.ConfirmedDir(coRoot))) git.DoNothingCloner(filesys.ConfirmedDir(coRoot)))
if err != nil { if err != nil {
t.Fatalf("unexpected err: %v\n", err) 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. // Define an overlay-base structure in the file system.
topDir := "/whatever" topDir := "/whatever"
cloneRoot := topDir + "/someClone" cloneRoot := topDir + "/someClone"
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.MkdirAll(topDir + "/highBase") fSys.MkdirAll(topDir + "/highBase")
fSys.MkdirAll(cloneRoot + "/foo/base") fSys.MkdirAll(cloneRoot + "/foo/base")
fSys.MkdirAll(cloneRoot + "/foo/overlay") fSys.MkdirAll(cloneRoot + "/foo/overlay")
@@ -480,7 +480,7 @@ func TestLoaderDisallowsLocalBaseFromRemoteOverlay(t *testing.T) {
} }
l1, err = newLoaderAtGitClone( l1, err = newLoaderAtGitClone(
repoSpec, validators.MakeFakeValidator(), fSys, nil, repoSpec, validators.MakeFakeValidator(), fSys, nil,
git.DoNothingCloner(fs.ConfirmedDir(cloneRoot))) git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
if err != nil { if err != nil {
t.Fatalf("unexpected err: %v\n", err) t.Fatalf("unexpected err: %v\n", err)
} }
@@ -509,7 +509,7 @@ func TestLoaderDisallowsLocalBaseFromRemoteOverlay(t *testing.T) {
func TestLocalLoaderReferencingGitBase(t *testing.T) { func TestLocalLoaderReferencingGitBase(t *testing.T) {
topDir := "/whatever" topDir := "/whatever"
cloneRoot := topDir + "/someClone" cloneRoot := topDir + "/someClone"
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.MkdirAll(topDir) fSys.MkdirAll(topDir)
fSys.MkdirAll(cloneRoot + "/foo/base") fSys.MkdirAll(cloneRoot + "/foo/base")
@@ -519,7 +519,7 @@ func TestLocalLoaderReferencingGitBase(t *testing.T) {
} }
l1 := newLoaderAtConfirmedDir( l1 := newLoaderAtConfirmedDir(
RestrictionRootOnly, validators.MakeFakeValidator(), root, fSys, nil, RestrictionRootOnly, validators.MakeFakeValidator(), root, fSys, nil,
git.DoNothingCloner(fs.ConfirmedDir(cloneRoot))) git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
if l1.Root() != topDir { if l1.Root() != topDir {
t.Fatalf("unexpected root %s", l1.Root()) t.Fatalf("unexpected root %s", l1.Root())
} }
@@ -535,7 +535,7 @@ func TestLocalLoaderReferencingGitBase(t *testing.T) {
func TestRepoDirectCycleDetection(t *testing.T) { func TestRepoDirectCycleDetection(t *testing.T) {
topDir := "/cycles" topDir := "/cycles"
cloneRoot := topDir + "/someClone" cloneRoot := topDir + "/someClone"
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.MkdirAll(topDir) fSys.MkdirAll(topDir)
fSys.MkdirAll(cloneRoot) fSys.MkdirAll(cloneRoot)
@@ -545,7 +545,7 @@ func TestRepoDirectCycleDetection(t *testing.T) {
} }
l1 := newLoaderAtConfirmedDir( l1 := newLoaderAtConfirmedDir(
RestrictionRootOnly, validators.MakeFakeValidator(), root, fSys, nil, RestrictionRootOnly, validators.MakeFakeValidator(), root, fSys, nil,
git.DoNothingCloner(fs.ConfirmedDir(cloneRoot))) git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
p1 := "github.com/someOrg/someRepo/foo" p1 := "github.com/someOrg/someRepo/foo"
rs1, err := git.NewRepoSpecFromUrl(p1) rs1, err := git.NewRepoSpecFromUrl(p1)
if err != nil { if err != nil {
@@ -564,7 +564,7 @@ func TestRepoDirectCycleDetection(t *testing.T) {
func TestRepoIndirectCycleDetection(t *testing.T) { func TestRepoIndirectCycleDetection(t *testing.T) {
topDir := "/cycles" topDir := "/cycles"
cloneRoot := topDir + "/someClone" cloneRoot := topDir + "/someClone"
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.MkdirAll(topDir) fSys.MkdirAll(topDir)
fSys.MkdirAll(cloneRoot) fSys.MkdirAll(cloneRoot)
@@ -574,7 +574,7 @@ func TestRepoIndirectCycleDetection(t *testing.T) {
} }
l0 := newLoaderAtConfirmedDir( l0 := newLoaderAtConfirmedDir(
RestrictionRootOnly, validators.MakeFakeValidator(), root, fSys, nil, RestrictionRootOnly, validators.MakeFakeValidator(), root, fSys, nil,
git.DoNothingCloner(fs.ConfirmedDir(cloneRoot))) git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
p1 := "github.com/someOrg/someRepo1" p1 := "github.com/someOrg/someRepo1"
p2 := "github.com/someOrg/someRepo2" p2 := "github.com/someOrg/someRepo2"

View File

@@ -7,7 +7,7 @@ import (
"reflect" "reflect"
"testing" "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/types"
"sigs.k8s.io/kustomize/v3/pkg/validators" "sigs.k8s.io/kustomize/v3/pkg/validators"
) )
@@ -46,7 +46,7 @@ func TestKeyValuesFromLines(t *testing.T) {
} }
l := NewFileLoaderAtRoot( l := NewFileLoaderAtRoot(
validators.MakeFakeValidator(), fs.MakeFsInMemory()) validators.MakeFakeValidator(), filesys.MakeFsInMemory())
for _, test := range tests { for _, test := range tests {
pairs, err := l.keyValuesFromLines([]byte(test.content)) pairs, err := l.keyValuesFromLines([]byte(test.content))
if test.expectedErr && err == nil { 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")) fSys.WriteFile("/files/app-init.ini", []byte("FOO=bar"))
l := NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys) l := NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys)
for _, tc := range tests { for _, tc := range tests {

View File

@@ -1,24 +1,11 @@
/* // Copyright 2019 The Kubernetes Authors.
Copyright 2018 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0
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.
*/
// Package loader has a data loading interface and various implementations. // Package loader has a data loading interface and various implementations.
package loader package loader
import ( 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/git"
"sigs.k8s.io/kustomize/v3/pkg/ifc" "sigs.k8s.io/kustomize/v3/pkg/ifc"
) )
@@ -32,7 +19,7 @@ import (
func NewLoader( func NewLoader(
lr LoadRestrictorFunc, lr LoadRestrictorFunc,
v ifc.Validator, v ifc.Validator,
target string, fSys fs.FileSystem) (ifc.Loader, error) { target string, fSys filesys.FileSystem) (ifc.Loader, error) {
repoSpec, err := git.NewRepoSpecFromUrl(target) repoSpec, err := git.NewRepoSpecFromUrl(target)
if err == nil { if err == nil {
// The target qualifies as a remote git target. // The target qualifies as a remote git target.

View File

@@ -1,18 +1,5 @@
/* // Copyright 2019 The Kubernetes Authors.
Copyright 2018 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0
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.
*/
package loader package loader
@@ -20,7 +7,7 @@ import (
"fmt" "fmt"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"sigs.k8s.io/kustomize/v3/pkg/fs" "sigs.k8s.io/kustomize/v3/pkg/filesys"
) )
//go:generate stringer -type=loadRestrictions //go:generate stringer -type=loadRestrictions
@@ -64,10 +51,10 @@ func ValidateFlagLoadRestrictor() (LoadRestrictorFunc, error) {
} }
type LoadRestrictorFunc func( type LoadRestrictorFunc func(
fs.FileSystem, fs.ConfirmedDir, string) (string, error) filesys.FileSystem, filesys.ConfirmedDir, string) (string, error)
func RestrictionRootOnly( 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) d, f, err := fSys.CleanedAbs(path)
if err != nil { if err != nil {
return "", err return "", err
@@ -84,6 +71,6 @@ func RestrictionRootOnly(
} }
func RestrictionNone( func RestrictionNone(
_ fs.FileSystem, _ fs.ConfirmedDir, path string) (string, error) { _ filesys.FileSystem, _ filesys.ConfirmedDir, path string) (string, error) {
return path, nil return path, nil
} }

View File

@@ -20,12 +20,12 @@ import (
"strings" "strings"
"testing" "testing"
"sigs.k8s.io/kustomize/v3/pkg/fs" "sigs.k8s.io/kustomize/v3/pkg/filesys"
) )
func TestRestrictionNone(t *testing.T) { func TestRestrictionNone(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
root := fs.ConfirmedDir("irrelevant") root := filesys.ConfirmedDir("irrelevant")
path := "whatever" path := "whatever"
p, err := RestrictionNone(fSys, root, path) p, err := RestrictionNone(fSys, root, path)
if err != nil { if err != nil {
@@ -37,8 +37,8 @@ func TestRestrictionNone(t *testing.T) {
} }
func TestRestrictionRootOnly(t *testing.T) { func TestRestrictionRootOnly(t *testing.T) {
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
root := fs.ConfirmedDir("/tmp/foo") root := filesys.ConfirmedDir("/tmp/foo")
path := "/tmp/foo/whatever/beans" path := "/tmp/foo/whatever/beans"
p, err := RestrictionRootOnly(fSys, root, path) p, err := RestrictionRootOnly(fSys, root, path)

View File

@@ -9,7 +9,7 @@ import (
"testing" "testing"
"sigs.k8s.io/kustomize/v3/internal/loadertest" "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/gvk"
"sigs.k8s.io/kustomize/v3/pkg/ifc" "sigs.k8s.io/kustomize/v3/pkg/ifc"
"sigs.k8s.io/kustomize/v3/pkg/loader" "sigs.k8s.io/kustomize/v3/pkg/loader"
@@ -234,7 +234,7 @@ func TestNewResMapFromSecretArgs(t *testing.T) {
Type: ifc.SecretTypeOpaque, Type: ifc.SecretTypeOpaque,
}, },
} }
fSys := fs.MakeFsInMemory() fSys := filesys.MakeFsInMemory()
fSys.Mkdir(".") fSys.Mkdir(".")
actual, err := rmF.NewResMapFromSecretArgs( actual, err := rmF.NewResMapFromSecretArgs(
loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys), nil, secrets) loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys), nil, secrets)

View File

@@ -11,7 +11,7 @@ import (
"sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct" "sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct"
"sigs.k8s.io/kustomize/v3/k8sdeps/transformer" "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/kusttest"
"sigs.k8s.io/kustomize/v3/pkg/loader" "sigs.k8s.io/kustomize/v3/pkg/loader"
"sigs.k8s.io/kustomize/v3/pkg/plugins" "sigs.k8s.io/kustomize/v3/pkg/plugins"
@@ -39,7 +39,7 @@ func TestPluginDir(t *testing.T) {
} }
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
fSys := fs.MakeFsOnDisk() fSys := filesys.MakeFsOnDisk()
err = fSys.WriteFile(filepath.Join(dir, "kustomization.yaml"), []byte(` err = fSys.WriteFile(filepath.Join(dir, "kustomization.yaml"), []byte(`
generators: generators:
- config.yaml - config.yaml

View File

@@ -2,6 +2,15 @@ module sigs.k8s.io/kustomize/pluginator
go 1.13 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 => ../

View File

@@ -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-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 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-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/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-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-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-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-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-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= 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/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 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= 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/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.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/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 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=