mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 09:24:23 +00:00
make BuildOptions exported
This commit is contained in:
@@ -29,11 +29,20 @@ import (
|
||||
"sigs.k8s.io/kustomize/pkg/target"
|
||||
)
|
||||
|
||||
type buildOptions struct {
|
||||
// BuildOptions contain the options for running a build
|
||||
type BuildOptions struct {
|
||||
kustomizationPath string
|
||||
outputPath string
|
||||
}
|
||||
|
||||
// NewBuildOptions creates a BuildOptions object
|
||||
func NewBuildOptions(p, o string) *BuildOptions {
|
||||
return &BuildOptions{
|
||||
kustomizationPath: p,
|
||||
outputPath: o,
|
||||
}
|
||||
}
|
||||
|
||||
var examples = `
|
||||
Use the file somedir/kustomization.yaml to generate a set of api resources:
|
||||
build somedir
|
||||
@@ -54,7 +63,7 @@ func NewCmdBuild(
|
||||
out io.Writer, fs fs.FileSystem,
|
||||
rf *resmap.Factory,
|
||||
ptf transformer.Factory) *cobra.Command {
|
||||
var o buildOptions
|
||||
var o BuildOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "build [path]",
|
||||
@@ -77,7 +86,7 @@ func NewCmdBuild(
|
||||
}
|
||||
|
||||
// Validate validates build command.
|
||||
func (o *buildOptions) Validate(args []string) error {
|
||||
func (o *BuildOptions) Validate(args []string) error {
|
||||
if len(args) > 1 {
|
||||
return errors.New("specify one path to " + constants.KustomizationFileName)
|
||||
}
|
||||
@@ -91,7 +100,7 @@ func (o *buildOptions) Validate(args []string) error {
|
||||
}
|
||||
|
||||
// RunBuild runs build command.
|
||||
func (o *buildOptions) RunBuild(
|
||||
func (o *BuildOptions) RunBuild(
|
||||
out io.Writer, fSys fs.FileSystem,
|
||||
rf *resmap.Factory, ptf transformer.Factory) error {
|
||||
ldr, err := loader.NewLoader(o.kustomizationPath, fSys)
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestBuildValidate(t *testing.T) {
|
||||
"", "specify one path to " + constants.KustomizationFileName},
|
||||
}
|
||||
for _, mycase := range cases {
|
||||
opts := buildOptions{}
|
||||
opts := BuildOptions{}
|
||||
e := opts.Validate(mycase.args)
|
||||
if len(mycase.erMsg) > 0 {
|
||||
if e == nil {
|
||||
|
||||
Reference in New Issue
Block a user