-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2,154 changed files
with
396,963 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
defaults: &defaults | ||
working_directory: /go/src/github.com/mstrzele/helm-edit | ||
docker: | ||
- image: circleci/golang:1.8 | ||
|
||
version: 2 | ||
jobs: | ||
lint: | ||
<<: *defaults | ||
steps: | ||
- run: | ||
name: Installing Glide | ||
command: curl https://glide.sh/get | sh | ||
- checkout | ||
- run: go install | ||
- run: | ||
name: Installing gometalinter | ||
command: | | ||
go get -u github.com/alecthomas/gometalinter | ||
gometalinter --install | ||
- run: | ||
name: Running gometalinter | ||
command: gometalinter --deadline=5m --errors $(glide novendor) | ||
build: | ||
<<: *defaults | ||
steps: | ||
- run: | ||
name: Installing Gox | ||
command: go get github.com/mitchellh/gox | ||
- checkout | ||
- run: gox -osarch "darwin/amd64 linux/amd64" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" | ||
|
||
- persist_to_workspace: | ||
root: dist | ||
paths: | ||
- helm-edit_darwin_amd64 | ||
- helm-edit_linux_amd64 | ||
|
||
deploy: | ||
<<: *defaults | ||
steps: | ||
- run: | ||
name: Installing ghr | ||
command: go get -u github.com/tcnksm/ghr | ||
- checkout | ||
|
||
- attach_workspace: | ||
at: dist | ||
|
||
- deploy: | ||
command: ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --replace `git describe --tags` dist/ | ||
|
||
workflows: | ||
version: 2 | ||
lint-build-and-deploy: | ||
jobs: | ||
- lint | ||
- build: | ||
requires: | ||
- lint | ||
- deploy: | ||
requires: | ||
- build | ||
filters: | ||
tags: | ||
only: /v[0-9]+(\.[0-9]+)*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
# Created by https://www.gitignore.io/api/go | ||
|
||
### Go ### | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 | ||
.glide/ | ||
|
||
# End of https://www.gitignore.io/api/go | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Maciej Strzelecki | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
:warning: **Until [kubernetes/helm#2740](https://github.com/kubernetes/helm/pull/2740) won't be merged, opening an editor using this plugin will mess up your terminal. Use `reset` command after `helm edit`.** | ||
|
||
# Helm Edit | ||
|
||
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) | ||
[![CircleCI](https://img.shields.io/circleci/project/github/mstrzele/helm-edit.svg?style=flat-square)](https://circleci.com/gh/mstrzele/helm-edit) | ||
|
||
> Edit a Helm release | ||
This plugin adds `helm edit` command. It opens the editor defined by `HELM_EDITOR`, `KUBE_EDITOR` or `EDITOR` environment variable and allows to edit the values and upgrade a release. | ||
|
||
## Install | ||
|
||
```bash | ||
$ helm plugin install https://github.com/mstrzele/helm-edit | ||
``` | ||
|
||
## Usage | ||
|
||
```bash | ||
$ helm edit smiling-penguin | ||
# Edits the smiling-penguin release | ||
``` | ||
|
||
[![asciicast](https://asciinema.org/a/131663.png)](https://asciinema.org/a/131663) | ||
|
||
## Maintainers | ||
|
||
[@mstrzele](https://github.com/mstrzele) | ||
|
||
## Contribute | ||
|
||
PRs accepted. | ||
|
||
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification. | ||
|
||
## License | ||
|
||
[MIT](LICENSE) © 2017 Maciej Strzelecki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"io/ioutil" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"k8s.io/helm/pkg/chartutil" | ||
"k8s.io/helm/pkg/helm" | ||
"k8s.io/helm/pkg/proto/hapi/release" | ||
) | ||
|
||
type editCmd struct { | ||
release string | ||
out io.Writer | ||
client helm.Interface | ||
allValues bool | ||
editor string | ||
timeout int64 | ||
wait bool | ||
} | ||
|
||
func newEditCmd(client helm.Interface, out io.Writer) *cobra.Command { | ||
|
||
edit := &editCmd{ | ||
out: out, | ||
client: client, | ||
} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "edit [flags] RELEASE", | ||
Short: fmt.Sprintf("edit a release"), | ||
PreRunE: setupConnection, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) != 1 { | ||
return fmt.Errorf("This command neeeds 1 argument: release name") | ||
} | ||
|
||
edit.release = args[0] | ||
edit.client = ensureHelmClient(edit.client) | ||
edit.editor = os.ExpandEnv(edit.editor) | ||
|
||
return edit.run() | ||
}, | ||
} | ||
|
||
f := cmd.Flags() | ||
f.BoolVarP(&edit.allValues, "all", "a", false, "edit all (computed) vals") | ||
f.Int64Var(&edit.timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") | ||
f.BoolVar(&edit.wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout") | ||
f.StringVarP(&edit.editor, "editor", "e", "$EDITOR", "name of the editor") | ||
|
||
return cmd | ||
} | ||
|
||
func (e *editCmd) vals(rel *release.Release) (string, error) { | ||
if e.allValues { | ||
cfg, err := chartutil.CoalesceValues(rel.Chart, rel.Config) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return cfg.YAML() | ||
} else { | ||
return rel.Config.Raw, nil | ||
} | ||
} | ||
|
||
func (e *editCmd) run() error { | ||
res, err := e.client.ReleaseContent(e.release) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
tmpfile, err := ioutil.TempFile(os.TempDir(), fmt.Sprintf("helm-edit-%s", res.Release.Name)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
defer os.Remove(tmpfile.Name()) | ||
|
||
vals, err := e.vals(res.Release) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
tmpfile.WriteString(vals) | ||
|
||
if err := tmpfile.Close(); err != nil { | ||
return err | ||
} | ||
|
||
cmd := exec.Command(e.editor, tmpfile.Name()) | ||
cmd.Stdin = os.Stdin | ||
cmd.Stdout = e.out | ||
cmd.Stderr = e.out | ||
if err := cmd.Run(); err != nil { | ||
return err | ||
} | ||
|
||
rawVals, err := ioutil.ReadFile(tmpfile.Name()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if vals != string(rawVals) { | ||
_, err := e.client.UpdateReleaseFromChart( | ||
res.Release.Name, | ||
res.Release.Chart, | ||
helm.UpdateValueOverrides(rawVals), | ||
helm.UpgradeTimeout(e.timeout), | ||
helm.UpgradeWait(e.wait)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// TODO: print release | ||
|
||
fmt.Fprintf(e.out, "Release %q has been edited. Happy Helming!\n", e.release) | ||
|
||
// TODO: print the status like status command does | ||
} | ||
|
||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package: github.com/mstrzele/helm-edit | ||
import: | ||
- package: github.com/spf13/cobra | ||
- package: k8s.io/helm | ||
version: ~2.5.1 | ||
subpackages: | ||
- pkg/chartutil | ||
- pkg/helm | ||
- pkg/helm/environment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
|
||
set -euf -o pipefail | ||
|
||
HELM_EDIT_VERSION=${HELM_EDIT_VERSION:-"0.1.0"} | ||
|
||
file="${HELM_PLUGIN_DIR:-"$(helm home)/plugins/helm-edit"}/helm-edit" | ||
os=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
url="https://github.com/mstrzele/helm-edit/releases/download/v${HELM_EDIT_VERSION}/helm-edit_${os}_amd64" | ||
|
||
if command -v wget; then | ||
wget -O "${file}" "${url}" | ||
elif command -v curl; then | ||
curl -o "${file}" "${url}" | ||
fi | ||
|
||
chmod +x "${file}" |
Oops, something went wrong.