Skip to content

Commit

Permalink
Bump dependencies & update fmt (gofumpt, yaml)
Browse files Browse the repository at this point in the history
FIx #33
  • Loading branch information
elsesiy committed Dec 18, 2022
1 parent 9f8c09a commit 6b78b92
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 39 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ on:
jobs:
ci_job:
name: test
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
container:
image: golang:1.19
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Test
run: make test
- name: Checkout
uses: actions/checkout@v3
- name: Test
run: make test
36 changes: 18 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ name: release
on:
push:
tags:
- 'v*.*.*'
- "v*.*.*"
jobs:
release_job:
name: goreleaser & krew
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '^1.19'
- name: GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update new version in krew-index
uses: rajatjindal/[email protected]
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "^1.19"
- name: GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update new version in krew-index
uses: rajatjindal/[email protected]
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/elsesiy/kubectl-view-secret
go 1.19

require (
github.com/goccy/go-json v0.9.10
github.com/magiconair/properties v1.8.6
github.com/spf13/cobra v1.5.0
github.com/goccy/go-json v0.10.0
github.com/magiconair/properties v1.8.7
github.com/spf13/cobra v1.6.1
)

require (
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/goccy/go-json v0.9.10 h1:hCeNmprSNLB8B8vQKWl6DpuH0t60oEs+TAk9a7CScKc=
github.com/goccy/go-json v0.9.10/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA=
github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
9 changes: 5 additions & 4 deletions pkg/cmd/view-secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"sort"
Expand Down Expand Up @@ -85,9 +84,11 @@ func NewCmdViewSecret() *cobra.Command {
},
}

cmd.Flags().BoolVarP(&res.decodeAll, "all", "a", res.decodeAll, "if true, decodes all secrets without specifying the individual secret keys")
cmd.Flags().
BoolVarP(&res.decodeAll, "all", "a", res.decodeAll, "if true, decodes all secrets without specifying the individual secret keys")
cmd.Flags().BoolVarP(&res.quiet, "quiet", "q", res.quiet, "if true, suppresses info output")
cmd.Flags().StringVarP(&res.customNamespace, "namespace", "n", res.customNamespace, "override the namespace defined in the current context")
cmd.Flags().
StringVarP(&res.customNamespace, "namespace", "n", res.customNamespace, "override the namespace defined in the current context")
cmd.Flags().StringVarP(&res.customContext, "context", "c", res.customContext, "override the current context")
cmd.Flags().StringVarP(&res.kubeConfig, "kubeconfig", "k", res.kubeConfig, "explicitly provide the kubeconfig to use")

Expand Down Expand Up @@ -144,7 +145,7 @@ func (c *CommandOpts) Retrieve(cmd *cobra.Command) error {
}

if c.quiet {
return ProcessSecret(os.Stdout, ioutil.Discard, secret, c.secretKey, c.decodeAll)
return ProcessSecret(os.Stdout, io.Discard, secret, c.secretKey, c.decodeAll)
}

return ProcessSecret(os.Stdout, os.Stderr, secret, c.secretKey, c.decodeAll)
Expand Down
41 changes: 33 additions & 8 deletions pkg/cmd/view-secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func TestValidate(t *testing.T) {
}
})
}

}

func TestProcessSecret(t *testing.T) {
Expand All @@ -70,12 +69,39 @@ func TestProcessSecret(t *testing.T) {
decodeAll bool
err error
}{
"view-secret <secret>": {secret, []string{"-> TEST_CONN_STR", "-> TEST_PASSWORD", "-> TEST_PASSWORD_2"}, []string{listDescription}, "", false, nil},
"view-secret <secret-single-key>": {secretSingle, []string{"secret"}, []string{fmt.Sprintf(singleKeyDescription, "SINGLE_PASSWORD")}, "", false, nil},
"view-secret test TEST_PASSWORD": {secret, []string{"secret"}, nil, "TEST_PASSWORD", false, nil},
"view-secret test -a": {secret, []string{"", "", "TEST_CONN_STR=mongodb://myDBReader:D1fficultP%[email protected]:27017/?authSource=admin", "TEST_PASSWORD=secret", "TEST_PASSWORD_2=verysecret"}, nil, "", true, nil},
"view-secret test NONE": {secret, nil, nil, "NONE", false, ErrSecretKeyNotFound},
"view-secret <secret-empty>": {secretEmpty, nil, nil, "", false, ErrSecretEmpty},
"view-secret <secret>": {
secret,
[]string{"-> TEST_CONN_STR", "-> TEST_PASSWORD", "-> TEST_PASSWORD_2"},
[]string{listDescription},
"",
false,
nil,
},
"view-secret <secret-single-key>": {
secretSingle,
[]string{"secret"},
[]string{fmt.Sprintf(singleKeyDescription, "SINGLE_PASSWORD")},
"",
false,
nil,
},
"view-secret test TEST_PASSWORD": {secret, []string{"secret"}, nil, "TEST_PASSWORD", false, nil},
"view-secret test -a": {
secret,
[]string{
"",
"",
"TEST_CONN_STR=mongodb://myDBReader:D1fficultP%[email protected]:27017/?authSource=admin",
"TEST_PASSWORD=secret",
"TEST_PASSWORD_2=verysecret",
},
nil,
"",
true,
nil,
},
"view-secret test NONE": {secret, nil, nil, "NONE", false, ErrSecretKeyNotFound},
"view-secret <secret-empty>": {secretEmpty, nil, nil, "", false, ErrSecretEmpty},
}

for name, test := range tests {
Expand Down Expand Up @@ -109,7 +135,6 @@ func TestProcessSecret(t *testing.T) {
t.Errorf("got %v, want %v", gotStdErrArr, test.wantStdErr)
}
}

})
}
}

0 comments on commit 6b78b92

Please sign in to comment.