Skip to content

Commit

Permalink
Add setting to not install namespace on chart_app
Browse files Browse the repository at this point in the history
This commit allows an app author to not get the chart_app install option
to try to create the namespace. This is useful when namespaces are
created from a yaml file with specific annotations.

Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
  • Loading branch information
Waterdrips authored and alexellis committed Jan 30, 2021
1 parent 7084b7a commit 6680f83
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions cmd/apps/openfaas_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func MakeInstallOpenFaaS() *cobra.Command {
WithHelmURL("https://openfaas.github.io/faas-netes/").
WithHelmRepo("openfaas/openfaas").
WithNamespace(namespace).
WithInstallNamespace(false).
WithWait(wait)

if _, err := apps.MakeInstallChart(appOpts); err != nil {
Expand Down
6 changes: 4 additions & 2 deletions pkg/apps/chart_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ func MakeInstallChart(options *types.InstallerOptions) (*types.InstallerOutput,
return nil, err
}

if err := k8s.CreateNamespace(options.Namespace); err != nil {
return nil, err
if options.CreateNamespace {
if err := k8s.CreateNamespace(options.Namespace); err != nil {
return nil, err
}
}

for _, secret := range options.Secrets {
Expand Down
25 changes: 16 additions & 9 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package types
import "github.com/alexellis/arkade/pkg/config"

type InstallerOptions struct {
Namespace string
KubeconfigPath string
NodeArch string
Helm *HelmConfig
Verbose bool
Secrets []K8sSecret
Namespace string
CreateNamespace bool
KubeconfigPath string
NodeArch string
Helm *HelmConfig
Verbose bool
Secrets []K8sSecret
}

type K8sSecret struct {
Expand Down Expand Up @@ -93,11 +94,17 @@ func (o *InstallerOptions) WithSecret(secret K8sSecret) *InstallerOptions {
return o
}

func (o *InstallerOptions) WithInstallNamespace(b bool) *InstallerOptions {
o.CreateNamespace = b
return o
}

func DefaultInstallOptions() *InstallerOptions {
return &InstallerOptions{
Namespace: "default",
KubeconfigPath: config.GetDefaultKubeconfig(),
NodeArch: "x86_64",
Namespace: "default",
KubeconfigPath: config.GetDefaultKubeconfig(),
NodeArch: "x86_64",
CreateNamespace: false,
Helm: &HelmConfig{
Repo: &HelmRepo{
Version: "",
Expand Down

0 comments on commit 6680f83

Please sign in to comment.