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