Skip to content

Commit ba63df0

Browse files
committed
Make namespace arg optional for RunFuncDeploy()
1 parent 0ba0b49 commit ba63df0

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

test/e2e/bundle_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ func createNamespaceAndDeployFunction() TestNamespace {
363363
DeferCleanup(os.RemoveAll, repoDir)
364364

365365
// Deploy function
366-
out, err := utils.RunFuncDeploy(repoDir, ns)
366+
out, err := utils.RunFuncDeploy(repoDir, utils.WithNamespace(ns))
367367
Expect(err).NotTo(HaveOccurred())
368368
_, _ = fmt.Fprint(GinkgoWriter, out)
369369

test/e2e/func_deploy_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ var _ = Describe("Operator", func() {
154154
DeferCleanup(cleanupNamespaces, functionNamespace)
155155

156156
// Deploy function using func CLI
157-
out, err := utils.RunFuncDeploy(repoDir, functionNamespace)
157+
out, err := utils.RunFuncDeploy(repoDir, utils.WithNamespace(functionNamespace))
158158
Expect(err).NotTo(HaveOccurred())
159159
_, _ = fmt.Fprint(GinkgoWriter, out)
160160

@@ -235,7 +235,7 @@ var _ = Describe("Operator", func() {
235235
functionDir := filepath.Join(repoDir, subPath)
236236

237237
// Deploy function using func CLI
238-
out, err := utils.RunFuncDeploy(functionDir, functionNamespace)
238+
out, err := utils.RunFuncDeploy(functionDir, utils.WithNamespace(functionNamespace))
239239
Expect(err).NotTo(HaveOccurred())
240240
_, _ = fmt.Fprint(GinkgoWriter, out)
241241

@@ -375,7 +375,7 @@ var _ = Describe("Operator", func() {
375375
DeferCleanup(cleanupNamespaces, functionNamespace)
376376

377377
// Deploy function using func CLI
378-
out, err := utils.RunFuncDeploy(repoDir, functionNamespace)
378+
out, err := utils.RunFuncDeploy(repoDir, utils.WithNamespace(functionNamespace))
379379
Expect(err).NotTo(HaveOccurred())
380380
_, _ = fmt.Fprint(GinkgoWriter, out)
381381

test/utils/func.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func RunFunc(command string, args ...string) (string, error) {
3434
}
3535

3636
// RunFuncDeploy runs func deploy
37-
func RunFuncDeploy(functionDir, functionNamespace string, optFns ...FuncDeployOption) (string, error) {
37+
func RunFuncDeploy(functionDir string, optFns ...FuncDeployOption) (string, error) {
3838
opts := &FuncDeployOptions{
3939
// defaults
4040
Registry: Registry(),
@@ -46,12 +46,15 @@ func RunFuncDeploy(functionDir, functionNamespace string, optFns ...FuncDeployOp
4646
}
4747

4848
args := []string{
49-
"--namespace", functionNamespace,
5049
"--path", functionDir,
5150
"--registry", opts.Registry,
5251
fmt.Sprintf("--registry-insecure=%t", opts.RegistryInsecure),
5352
}
5453

54+
if opts.Namespace != "" {
55+
args = append(args, "--namespace", opts.Namespace)
56+
}
57+
5558
if opts.Builder != "" {
5659
args = append(args, "--builder", opts.Builder)
5760
}
@@ -79,12 +82,19 @@ func RunFuncWithVersion(version string, command string, args ...string) (string,
7982
type FuncDeployOptions struct {
8083
Registry string
8184
RegistryInsecure bool
85+
Namespace string
8286
Builder string
8387
Deployer string
8488
}
8589

8690
type FuncDeployOption func(*FuncDeployOptions)
8791

92+
func WithNamespace(namespace string) FuncDeployOption {
93+
return func(opts *FuncDeployOptions) {
94+
opts.Namespace = namespace
95+
}
96+
}
97+
8898
func WithBuilder(builder string) FuncDeployOption {
8999
return func(o *FuncDeployOptions) {
90100
o.Builder = builder

0 commit comments

Comments
 (0)