├── .gitignore ├── .github ├── CODEOWNERS └── workflows │ ├── create_issue_on_label.yml │ ├── create_issue.yml │ └── comment_issue.yml ├── plugin.yaml ├── CHANGELOG.md ├── go.mod ├── LICENSE ├── internal ├── ssm.go ├── ssm_test.go ├── template_test.go └── template.go ├── cmd └── main.go ├── Makefile ├── .circleci └── config.yml ├── install-binary.sh ├── README.md └── go.sum /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | bin 3 | _dist 4 | .version 5 | 6 | .vscode/ 7 | *~ 8 | .*.swp 9 | 10 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @lolgab @ljmf00 @andreaTP @rtfpessoa @bmbferreira @DReigada @pedrocodacy 2 | 3 | *.yml @h314to @paulopontesm 4 | 5 | -------------------------------------------------------------------------------- /plugin.yaml: -------------------------------------------------------------------------------- 1 | name: "ssm" 2 | version: "dev" 3 | usage: "Inject AWS SSM parameters into Helm values files" 4 | description: |- 5 | Inject AWS SSM parameters into Helm values files 6 | ignoreFlags: false 7 | useTunnel: false 8 | command: "$HELM_PLUGIN_DIR/helm-ssm" 9 | hooks: 10 | install: "$HELM_PLUGIN_DIR/install-binary.sh" 11 | update: "$HELM_PLUGIN_DIR/install-binary.sh" 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 3.x 4 | 5 | Helm 2 support is dropped and dependencies on its api were removed. This means helm extensions to go templates 6 | are not supported by this plugin, since the helm engine funcMap is now private. The functions from the 7 | [sprig](http://masterminds.github.io/sprig/) are now used instead. 8 | 9 | ## 2.0.x 10 | 11 | **NOTE:** Some initial versions of the 2.0.x cycle were wrongly published and for that reason they should start on 2.0.2, 12 | you can check [GitHub releases](https://github.com/codacy/helm-ssm/releases) for the last release with artifacts attached. 13 | 14 | - Removed `required` field 15 | - Added `default` field. 16 | Now you should explicitly say you want the `default=` (empty string) instead of that being implicit. 17 | - The input file flag `-t` was changed to `-o` -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/codacy/helm-ssm 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/Masterminds/goutils v1.1.0 // indirect 7 | github.com/Masterminds/semver v1.5.0 // indirect 8 | github.com/Masterminds/sprig v2.22.0+incompatible 9 | github.com/aws/aws-sdk-go v1.40.22 10 | github.com/go-sql-driver/mysql v1.5.0 // indirect 11 | github.com/google/go-cmp v0.5.2 // indirect 12 | github.com/google/uuid v1.1.2 // indirect 13 | github.com/huandu/xstrings v1.3.2 // indirect 14 | github.com/imdario/mergo v0.3.11 // indirect 15 | github.com/kr/pretty v0.2.1 // indirect 16 | github.com/mitchellh/copystructure v1.0.0 // indirect 17 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect 18 | github.com/spf13/cobra v1.0.0 19 | github.com/spf13/pflag v1.0.5 // indirect 20 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect 21 | gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect 22 | gotest.tools/v3 v3.0.2 23 | ) 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Codacy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /internal/ssm.go: -------------------------------------------------------------------------------- 1 | package hssm 2 | 3 | import ( 4 | "fmt" 5 | "regexp" 6 | 7 | "github.com/aws/aws-sdk-go/aws/awserr" 8 | "github.com/aws/aws-sdk-go/service/ssm" 9 | "github.com/aws/aws-sdk-go/service/ssm/ssmiface" 10 | ) 11 | 12 | // GetSSMParameter gets a parameter from the AWS Simple Systems Manager service. 13 | func GetSSMParameter(svc ssmiface.SSMAPI, name string, defaultValue *string, decrypt bool) (*string, error) { 14 | regex := "([a-zA-Z0-9\\.\\-_/]*)" 15 | r, _ := regexp.Compile(regex) 16 | match := r.FindString(name) 17 | if match == "" { 18 | return nil, fmt.Errorf("There is an invalid character in the name of the parameter: %s. It should match %s", name, regex) 19 | } 20 | // Create the request to SSM 21 | getParameterInput := &ssm.GetParameterInput{ 22 | Name: &name, 23 | WithDecryption: &decrypt, 24 | } 25 | 26 | // Get the parameter from SSM 27 | param, err := svc.GetParameter(getParameterInput) 28 | // Cast err to awserr.Error to handle specific error codes. 29 | aerr, ok := err.(awserr.Error) 30 | if ok && aerr.Code() == ssm.ErrCodeParameterNotFound { 31 | // Specific error code handling 32 | if defaultValue != nil { 33 | return defaultValue, nil 34 | } 35 | return nil, err 36 | } 37 | if aerr != nil { 38 | return nil, err 39 | } 40 | return param.Parameter.Value, nil 41 | } 42 | -------------------------------------------------------------------------------- /cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | "strings" 8 | 9 | hssm "github.com/codacy/helm-ssm/internal" 10 | "github.com/spf13/cobra" 11 | ) 12 | 13 | var valueFiles valueFilesList 14 | var targetDir string 15 | var profile string 16 | var verbose bool 17 | var dryRun bool 18 | 19 | type valueFilesList []string 20 | 21 | func (v *valueFilesList) String() string { 22 | return fmt.Sprint(*v) 23 | } 24 | 25 | func (v *valueFilesList) Type() string { 26 | return "valueFilesList" 27 | } 28 | 29 | func (v *valueFilesList) Set(value string) error { 30 | for _, filePath := range strings.Split(value, ",") { 31 | *v = append(*v, filePath) 32 | } 33 | return nil 34 | } 35 | 36 | func main() { 37 | cmd := &cobra.Command{ 38 | Use: "ssm [flags]", 39 | Short: "", 40 | RunE: run, 41 | } 42 | 43 | f := cmd.Flags() 44 | f.VarP(&valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)") 45 | f.BoolVarP(&verbose, "verbose", "v", false, "show the computed YAML values file/s") 46 | f.BoolVarP(&dryRun, "dry-run", "d", false, "doesn't replace the file content") 47 | f.StringVarP(&targetDir, "target-dir", "o", "", "dir to output content") 48 | f.StringVarP(&profile, "profile", "p", "", "aws profile to fetch the ssm parameters") 49 | 50 | cmd.MarkFlagRequired("values") 51 | 52 | if err := cmd.Execute(); err != nil { 53 | fmt.Println(err) 54 | os.Exit(1) 55 | } 56 | } 57 | 58 | func run(cmd *cobra.Command, args []string) error { 59 | funcMap := hssm.GetFuncMap(profile) 60 | for _, filePath := range valueFiles { 61 | content, err := hssm.ExecuteTemplate(filePath, funcMap, verbose) 62 | if err != nil { 63 | return err 64 | } 65 | if !dryRun { 66 | write(filePath, targetDir, content) 67 | } 68 | } 69 | return nil 70 | } 71 | 72 | func write(filePath string, targetDir string, content string) error { 73 | if targetDir != "" { 74 | fileName := filepath.Base(filePath) 75 | return hssm.WriteFileD(fileName, targetDir, content) 76 | } 77 | return hssm.WriteFile(filePath, content) 78 | } 79 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | HELM_PLUGIN_DIR ?= $(shell helm env | grep HELM_PLUGINS | cut -d\" -f2)/helm-ssm 2 | HELM_PLUGIN_NAME := helm-ssm 3 | VERSION := $(shell cat .version) 4 | DIST := $(CURDIR)/_dist 5 | LDFLAGS := "-X main.version=${VERSION}" 6 | 7 | .PHONY: install 8 | install: dist 9 | @if [ ! -f .version ] ; then echo "dev" > .version ; fi 10 | mkdir -p $(HELM_PLUGIN_DIR) 11 | @if [ "$$(uname)" = "Darwin" ]; then file="${HELM_PLUGIN_NAME}-macos"; \ 12 | elif [ "$$(uname)" = "Linux" ]; then file="${HELM_PLUGIN_NAME}-linux"; \ 13 | else file="${HELM_PLUGIN_NAME}-windows"; \ 14 | fi; \ 15 | mkdir -p $(DIST)/$$file ; \ 16 | tar -xf $(DIST)/$$file.tgz -C $(DIST)/$$file ; \ 17 | cp -r $(DIST)/$$file/* $(HELM_PLUGIN_DIR) ;\ 18 | rm -rf $(DIST)/$$file 19 | 20 | .PHONY: hookInstall 21 | hookInstall: build 22 | 23 | .PHONY: build 24 | build: 25 | go build -o bin/${HELM_PLUGIN_NAME} -ldflags $(LDFLAGS) ./cmd 26 | 27 | .PHONY: test 28 | test: 29 | go test -v ./internal 30 | 31 | .PHONY: dist 32 | dist: 33 | mkdir -p $(DIST) 34 | sed -i.bak 's/version:.*/version: "'$(VERSION)'"/g' plugin.yaml && rm plugin.yaml.bak 35 | CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${HELM_PLUGIN_NAME} -ldflags $(LDFLAGS) ./cmd 36 | tar -zcvf $(DIST)/${HELM_PLUGIN_NAME}-linux.tgz ${HELM_PLUGIN_NAME} README.md LICENSE plugin.yaml 37 | CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ${HELM_PLUGIN_NAME} -ldflags $(LDFLAGS) ./cmd 38 | tar -zcvf $(DIST)/${HELM_PLUGIN_NAME}-linux-arm.tgz ${HELM_PLUGIN_NAME} README.md LICENSE plugin.yaml 39 | CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ${HELM_PLUGIN_NAME} -ldflags $(LDFLAGS) ./cmd 40 | tar -zcvf $(DIST)/${HELM_PLUGIN_NAME}-macos.tgz ${HELM_PLUGIN_NAME} README.md LICENSE plugin.yaml 41 | CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ${HELM_PLUGIN_NAME} -ldflags $(LDFLAGS) ./cmd 42 | tar -zcvf $(DIST)/${HELM_PLUGIN_NAME}-macos-arm.tgz ${HELM_PLUGIN_NAME} README.md LICENSE plugin.yaml 43 | CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o ${HELM_PLUGIN_NAME}.exe -ldflags $(LDFLAGS) ./cmd 44 | tar -zcvf $(DIST)/${HELM_PLUGIN_NAME}-windows.tgz ${HELM_PLUGIN_NAME}.exe README.md LICENSE plugin.yaml 45 | rm ${HELM_PLUGIN_NAME} 46 | rm ${HELM_PLUGIN_NAME}.exe 47 | -------------------------------------------------------------------------------- /internal/ssm_test.go: -------------------------------------------------------------------------------- 1 | package hssm 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | 7 | "gotest.tools/v3/assert" 8 | 9 | "github.com/aws/aws-sdk-go/aws/awserr" 10 | "github.com/aws/aws-sdk-go/service/ssm" 11 | "github.com/aws/aws-sdk-go/service/ssm/ssmiface" 12 | ) 13 | 14 | var fakeValue = "value" 15 | var fakeOtherValue = "other-value" 16 | var fakeMissingValue = "missing-value" 17 | 18 | type SSMParameter struct { 19 | value *string 20 | defaultValue *string 21 | expectedValue *string 22 | } 23 | 24 | var fakeSSMStore = map[string]SSMParameter{ 25 | "/root/existing-parameter": SSMParameter{&fakeValue, nil, &fakeValue}, 26 | "/root/existing-parameter-with-default": SSMParameter{&fakeValue, &fakeOtherValue, &fakeValue}, 27 | "/root/non-existing-parameter": SSMParameter{nil, &fakeMissingValue, &fakeMissingValue}, 28 | "/root/non-existing-parameter-without-default": SSMParameter{nil, nil, nil}, 29 | } 30 | 31 | type mockSSMClient struct { 32 | ssmiface.SSMAPI 33 | } 34 | 35 | func TestGetSSMParameter(t *testing.T) { 36 | // Setup Test 37 | mockSvc := &mockSSMClient{} 38 | 39 | for k, v := range fakeSSMStore { 40 | expectedValueStr := "nil" 41 | if v.expectedValue != nil { 42 | expectedValueStr = *v.expectedValue 43 | } 44 | t.Logf("Key: %s should have value: %s", k, expectedValueStr) 45 | 46 | value, err := GetSSMParameter(mockSvc, k, v.defaultValue, false) 47 | 48 | assert.Equal(t, v.expectedValue, value) 49 | if v.expectedValue == nil { 50 | assert.Error(t, err, "ParameterNotFound: Parameter does not exist in SSM") 51 | } 52 | } 53 | } 54 | 55 | func TestGetSSMParameterInvalidChar(t *testing.T) { 56 | key := "&%&/root/parameter5!$%&$&" 57 | t.Logf("Key with invalid characters should be handled") 58 | // Setup Test 59 | mockSvc := &mockSSMClient{} 60 | _, err := GetSSMParameter(mockSvc, key, nil, false) 61 | assert.Error(t, err, "There is an invalid character in the name of the parameter: &%&/root/parameter5!$%&$&. It should match ([a-zA-Z0-9\\.\\-_/]*)") 62 | } 63 | 64 | // GetParameter is a mock for the SSM client 65 | func (m *mockSSMClient) GetParameter(input *ssm.GetParameterInput) (*ssm.GetParameterOutput, error) { 66 | parameterArn := "arn:::::" 67 | parameterLastModifiedDate := time.Now() 68 | parameterType := "String" 69 | parameterValue := fakeSSMStore[*input.Name] 70 | var parameterVersion int64 = 1 71 | 72 | if parameterValue.value == nil { 73 | return nil, awserr.New("ParameterNotFound", "Parameter does not exist in SSM", nil) 74 | } 75 | 76 | parameter := ssm.Parameter{ 77 | ARN: ¶meterArn, 78 | LastModifiedDate: ¶meterLastModifiedDate, 79 | Name: input.Name, 80 | Type: ¶meterType, 81 | Value: parameterValue.value, 82 | Version: ¶meterVersion, 83 | } 84 | getParameterOutput := &ssm.GetParameterOutput{ 85 | Parameter: ¶meter, 86 | } 87 | 88 | return getParameterOutput, nil 89 | } 90 | -------------------------------------------------------------------------------- /internal/template_test.go: -------------------------------------------------------------------------------- 1 | package hssm 2 | 3 | import ( 4 | "io/ioutil" 5 | "syscall" 6 | "testing" 7 | "text/template" 8 | 9 | "github.com/Masterminds/sprig" 10 | ) 11 | 12 | func createTempFile() (string, error) { 13 | file, err := ioutil.TempFile("", "") 14 | if err != nil { 15 | return "", err 16 | } 17 | return file.Name(), nil 18 | } 19 | 20 | func TestExecuteTemplate(t *testing.T) { 21 | templateContent := "example: {{ and true false }}" 22 | expectedOutput := "example: false" 23 | t.Logf("Template with content: %s , should out put a file with content: %s", templateContent, expectedOutput) 24 | 25 | templateFilePath, err := createTempFile() 26 | if err != nil { 27 | panic(err) 28 | } 29 | defer syscall.Unlink(templateFilePath) 30 | ioutil.WriteFile(templateFilePath, []byte(templateContent), 0644) 31 | content, err := ExecuteTemplate(templateFilePath, template.FuncMap{}, false) 32 | if content != expectedOutput { 33 | t.Errorf("Expected content \"%s\". Got \"%s\"", expectedOutput, content) 34 | } 35 | } 36 | 37 | func TestWriteFile(t *testing.T) { 38 | templateContent := "write_file_example: true" 39 | expectedOutput := "write_file_example: true" 40 | t.Logf("Template with content: %s , should out put a file with content: %s", templateContent, expectedOutput) 41 | 42 | templateFilePath, err := createTempFile() 43 | if err != nil { 44 | panic(err) 45 | } 46 | WriteFile(templateFilePath, templateContent) 47 | fileContent, err := ioutil.ReadFile(templateFilePath) 48 | if err != nil { 49 | panic(err) 50 | } 51 | content := string(fileContent) 52 | if content != expectedOutput { 53 | t.Errorf("Expected file with content \"%s\". Got \"%s\"", expectedOutput, content) 54 | } 55 | } 56 | func TestFailExecuteTemplate(t *testing.T) { 57 | t.Logf("Non existing template should return \"no such file or directory\" error.") 58 | _, err := ExecuteTemplate("", template.FuncMap{}, false) 59 | if err == nil { 60 | t.Error("Should fail with \"no such file or directory\"") 61 | } 62 | } 63 | 64 | func TestSsmFunctionExistsInFuncMap(t *testing.T) { 65 | t.Logf("\"ssm\" function should exist in function map.") 66 | funcMap := GetFuncMap("") 67 | keys := make([]string, len(funcMap)) 68 | for k := range funcMap { 69 | keys = append(keys, k) 70 | } 71 | if _, exists := funcMap["ssm"]; !exists { 72 | t.Errorf("Expected \"ssm\" function in function map. Got the following functions: %s", keys) 73 | } 74 | } 75 | 76 | func TestSprigFunctionsExistInFuncMap(t *testing.T) { 77 | t.Logf("\"quote\" function (from sprig) should exist in function map.") 78 | funcMap := GetFuncMap("") 79 | keys := make([]string, len(funcMap)) 80 | for k := range funcMap { 81 | keys = append(keys, k) 82 | } 83 | 84 | if _, exists := funcMap["quote"]; !exists { 85 | t.Errorf("Expected \"quote\" function in function map. Got the following functions: %s", keys) 86 | } 87 | 88 | t.Logf("number of functions in function map minus custom functions should match those in sprig") 89 | if len(funcMap)-1 != len(sprig.GenericFuncMap()) { 90 | t.Errorf("Expected function map to include all sprig functions. Got the following functions: %s", keys) 91 | } 92 | } 93 | 94 | func TestResolveSSMParameter(t *testing.T) { 95 | t.Logf("TODO") 96 | } 97 | 98 | func TestHandleOptions(t *testing.T) { 99 | t.Logf("TODO") 100 | } 101 | -------------------------------------------------------------------------------- /.github/workflows/create_issue_on_label.yml: -------------------------------------------------------------------------------- 1 | name: Create issue on Jira when labeled with JIRA_ISSUE_LABEL 2 | 3 | on: 4 | issues: 5 | types: [labeled] 6 | 7 | jobs: 8 | jira: 9 | env: 10 | JIRA_ISSUE_LABEL: ${{ secrets.JIRA_ISSUE_LABEL }} 11 | runs-on: ubuntu-latest 12 | steps: 13 | 14 | - name: Start workflow if GitHub issue is tagged with JIRA_ISSUE_LABEL 15 | if: github.event.label.name == env.JIRA_ISSUE_LABEL 16 | run: echo "Starting workflow" 17 | 18 | - name: Jira Login 19 | if: github.event.label.name == env.JIRA_ISSUE_LABEL 20 | id: login 21 | uses: atlassian/gajira-login@v2.0.0 22 | env: 23 | JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} 24 | JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} 25 | JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} 26 | 27 | - name: Jira Create issue 28 | if: github.event.label.name == env.JIRA_ISSUE_LABEL 29 | id: create_jira_issue 30 | uses: atlassian/gajira-create@v2.0.1 31 | with: 32 | project: ${{ secrets.JIRA_PROJECT }} 33 | issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} 34 | summary: "[GH#${{ github.event.issue.number }}] ${{ github.event.issue.title }}" 35 | description: | 36 | ${{ github.event.issue.body }} 37 | ---- 38 | {panel} 39 | _[Github permalink |${{ github.event.issue.html_url }}]_ 40 | {panel} 41 | 42 | - name: Update Jira issue if JIRA_UPDATE_ISSUE_BODY is defined 43 | if: github.event.label.name == env.JIRA_ISSUE_LABEL && env.JIRA_UPDATE_ISSUE_BODY != '' 44 | env: 45 | JIRA_UPDATE_ISSUE_BODY: ${{ secrets.JIRA_UPDATE_ISSUE_BODY }} 46 | run: > 47 | curl 48 | -u ${{ secrets.JIRA_USER_EMAIL }}:${{ secrets.JIRA_API_TOKEN }} 49 | -X PUT 50 | -H 'Content-Type: application/json' 51 | -d '${{ env.JIRA_UPDATE_ISSUE_BODY }}' 52 | ${{ secrets.JIRA_BASE_URL }}/rest/api/2/issue/${{ steps.create_jira_issue.outputs.issue }} 53 | 54 | - name: Change Title 55 | if: github.event.label.name == env.JIRA_ISSUE_LABEL 56 | uses: actions/github-script@v2.0.0 57 | env: 58 | JIRA_ISSUE_NUMBER: ${{ steps.create_jira_issue.outputs.issue }} 59 | GITHUB_ORIGINAL_TITLE: ${{ github.event.issue.title }} 60 | with: 61 | github-token: ${{secrets.GITHUB_TOKEN}} 62 | script: | 63 | const newTitle = `[${process.env.JIRA_ISSUE_NUMBER}] ${process.env.GITHUB_ORIGINAL_TITLE}` 64 | github.issues.update({ 65 | issue_number: context.issue.number, 66 | owner: context.repo.owner, 67 | repo: context.repo.repo, 68 | title: newTitle 69 | }) 70 | 71 | - name: Add comment after sync 72 | if: github.event.label.name == env.JIRA_ISSUE_LABEL 73 | uses: actions/github-script@v2.0.0 74 | with: 75 | github-token: ${{secrets.GITHUB_TOKEN}} 76 | script: | 77 | github.issues.createComment({ 78 | issue_number: context.issue.number, 79 | owner: context.repo.owner, 80 | repo: context.repo.repo, 81 | body: 'Internal ticket created : [${{ steps.create_jira_issue.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create_jira_issue.outputs.issue }})' 82 | }) 83 | -------------------------------------------------------------------------------- /.github/workflows/create_issue.yml: -------------------------------------------------------------------------------- 1 | name: Create issue on Jira 2 | 3 | on: 4 | issues: 5 | types: [opened] 6 | 7 | jobs: 8 | jira: 9 | env: 10 | JIRA_CREATE_ISSUE_AUTO: ${{ secrets.JIRA_CREATE_ISSUE_AUTO }} 11 | runs-on: ubuntu-latest 12 | steps: 13 | 14 | - name: Start workflow if JIRA_CREATE_ISSUE_AUTO is enabled 15 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' 16 | run: echo "Starting workflow" 17 | 18 | - name: Jira Login 19 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' 20 | id: login 21 | uses: atlassian/gajira-login@v2.0.0 22 | env: 23 | JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} 24 | JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} 25 | JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} 26 | 27 | - name: Jira Create issue 28 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' 29 | id: create_jira_issue 30 | uses: atlassian/gajira-create@v2.0.1 31 | with: 32 | project: ${{ secrets.JIRA_PROJECT }} 33 | issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} 34 | summary: "[GH#${{ github.event.issue.number }}] ${{ github.event.issue.title }}" 35 | description: | 36 | ${{ github.event.issue.body }} 37 | ---- 38 | {panel} 39 | _[Github permalink |${{ github.event.issue.html_url }}]_ 40 | {panel} 41 | 42 | - name: Update Jira issue if JIRA_UPDATE_ISSUE_BODY is defined 43 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' && env.JIRA_UPDATE_ISSUE_BODY != '' 44 | env: 45 | JIRA_UPDATE_ISSUE_BODY: ${{ secrets.JIRA_UPDATE_ISSUE_BODY }} 46 | run: > 47 | curl 48 | -u ${{ secrets.JIRA_USER_EMAIL }}:${{ secrets.JIRA_API_TOKEN }} 49 | -X PUT 50 | -H 'Content-Type: application/json' 51 | -d '${{ env.JIRA_UPDATE_ISSUE_BODY }}' 52 | ${{ secrets.JIRA_BASE_URL }}/rest/api/2/issue/${{ steps.create_jira_issue.outputs.issue }} 53 | 54 | - name: Update GitHub issue 55 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' 56 | uses: actions/github-script@v2.0.0 57 | env: 58 | JIRA_ISSUE_NUMBER: ${{ steps.create_jira_issue.outputs.issue }} 59 | GITHUB_ORIGINAL_TITLE: ${{ github.event.issue.title }} 60 | JIRA_ISSUE_LABEL: ${{ secrets.JIRA_ISSUE_LABEL }} 61 | with: 62 | github-token: ${{secrets.GITHUB_TOKEN}} 63 | script: | 64 | const newTitle = `[${process.env.JIRA_ISSUE_NUMBER}] ${process.env.GITHUB_ORIGINAL_TITLE}` 65 | github.issues.update({ 66 | issue_number: context.issue.number, 67 | owner: context.repo.owner, 68 | repo: context.repo.repo, 69 | title: newTitle 70 | }) 71 | github.issues.addLabels({ 72 | issue_number: context.issue.number, 73 | owner: context.repo.owner, 74 | repo: context.repo.repo, 75 | labels: [process.env.JIRA_ISSUE_LABEL] 76 | }) 77 | 78 | 79 | - name: Add comment after sync 80 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' 81 | uses: actions/github-script@v2.0.0 82 | with: 83 | github-token: ${{secrets.GITHUB_TOKEN}} 84 | script: | 85 | github.issues.createComment({ 86 | issue_number: context.issue.number, 87 | owner: context.repo.owner, 88 | repo: context.repo.repo, 89 | body: 'Internal ticket created : [${{ steps.create_jira_issue.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create_jira_issue.outputs.issue }})' 90 | }) 91 | -------------------------------------------------------------------------------- /internal/template.go: -------------------------------------------------------------------------------- 1 | package hssm 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io/ioutil" 7 | "os" 8 | "strings" 9 | "text/template" 10 | 11 | "github.com/Masterminds/sprig" 12 | "github.com/aws/aws-sdk-go/aws" 13 | "github.com/aws/aws-sdk-go/aws/session" 14 | "github.com/aws/aws-sdk-go/service/ssm" 15 | "github.com/aws/aws-sdk-go/service/ssm/ssmiface" 16 | ) 17 | 18 | // WriteFileD dumps a given content on the file with path `targetDir/fileName`. 19 | func WriteFileD(fileName string, targetDir string, content string) error { 20 | targetFilePath := targetDir + "/" + fileName 21 | _ = os.Mkdir(targetDir, os.ModePerm) 22 | return WriteFile(targetFilePath, content) 23 | } 24 | 25 | // WriteFile dumps a given content on the file with path `targetFilePath`. 26 | func WriteFile(targetFilePath string, content string) error { 27 | return ioutil.WriteFile(targetFilePath, []byte(content), 0777) 28 | } 29 | 30 | // ExecuteTemplate loads a template file, executes is against a given function map and writes the output 31 | func ExecuteTemplate(sourceFilePath string, funcMap template.FuncMap, verbose bool) (string, error) { 32 | fileContent, err := ioutil.ReadFile(sourceFilePath) 33 | if err != nil { 34 | return "", err 35 | } 36 | t := template.New("ssmtpl").Funcs(funcMap) 37 | if _, err := t.Parse(string(fileContent)); err != nil { 38 | return "", err 39 | } 40 | var buf bytes.Buffer 41 | vals := map[string]interface{}{} 42 | if err := t.Execute(&buf, vals); err != nil { 43 | return "", err 44 | } 45 | if verbose { 46 | fmt.Println(string(buf.Bytes())) 47 | } 48 | return buf.String(), nil 49 | } 50 | 51 | // GetFuncMap builds the relevant function map to helm_ssm 52 | func GetFuncMap(profile string) template.FuncMap { 53 | // Clone the func map because we are adding context-specific functions. 54 | var funcMap template.FuncMap = map[string]interface{}{} 55 | for k, v := range sprig.GenericFuncMap() { 56 | funcMap[k] = v 57 | } 58 | 59 | awsSession := newAWSSession(profile) 60 | funcMap["ssm"] = func(ssmPath string, options ...string) (string, error) { 61 | optStr, err := resolveSSMParameter(awsSession, ssmPath, options) 62 | str := "" 63 | if optStr != nil { 64 | str = *optStr 65 | } 66 | return str, err 67 | } 68 | return funcMap 69 | } 70 | 71 | func resolveSSMParameter(session *session.Session, ssmPath string, options []string) (*string, error) { 72 | opts, err := handleOptions(options) 73 | if err != nil { 74 | return nil, err 75 | } 76 | 77 | var defaultValue *string 78 | if optDefaultValue, exists := opts["default"]; exists { 79 | defaultValue = &optDefaultValue 80 | } 81 | 82 | var svc ssmiface.SSMAPI 83 | if region, exists := opts["region"]; exists { 84 | svc = ssm.New(session, aws.NewConfig().WithRegion(region)) 85 | } else { 86 | svc = ssm.New(session) 87 | } 88 | 89 | return GetSSMParameter(svc, opts["prefix"]+ssmPath, defaultValue, true) 90 | } 91 | 92 | func handleOptions(options []string) (map[string]string, error) { 93 | validOptions := []string{ 94 | "required", 95 | "prefix", 96 | "region", 97 | } 98 | opts := map[string]string{} 99 | for _, o := range options { 100 | split := strings.Split(o, "=") 101 | if len(split) != 2 { 102 | return nil, fmt.Errorf("Invalid option: %s. Valid options: %s", o, validOptions) 103 | } 104 | opts[split[0]] = split[1] 105 | } 106 | if _, exists := opts["required"]; !exists { 107 | opts["required"] = "true" 108 | } 109 | if _, exists := opts["prefix"]; !exists { 110 | opts["prefix"] = "" 111 | } 112 | return opts, nil 113 | } 114 | 115 | func newAWSSession(profile string) *session.Session { 116 | // Specify profile for config and region for requests 117 | session := session.Must(session.NewSessionWithOptions(session.Options{ 118 | SharedConfigState: session.SharedConfigEnable, 119 | Profile: profile, 120 | })) 121 | return session 122 | } 123 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | orbs: 4 | codacy: codacy/base@5.0.4 5 | 6 | jobs: 7 | build: # runs not using Workflows must have a `build` job as entry point 8 | docker: # run the steps with Docker 9 | # CircleCI Go images available at: https://hub.docker.com/r/circleci/golang/ 10 | - image: circleci/golang:1.15 # 11 | 12 | # directory where steps are run. Path must conform to the Go Workspace requirements 13 | working_directory: ~/workdir/helm-ssm 14 | 15 | environment: # environment variables for the build itself 16 | TEST_RESULTS: /tmp/test-results # path to where test results will be saved 17 | 18 | steps: # steps that comprise the `build` job 19 | - attach_workspace: 20 | at: ~/workdir/helm-ssm 21 | 22 | - run: mkdir -p $TEST_RESULTS # create the test results directory 23 | 24 | - restore_cache: # restores saved cache if no changes are detected since last run 25 | # Read about caching dependencies: https://circleci.com/docs/2.0/caching/ 26 | keys: 27 | - v2020-09-pkg-cache 28 | 29 | - run: go get github.com/jstemmer/go-junit-report 30 | 31 | - run: 32 | name: Run unit tests 33 | # Store the results of our tests in the $TEST_RESULTS directory 34 | command: | 35 | make test | go-junit-report >> ${TEST_RESULTS}/go-test-report.xml 36 | 37 | - run: make dist # pull and build dependencies for the project 38 | 39 | - persist_to_workspace: 40 | root: ~/workdir/helm-ssm 41 | paths: 42 | - '*' 43 | 44 | - save_cache: # Store cache in the /go/pkg directory 45 | key: v1-pkg-cache 46 | paths: 47 | - "/go/pkg" 48 | 49 | - store_artifacts: # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/ 50 | path: /tmp/test-results 51 | destination: raw-test-output 52 | 53 | - store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/ 54 | path: /tmp/test-results 55 | 56 | publish: # runs not using Workflows must have a `build` job as entry point 57 | docker: # run the steps with Docker 58 | # CircleCI Go images available at: https://hub.docker.com/r/circleci/golang/ 59 | - image: circleci/golang:1.15 # 60 | 61 | # directory where steps are run. Path must conform to the Go Workspace requirements 62 | working_directory: ~/workdir/helm-ssm 63 | steps: # steps that comprise the `build` job 64 | - attach_workspace: 65 | at: ~/workdir/helm-ssm 66 | 67 | - run: 68 | name: "Publish Release on GitHub" 69 | command: | 70 | export VERSION="$(cat .version)" 71 | echo "Publishing version ${VERSION}" 72 | ls -lisah ./_dist/ 73 | 74 | curl -L https://github.com/cli/cli/releases/download/v1.1.0/gh_1.1.0_linux_amd64.deb -o gh.deb 75 | sudo dpkg -i gh.deb 76 | echo ${GITHUB_TOKEN} | gh auth login --with-token 77 | gh config set prompt disabled 78 | gh release create ${VERSION} ./_dist/*.tgz 79 | 80 | 81 | workflows: 82 | version: 2 83 | ci: 84 | jobs: 85 | - codacy/checkout_and_version 86 | - build: 87 | requires: 88 | - codacy/checkout_and_version 89 | - codacy/tag_version: 90 | name: tag_version 91 | context: CodacyAWS 92 | requires: 93 | - build 94 | filters: 95 | branches: 96 | only: 97 | - master 98 | - publish: 99 | context: CodacyGitHub 100 | requires: 101 | - tag_version 102 | - codacy/tag_version: 103 | name: tag_version_latest 104 | context: CodacyAWS 105 | version: latest 106 | force: true 107 | requires: 108 | - publish -------------------------------------------------------------------------------- /install-binary.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [ $# -gt 0 ]; do 3 | case "$1" in 4 | --version*|-v*) 5 | if [[ "$1" != *=* ]]; then shift; fi 6 | VERSION="${1#*=}" 7 | ;; 8 | *) 9 | >&2 printf "Error: Invalid argument\n" 10 | exit 1 11 | ;; 12 | esac 13 | shift 14 | done 15 | if [ -z $VERSION ]; then 16 | VERSION='3.2.0' 17 | fi 18 | PROJECT_NAME="helm-ssm" 19 | PROJECT_GH="seripap/$PROJECT_NAME" 20 | eval $(helm env) 21 | 22 | if [[ $SKIP_BIN_INSTALL == "1" ]]; then 23 | echo "Skipping binary install" 24 | exit 25 | fi 26 | 27 | # initArch discovers the architecture for this system. 28 | initArch() { 29 | ARCH=$(uname -m) 30 | case $ARCH in 31 | armv5*) ARCH="armv5";; 32 | armv6*) ARCH="armv6";; 33 | armv7*) ARCH="armv7";; 34 | aarch64) ARCH="arm64";; 35 | x86) ARCH="386";; 36 | x86_64) ARCH="amd64";; 37 | i686) ARCH="386";; 38 | i386) ARCH="386";; 39 | esac 40 | } 41 | 42 | # initOS discovers the operating system for this system. 43 | initOS() { 44 | OS=$(echo $(uname)|tr '[:upper:]' '[:lower:]') 45 | case "$OS" in 46 | # Msys support 47 | msys*) OS='windows';; 48 | # Minimalist GNU for Windows 49 | mingw*) OS='windows';; 50 | darwin) OS='macos';; 51 | esac 52 | } 53 | 54 | # verifySupported checks that the os/arch combination is supported for 55 | # binary builds. 56 | verifySupported() { 57 | local supported="linux-amd64\nmacos-amd64\nwindows-amd64\linux-arm-armv5\linux-arm-armv6\linux-arm-armv7\linux-arm-arm64\macos-arm64" 58 | if ! echo "${supported}" | grep -q "${OS}-${ARCH}"; then 59 | echo "No prebuild binary for ${OS}-${ARCH}." 60 | exit 1 61 | fi 62 | 63 | if ! type "curl" > /dev/null && ! type "wget" > /dev/null; then 64 | echo "Either curl or wget is required" 65 | exit 1 66 | fi 67 | } 68 | 69 | # getDownloadURL checks the latest available version. 70 | getDownloadURL() { 71 | # Use the GitHub API to find the latest version for this project. 72 | if [VERSION='latest']; then 73 | local latest_url="https://api.github.com/repos/$PROJECT_GH/releases/$VERSION" 74 | echo $latest_url 75 | if type "curl" > /dev/null; then 76 | DOWNLOAD_URL=$(curl -s $latest_url | sort -r | grep $OS -m3 | awk '/"browser_download_url":/{gsub( /[,"]/,"", $2); print $2}') 77 | elif type "wget" > /dev/null; then 78 | DOWNLOAD_URL=$(wget -q -O - $latest_url | awk '/"browser_download_url":/{gsub( /[,"]/,"", $2); print $2}') 79 | fi 80 | else 81 | DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/$VERSION/helm-ssm-$OS.tgz" 82 | fi 83 | } 84 | 85 | # downloadFile downloads the latest binary package and also the checksum 86 | # for that binary. 87 | downloadFile() { 88 | PLUGIN_TMP_FILE="/tmp/${PROJECT_NAME}.tgz" 89 | echo "Downloading $DOWNLOAD_URL" 90 | if type "curl" > /dev/null; then 91 | curl -L "$DOWNLOAD_URL" -o "$PLUGIN_TMP_FILE" 92 | elif type "wget" > /dev/null; then 93 | wget -q -O "$PLUGIN_TMP_FILE" "$DOWNLOAD_URL" 94 | fi 95 | } 96 | 97 | # installFile verifies the SHA256 for the file, then unpacks and 98 | # installs it. 99 | installFile() { 100 | HELM_TMP="/tmp/$PROJECT_NAME" 101 | mkdir -p "$HELM_TMP" 102 | tar xf "$PLUGIN_TMP_FILE" -C "$HELM_TMP" 103 | echo "$HELM_TMP" 104 | HELM_TMP_BIN="$HELM_TMP/helm-ssm" 105 | echo "Preparing to install into ${HELM_PLUGINS}" 106 | # Use * to also copy the file withe the exe suffix on Windows 107 | cp "$HELM_TMP_BIN" "$HELM_PLUGINS/helm-ssm" 108 | } 109 | 110 | # fail_trap is executed if an error occurs. 111 | fail_trap() { 112 | result=$? 113 | if [ "$result" != "0" ]; then 114 | echo "Failed to install $PROJECT_NAME" 115 | echo "For support, go to https://github.com/codacy/helm-ssm." 116 | fi 117 | exit $result 118 | } 119 | 120 | # testVersion tests the installed client to make sure it is working. 121 | testVersion() { 122 | set +e 123 | echo "$PROJECT_NAME installed into $HELM_PLUGINS/$PROJECT_NAME" 124 | # To avoid to keep track of the Windows suffix, 125 | # call the plugin assuming it is in the PATH 126 | PATH=$PATH:$HELM_PLUGINS/$PROJECT_NAME 127 | helm-ssm -h 128 | set -e 129 | } 130 | 131 | # Execution 132 | 133 | #Stop execution on any error 134 | trap "fail_trap" EXIT 135 | set -e 136 | initArch 137 | initOS 138 | verifySupported 139 | getDownloadURL 140 | downloadFile 141 | installFile 142 | testVersion 143 | -------------------------------------------------------------------------------- /.github/workflows/comment_issue.yml: -------------------------------------------------------------------------------- 1 | name: Comment issue on Jira 2 | 3 | on: 4 | issue_comment: 5 | types: [created] 6 | 7 | jobs: 8 | jira: 9 | env: 10 | JIRA_CREATE_COMMENT_AUTO: ${{ secrets.JIRA_CREATE_COMMENT_AUTO }} 11 | runs-on: ubuntu-latest 12 | steps: 13 | 14 | - name: Start workflow if JIRA_CREATE_COMMENT_AUTO is enabled 15 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' 16 | run: echo "Starting workflow" 17 | 18 | - name: Check GitHub Issue type 19 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' 20 | id: github_issue_type 21 | uses: actions/github-script@v2.0.0 22 | with: 23 | result-encoding: string 24 | script: | 25 | // An Issue can be a pull request, you can identify pull requests by the pull_request key 26 | const pullRequest = ${{ toJson(github.event.issue.pull_request) }} 27 | if(pullRequest) { 28 | return "pull-request" 29 | } else { 30 | return "issue" 31 | } 32 | 33 | - name: Check if GitHub Issue has JIRA_ISSUE_LABEL 34 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' 35 | id: github_issue_has_jira_issue_label 36 | uses: actions/github-script@v2.0.0 37 | env: 38 | JIRA_ISSUE_LABEL: ${{ secrets.JIRA_ISSUE_LABEL }} 39 | with: 40 | result-encoding: string 41 | script: | 42 | const labels = ${{ toJson(github.event.issue.labels) }} 43 | if(labels.find(label => label.name == process.env.JIRA_ISSUE_LABEL)) { 44 | return "true" 45 | } else { 46 | return "false" 47 | } 48 | 49 | - name: Continue workflow only for Issues (not Pull Requests) tagged with JIRA_ISSUE_LABEL 50 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' 51 | env: 52 | GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} 53 | GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} 54 | run: echo "GitHub Issue is tracked on Jira, eligilbe to be commented" 55 | 56 | - name: Jira Login 57 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' 58 | id: login 59 | uses: atlassian/gajira-login@v2.0.0 60 | env: 61 | GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} 62 | GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} 63 | JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} 64 | JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} 65 | JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} 66 | 67 | - name: Extract Jira number 68 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' 69 | id: extract_jira_number 70 | uses: actions/github-script@v2.0.0 71 | env: 72 | GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} 73 | GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} 74 | JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }} 75 | GITHUB_TITLE: ${{ github.event.issue.title }} 76 | with: 77 | script: | 78 | const jiraTaskRegex = new RegExp(`\\\[(${process.env.JIRA_PROJECT}-[0-9]+?)\\\]`) 79 | return process.env.GITHUB_TITLE.match(jiraTaskRegex)[1] 80 | result-encoding: string 81 | 82 | - name: Jira Add comment on issue 83 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' 84 | id: add_comment_jira_issue 85 | uses: atlassian/gajira-comment@v2.0.2 86 | env: 87 | GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} 88 | GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} 89 | with: 90 | issue: ${{ steps.extract_jira_number.outputs.result }} 91 | comment: | 92 | GitHub Comment : ${{ github.event.comment.user.login }} 93 | {quote}${{ github.event.comment.body }}{quote} 94 | ---- 95 | {panel} 96 | _[Github permalink |${{ github.event.comment.html_url }}]_ 97 | {panel} 98 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Helm SSM Plugin 2 | 3 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d3cd080edd8644e085f2f8adfd43510c)](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=codacy/helm-ssm&utm_campaign=Badge_Grade) 4 | [![CircleCI](https://circleci.com/gh/codacy/helm-ssm.svg?style=svg)](https://circleci.com/gh/codacy/helm-ssm) 5 | 6 | This is a **helm3** plugin to help developers inject values coming from AWS SSM 7 | parameters, on the `values.yaml` file. It also leverages the wonderful [sprig](http://masterminds.github.io/sprig/) 8 | package, thus making all its functions available when parsing. 9 | 10 | Since **helm2 is deprecated** the current version of the plugin only supports helm3. The last version 11 | to support helm2 is [v2.2.1](https://github.com/codacy/helm-ssm/releases/tag/2.2.1). There will be 12 | no further patches or updates to this legacy version. 13 | 14 | ## Usage 15 | 16 | Loads a template file, and writes the output. 17 | 18 | Simply add placeholders like `{{ssm "path" "option1=value1" }}` in your 19 | file, where you want it to be replaced by the plugin. 20 | 21 | Currently the plugin supports the following options: 22 | 23 | - `region=eu-west-1` - to resolve that parameter in a specific region 24 | - `default=some-value` - to give a default **string** value when the ssm parameter is optional. The plugin will throw an error when values are not defined and do not have a default. 25 | - `prefix=/something` - you can use this to specify a given prefix for a parameter without affecting the path. It will be concatenated with the path before resolving. 26 | 27 | ### Values file 28 | 29 | ```yaml 30 | service: 31 | ingress: 32 | enabled: false 33 | hosts: 34 | - service.{{ssm "/exists/subdomain" }} 35 | - service1.{{ssm "/empty/subdomain" "default=codacy.org" }} 36 | - service2.{{ssm "/exists/subdomain" "default=codacy.org" "region=eu-west-1" }} 37 | - service3.{{ssm "/subdomain" "default=codacy.org" "region=eu-west-1" "prefix=/empty" }} 38 | - service4.{{ssm "/securestring" }} 39 | 40 | ``` 41 | 42 | when you do not want a key to be defined, you can use a condition and an empty default value: 43 | 44 | ```yaml 45 | service: 46 | ingress: 47 | enabled: false 48 | hosts: 49 | {{- with $subdomain := (ssm "/exists/subdomain" "default=") }}{{ if $subdomain }} 50 | - service.{{$subdomain}} 51 | {{- end }}{{- end }} 52 | 53 | ``` 54 | 55 | ### Command 56 | 57 | ```sh 58 | $ helm ssm [flags] 59 | ``` 60 | 61 | ### Flags 62 | 63 | ```sh 64 | -d, --dry-run does not replace the file content 65 | -h, --help help for ssm 66 | -p, --profile string aws profile to fetch the ssm parameters 67 | -o, --target-dir string dir to output content 68 | -f, --values valueFilesList specify values in a YAML file (can specify multiple) (default []) 69 | -v, --verbose show the computed YAML values file/s 70 | ``` 71 | 72 | ## Example 73 | 74 | [![asciicast](https://asciinema.org/a/c2zut95zzbiKyk5gJov67bxsP.svg)](https://asciinema.org/a/c2zut95zzbiKyk5gJov67bxsP?t=1) 75 | 76 | ## Install 77 | 78 | Choose the latest version from the releases and install the 79 | appropriate version for your OS as indicated below. 80 | 81 | ```sh 82 | $ helm plugin add https://github.com/codacy/helm-ssm 83 | ``` 84 | 85 | ### Developer (From Source) Install 86 | 87 | If you would like to handle the build yourself, instead of fetching a binary, 88 | this is how we recommend doing it. 89 | 90 | - Make sure you have [Go](http://golang.org) installed. 91 | 92 | - Clone this project 93 | 94 | - In the project directory run 95 | ```sh 96 | $ make install 97 | ``` 98 | 99 | ## What is Codacy 100 | 101 | [Codacy](https://www.codacy.com/) is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews. 102 | 103 | ### Among Codacy’s features 104 | 105 | - Identify new Static Analysis issues 106 | - Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories) 107 | - Auto-comments on Commits and Pull Requests 108 | - Integrations with Slack, HipChat, Jira, YouTrack 109 | - Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories 110 | 111 | Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity. 112 | 113 | Codacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others. 114 | 115 | ## Free for Open Source 116 | 117 | Codacy is free for Open Source projects. 118 | 119 | ## License 120 | 121 | helm-ssm is available under the MIT license. See the LICENSE file for more info. 122 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= 3 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 4 | github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= 5 | github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= 6 | github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= 7 | github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= 8 | github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60= 9 | github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= 10 | github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= 11 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 12 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 13 | github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= 14 | github.com/aws/aws-sdk-go v1.34.30 h1:izATc/E0+HcT5YHmaQVjn7GHCoqaBxn0PGo6Zq5UNFA= 15 | github.com/aws/aws-sdk-go v1.34.30/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= 16 | github.com/aws/aws-sdk-go v1.35.1 h1:dGBUiVpdG6Zho3taAqGJKxuhn+qIrP3OdjfrtqowDyc= 17 | github.com/aws/aws-sdk-go v1.35.1/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= 18 | github.com/aws/aws-sdk-go v1.38.57 h1:Jo6uOnWNbj4jL/8t/XUrHOKm1J6pPcYFhGzda20UcUk= 19 | github.com/aws/aws-sdk-go v1.38.57/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= 20 | github.com/aws/aws-sdk-go v1.40.22 h1:iit4tJ1hjL2GlNCrbE4aJza6jTmvEE2pDTnShct/yyY= 21 | github.com/aws/aws-sdk-go v1.40.22/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= 22 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 23 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 24 | github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= 25 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 26 | github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= 27 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 28 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 29 | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 30 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 31 | github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 32 | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= 33 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 34 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 35 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 36 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 37 | github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= 38 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 39 | github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= 40 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 41 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 42 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 43 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 44 | github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= 45 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 46 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 47 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 48 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 49 | github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 50 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 51 | github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= 52 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 53 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 54 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 55 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 56 | github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= 57 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 58 | github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= 59 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 60 | github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= 61 | github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 62 | github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= 63 | github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 64 | github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 65 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 66 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 67 | github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 68 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 69 | github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= 70 | github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= 71 | github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA= 72 | github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= 73 | github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= 74 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= 75 | github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= 76 | github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= 77 | github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= 78 | github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= 79 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= 80 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 81 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 82 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 83 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 84 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 85 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 86 | github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= 87 | github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 88 | github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= 89 | github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 90 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 91 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 92 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 93 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 94 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 95 | github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= 96 | github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= 97 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 98 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 99 | github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= 100 | github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= 101 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 102 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= 103 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= 104 | github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= 105 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 106 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 107 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 108 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 109 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 110 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 111 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 112 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 113 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 114 | github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= 115 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 116 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 117 | github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 118 | github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 119 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 120 | github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 121 | github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= 122 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 123 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 124 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 125 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 126 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 127 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 128 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 129 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 130 | github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= 131 | github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= 132 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 133 | github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= 134 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 135 | github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= 136 | github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 137 | github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= 138 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 139 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 140 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= 141 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 142 | github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= 143 | github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= 144 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= 145 | github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= 146 | go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 147 | go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 148 | go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= 149 | go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 150 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 151 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 152 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= 153 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 154 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 155 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 156 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 157 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 158 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 159 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 160 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 161 | golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 162 | golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 163 | golang.org/x/net v0.0.0-20200923182212-328152dc79b1 h1:Iu68XRPd67wN4aRGGWwwq6bZo/25jR6uu52l/j2KkUE= 164 | golang.org/x/net v0.0.0-20200923182212-328152dc79b1/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 165 | golang.org/x/net v0.0.0-20200930145003-4acb6c075d10 h1:YfxMZzv3PjGonQYNUaeU2+DhAdqOxerQ30JFB6WgAXo= 166 | golang.org/x/net v0.0.0-20200930145003-4acb6c075d10/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 167 | golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 168 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 169 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 170 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 171 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 172 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 173 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 174 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 175 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 176 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 177 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 178 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 179 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 180 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 181 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 182 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 183 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 184 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 185 | golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= 186 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 187 | golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= 188 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 189 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 190 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 191 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 192 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 193 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 194 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 195 | golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 196 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 197 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 198 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 199 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 200 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 201 | google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 202 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 203 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 204 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 205 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 206 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= 207 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 208 | gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= 209 | gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 210 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= 211 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= 212 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 213 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 214 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 215 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 216 | gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= 217 | gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 218 | gotest.tools/v3 v3.0.2 h1:kG1BFyqVHuQoVQiR1bWGnfz/fmHvvuiSPIV7rvl360E= 219 | gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= 220 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 221 | --------------------------------------------------------------------------------