mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Use mount flag to pass storage mounts to functions
This commit is contained in:
@@ -51,10 +51,6 @@ type RunFns struct {
|
||||
// NetworkName is the name of the docker network to use for the container
|
||||
NetworkName string
|
||||
|
||||
// Volumes Volumes allows directories to be specified outside the configuration
|
||||
// directory.
|
||||
Volumes []string
|
||||
|
||||
// Output can be set to write the result to Output rather than back to the directory
|
||||
Output io.Writer
|
||||
|
||||
@@ -137,13 +133,6 @@ func (r RunFns) getFilters(nodes []*yaml.RNode) ([]kio.Filter, error) {
|
||||
}
|
||||
fltrs = append(fltrs, f...)
|
||||
|
||||
// directories from volumes specified on the struct
|
||||
f, err = r.getDirectoriesFromVolumes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fltrs = append(fltrs, f...)
|
||||
|
||||
// explicit fns specified on the struct
|
||||
f, err = r.getFunctionsFromFunctions()
|
||||
if err != nil {
|
||||
@@ -207,24 +196,6 @@ func (r RunFns) getFunctionsFromFunctionPaths() ([]kio.Filter, error) {
|
||||
return r.getFunctionFilters(true, buff.Nodes...)
|
||||
}
|
||||
|
||||
// getDirectoriesFromVolumes returns the set of directories read from r.Volumes
|
||||
// as a slice of Filters
|
||||
func (r RunFns) getDirectoriesFromVolumes() ([]kio.Filter, error) {
|
||||
buff := &kio.PackageBuffer{}
|
||||
for i := range r.Volumes {
|
||||
err := kio.Pipeline{
|
||||
Inputs: []kio.Reader{
|
||||
kio.LocalPackageReader{PackagePath: r.Volumes[i]},
|
||||
},
|
||||
Outputs: []kio.Writer{buff},
|
||||
}.Execute()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return r.getFunctionFilters(true, buff.Nodes...)
|
||||
}
|
||||
|
||||
// getFunctionsFromFunctions returns the set of explicitly provided functions as
|
||||
// Filters
|
||||
func (r RunFns) getFunctionsFromFunctions() ([]kio.Filter, error) {
|
||||
|
||||
@@ -141,13 +141,13 @@ func TestRunFns_Execute__initDefault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "explicit directories in volumes",
|
||||
instance: RunFns{Volumes: []string{"vol"}},
|
||||
name: "explicit directories in mounts",
|
||||
instance: RunFns{StorageMounts: []filters.StorageMount{{MountType: "volume", Src: "myvol", DstPath: "/local/"}}},
|
||||
expected: RunFns{
|
||||
Output: os.Stdout,
|
||||
Input: os.Stdin,
|
||||
NoFunctionsFromInput: getFalse(),
|
||||
Volumes: []string{"vol"},
|
||||
StorageMounts: []filters.StorageMount{{MountType: "volume", Src: "myvol", DstPath: "/local/"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user