@@ -95,3 +95,43 @@ func TestLoaderWithWorkingDir(t *testing.T) {
9595 npLdr .Config ().FnpLoadingOptions .WorkingDir ,
9696 "the plugin working dir is not updated" )
9797}
98+
99+ func TestLoaderWithStorageMounts (t * testing.T ) {
100+ const storageMountTransformer = `
101+ apiVersion: com.example.kustomize/v1
102+ kind: Test
103+ metadata:
104+ name: test-transformer
105+ annotations:
106+ config.kubernetes.io/function: |
107+ container:
108+ image: test
109+ mounts:
110+ - type: bind
111+ src: ../
112+ dst: /mount
113+ `
114+ p := provider .NewDefaultDepProvider ()
115+ rmF := resmap .NewFactory (p .GetResourceFactory ())
116+ fsys := filesys .MakeFsInMemory ()
117+ fLdr , err := loader .NewLoader (
118+ loader .RestrictionRootOnly ,
119+ filesys .Separator , fsys )
120+ if err != nil {
121+ t .Fatal (err )
122+ }
123+ configs , err := rmF .NewResMapFromBytes ([]byte (storageMountTransformer ))
124+ if err != nil {
125+ t .Fatal (err )
126+ }
127+ c := types .EnabledPluginConfig (types .BploLoadFromFileSys )
128+ pLdr := NewLoader (c , rmF , fsys )
129+ if pLdr == nil {
130+ t .Fatal ("expect non-nil loader" )
131+ }
132+ _ , err = pLdr .LoadTransformers (
133+ fLdr , valtest_test .MakeFakeValidator (), configs )
134+ if err == nil { // should fail because src specified is outside root
135+ t .Fatal ("the loader allowed a mount outside root" )
136+ }
137+ }
0 commit comments