Skip to content

Commit

Permalink
make namespace required for uninstalling a helm release
Browse files Browse the repository at this point in the history
  • Loading branch information
MCMChorfa committed Mar 26, 2020
1 parent 2fdee8c commit 7178153
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MIXIN = helm3
PKG = get.porter.sh/mixin/$(MIXIN)
PKG = github.com/MChorfa/porter-helm3/pkg/$(MIXIN)
SHELL = bash

GO = GO111MODULE=on go
Expand Down Expand Up @@ -74,16 +74,16 @@ publish: bin/porter$(FILE_EXT)
# The porter mixins feed generate command is used to build an ATOM feed for sharing mixins once published

# AZURE_STORAGE_CONNECTION_STRING will be used for auth in the following commands
if [[ "$(PERMALINK)" == "latest" ]]; then \
az storage blob upload-batch -d porter/mixins/$(MIXIN)/$(VERSION) -s $(BINDIR)/$(VERSION); \
az storage blob upload-batch -d porter/mixins/$(MIXIN)/$(PERMALINK) -s $(BINDIR)/$(VERSION); \
else \
mv $(BINDIR)/$(VERSION) $(BINDIR)/$(PERMALINK); \
az storage blob upload-batch -d porter/mixins/$(MIXIN)/$(PERMALINK) -s $(BINDIR)/$(PERMALINK); \
fi
# if [[ "$(PERMALINK)" == "latest" ]]; then \
# az storage blob upload-batch -d porter/mixins/$(MIXIN)/$(VERSION) -s $(BINDIR)/$(VERSION); \
# az storage blob upload-batch -d porter/mixins/$(MIXIN)/$(PERMALINK) -s $(BINDIR)/$(VERSION); \
# else \
# mv $(BINDIR)/$(VERSION) $(BINDIR)/$(PERMALINK); \
# az storage blob upload-batch -d porter/mixins/$(MIXIN)/$(PERMALINK) -s $(BINDIR)/$(PERMALINK); \
# fi

# Generate the mixin feed
az storage blob download -c porter -n atom.xml -f bin/atom.xml
# az storage blob download -c porter -n atom.xml -f bin/atom.xml
bin/porter mixins feed generate -d bin/mixins -f bin/atom.xml -t build/atom-template.xml
#az storage blob upload -c porter -n atom.xml -f bin/atom.xml

Expand Down
5 changes: 4 additions & 1 deletion pkg/helm3/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,13 @@
"type": "string"
},
"minItems": 1
},
"namespace": {
"type": "string"
}
},
"additionalProperties": false,
"required": ["description", "releases"]
"required": ["description", "releases", "namespace"]
}
},
"required": ["helm3"]
Expand Down
11 changes: 6 additions & 5 deletions pkg/helm3/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ type UninstallStep struct {

// UninstallArguments are the arguments available for the Uninstall action
type UninstallArguments struct {
Step `yaml:",inline"`

Releases []string `yaml:"releases"`
Step `yaml:",inline"`
Namespace string `yaml:"namespace"`
Releases []string `yaml:"releases"`
}

// Uninstall deletes a provided set of Helm releases, supplying optional flags/params
Expand All @@ -48,18 +48,19 @@ func (m *Mixin) Uninstall() error {
// This gives us more fine-grained error recovery and handling
var result error
for _, release := range step.Releases {
err = m.delete(release)
err = m.delete(release, step.Namespace)
if err != nil {
result = multierror.Append(result, err)
}
}
return result
}

func (m *Mixin) delete(release string) error {
func (m *Mixin) delete(release string, namespace string) error {
cmd := m.NewCommand("helm3", "uninstall")

cmd.Args = append(cmd.Args, release)
cmd.Args = append(cmd.Args, "--namespace", namespace)

output := &bytes.Buffer{}
cmd.Stdout = io.MultiWriter(m.Out, output)
Expand Down

0 comments on commit 7178153

Please sign in to comment.