Skip to content

Commit

Permalink
Merge pull request #150 from chroju/develop
Browse files Browse the repository at this point in the history
v0.4.0 release
  • Loading branch information
chroju authored Nov 23, 2022
2 parents dd46c8c + 28882d0 commit 463cb74
Show file tree
Hide file tree
Showing 18 changed files with 213 additions and 155 deletions.
7 changes: 5 additions & 2 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
interval: "weekly"
day: "friday"
time: "18:00"
timezone: "Asia/Tokyo"
assignees:
- "chroju"
target-branch: "develop"
target-branch: "main"
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: "1.16.0"
go-version: "1.19.0"
- name: Test all
env:
GO111MODULE: on
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: "1.16"
go-version: "1.19"
- name: Run goreleaser
uses: goreleaser/goreleaser-action@v2
env:
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# CHANGELOG

## 0.4.0 (2022/11/23)

### ENHANCEMENTS

* `set` command support `--kms-key-id` flag to specify a KMS key ID.

### BUG FIXES

* Fix the issue that `get` command fails when the specified key is not found.
* Fix the issue with error message output to standard out.

## 0.3.2 (2021/04/16)

### ENHANCEMENTS
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BINARY_NAME=parade

.PHONY: install test lint crossbuild clean
.PHONY: install test lint build crossbuild clean mod test-coverage

install:
go install
Expand All @@ -14,6 +14,9 @@ lint:
test: lint
go test -v ./...

build:
go build -o bin/$(BINARY_NAME)

crossbuild: test
gox -os="linux darwin windows" -arch="386 amd64" -output "bin/remo_{{.OS}}_{{.Arch}}/{{.Dir}}"

Expand Down
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Install
### Homebrew

```bash
$ brew install chroju/tap/parade
brew install chroju/tap/parade
```

### Download binary
Expand All @@ -25,16 +25,16 @@ Download the latest binary from [here](https://github.com/chroju/parade/releases

If you have set up Go environment, you can also install `parade` with `go get` command.

```
$ go get github.com/chroju/parade
```bash
go get github.com/chroju/parade
```

Authentication
--------------

Parade requires your AWS IAM user authentication. The same authentication method as [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) is available. Tools like [aws-vault](https://github.com/99designs/aws-vault) can be used as well.

```
```bash
# with command line options
$ parade --profile YOUR_PROFILE

Expand All @@ -59,14 +59,15 @@ There are simple 4 sub commands. It is similar to redis-cli.
Search keys and display their types together.

`keys` command supports exact match, forward match, and partial match. It usually searches for exact matches.
```

```bash
$ parade /service1/dev/key1
/service1/dev/key1 Type: String
```

Use `*` as a postfix, the search will be done as a forward match. Furthermore, also use `*` as a prefix, it becomes a partial match. You can't use `*` as a prefix only.

```
```bash
$ parade keys /service1*
/service1/dev/key1 Type: String
/service1/dev/key2 Type: String
Expand All @@ -78,7 +79,7 @@ $ parade keys *prod*

If no argument is given, all keys will be retrieved.

```
```bash
$ parade keys
/service1/dev/key1 Type: String
/service1/dev/key2 Type: String
Expand All @@ -90,14 +91,14 @@ $ parade keys

Display the value of the specified key.

```
```bash
$ parade get /service1/dev/key1
value1
```

You can also do a partial search using `*` as well as the `keys` command.

```
```bash
$ parade get /service1*
/service1/dev/key1 value1
/service1/dev/key2 value2
Expand All @@ -106,7 +107,7 @@ $ parade get /service1*

The `--decrypt` or `-d` option is required to decrypt SecureString.

```
```bash
$ parade get /service1/dev/password
(encrypted)

Expand All @@ -118,28 +119,30 @@ $ parade get /service1/dev/password -d

Set new key and value.

```
```bash
$ parade set /service1/dev/key4 value4
```

If the specified key already exists, you can choose to overwrite it. Use `--force` flag if you want to force overwriting.

```
```bash
$ parade set /service1/dev/key4 value5
WARN: `/service1/dev/key4` already exists.
Overwrite `/service1/dev/key4` (value: value4) ? (Y/n)

$ parade set /service1/dev/key4 value5 --force
```

The value is stored as `String` type by default. It also supports `SecureString` type with the default AWS KMS key and can be specified with the `--encrypt` flag. `StringList` type is not supported.
The value is stored as `String` type by default. It also supports `SecureString` with the `--encrypt` flag. If you don't specify a key ID with `--kms-key-id` flag, uses the default key associated with your AWS account.

`StringList` type is not supported.


### del

Delete key and value. Use `--force` flag if you want to skip the confirmation prompt.

```
```bash
$ parade del /service1/dev/key4
Delete `/service1/dev/key4` (value: value5) ? (Y/n)

Expand Down
31 changes: 14 additions & 17 deletions cmd/del_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"bytes"
"fmt"
"strings"
"testing"

Expand All @@ -14,12 +13,6 @@ const (
)

func Test_delCommand(t *testing.T) {
voidCmd := newDelCommand(
&GlobalOption{
Out: &bytes.Buffer{},
ErrOut: &bytes.Buffer{},
},
)
tests := []struct {
name string
command string
Expand All @@ -44,15 +37,15 @@ func Test_delCommand(t *testing.T) {
{
name: "two args",
command: "dev prod",
wantOutWriter: fmt.Sprintf("Error: accepts 1 arg(s), received 2\n%s%s", voidCmd.UsageString(), usageDelHelp),
wantErrWriter: "",
wantOutWriter: "",
wantErrWriter: "accepts 1 arg(s), received 2",
wantErr: true,
},
{
name: "no args",
command: "",
wantOutWriter: fmt.Sprintf("Error: accepts 1 arg(s), received 0\n%s%s", voidCmd.UsageString(), usageDelHelp),
wantErrWriter: "",
wantOutWriter: "",
wantErrWriter: "accepts 1 arg(s), received 0",
wantErr: true,
},
}
Expand All @@ -74,15 +67,19 @@ func Test_delCommand(t *testing.T) {
cmd.SetArgs(strings.Split(tt.command, " "))
}

if err := cmd.Execute(); (err != nil) != tt.wantErr {
err := cmd.Execute()
if (err != nil) != tt.wantErr {
t.Errorf("get() error = %v, wantErr %v", err, tt.wantErr)
return
}
if gotOutWriter := outWriter.String(); gotOutWriter != tt.wantOutWriter {
t.Errorf("get() = %v, want %v", gotOutWriter, tt.wantOutWriter)
}
if gotErrWriter := errWriter.String(); gotErrWriter != tt.wantErrWriter {
t.Errorf("get() = %v, want %v", gotErrWriter, tt.wantErrWriter)
if err != nil {
if err.Error() != tt.wantErrWriter {
t.Errorf("get() = %v, want %v", err.Error(), tt.wantErrWriter)
}
} else {
if gotOutWriter := outWriter.String(); gotOutWriter != tt.wantOutWriter {
t.Errorf("get() = %v, want %v", gotOutWriter, tt.wantOutWriter)
}
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ func newGetCommand(globalOption *GlobalOption) *cobra.Command {
func (o *getOption) get() error {
resp, err := o.SSMManager.DescribeParameters(o.Query, o.Option)
if err != nil {
if strings.Contains(err.Error(), "ParameterNotFound") {
return nil
}
return fmt.Errorf("%s\n%s", ErrMsgDescribeParameters, err)
}

if o.Option == ssmctl.DescribeOptionEquals {
resp, err := o.SSMManager.GetParameter(o.Query, o.IsDecryption)
if err != nil {
if strings.Contains(err.Error(), "ParameterNotFound") {
return nil
}
return err
}
fmt.Fprintln(o.Out, resp.Value)
Expand Down
31 changes: 14 additions & 17 deletions cmd/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"bytes"
"fmt"
"strings"
"testing"

Expand All @@ -14,12 +13,6 @@ const (
)

func Test_getCommand(t *testing.T) {
voidCmd := newGetCommand(
&GlobalOption{
Out: &bytes.Buffer{},
ErrOut: &bytes.Buffer{},
},
)
tests := []struct {
name string
command string
Expand Down Expand Up @@ -72,15 +65,15 @@ func Test_getCommand(t *testing.T) {
{
name: "two args",
command: "dev prod",
wantOutWriter: fmt.Sprintf("Error: accepts 1 arg(s), received 2\n%s%s", voidCmd.UsageString(), usageGetHelp),
wantErrWriter: "",
wantOutWriter: "",
wantErrWriter: "accepts 1 arg(s), received 2",
wantErr: true,
},
{
name: "no args",
command: "",
wantOutWriter: fmt.Sprintf("Error: accepts 1 arg(s), received 0\n%s%s", voidCmd.UsageString(), usageGetHelp),
wantErrWriter: "",
wantOutWriter: "",
wantErrWriter: "accepts 1 arg(s), received 0",
wantErr: true,
},
}
Expand All @@ -102,15 +95,19 @@ func Test_getCommand(t *testing.T) {
cmd.SetArgs(strings.Split(tt.command, " "))
}

if err := cmd.Execute(); (err != nil) != tt.wantErr {
err := cmd.Execute()
if (err != nil) != tt.wantErr {
t.Errorf("get() error = %v, wantErr %v", err, tt.wantErr)
return
}
if gotOutWriter := outWriter.String(); gotOutWriter != tt.wantOutWriter {
t.Errorf("get() = %v, want %v", gotOutWriter, tt.wantOutWriter)
}
if gotErrWriter := errWriter.String(); gotErrWriter != tt.wantErrWriter {
t.Errorf("get() = %v, want %v", gotErrWriter, tt.wantErrWriter)
if err != nil {
if err.Error() != tt.wantErrWriter {
t.Errorf("get() = %v, want %v", err.Error(), tt.wantErrWriter)
}
} else {
if gotOutWriter := outWriter.String(); gotOutWriter != tt.wantOutWriter {
t.Errorf("get() = %v, want %v", gotOutWriter, tt.wantOutWriter)
}
}
})
}
Expand Down
23 changes: 13 additions & 10 deletions cmd/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"bytes"
"fmt"
"strings"
"testing"

Expand Down Expand Up @@ -73,9 +72,9 @@ func Test_keysCommand(t *testing.T) {
{
name: "one arg for no match",
command: "no_match",
wantOutWriter: fmt.Sprintf("Error: %s\nParameterNotFound\n%s\n\n", ErrMsgDescribeParameters, usageKeys),
wantOutWriter: "",
wantErrWriter: "",
wantErr: true,
wantErr: false,
},
{
name: "no args",
Expand Down Expand Up @@ -103,15 +102,19 @@ func Test_keysCommand(t *testing.T) {
cmd.SetArgs(strings.Split(tt.command, " "))
}

if err := cmd.Execute(); (err != nil) != tt.wantErr {
t.Errorf("keys() error = %v, wantErr %v", err, tt.wantErr)
err := cmd.Execute()
if (err != nil) != tt.wantErr {
t.Errorf("get() error = %v, wantErr %v", err, tt.wantErr)
return
}
if gotOutWriter := outWriter.String(); gotOutWriter != tt.wantOutWriter {
t.Errorf("keys() = %v, want %v", gotOutWriter, tt.wantOutWriter)
}
if gotErrWriter := errWriter.String(); gotErrWriter != tt.wantErrWriter {
t.Errorf("keys() = %v, want %v", gotErrWriter, tt.wantErrWriter)
if err != nil {
if err.Error() != tt.wantErrWriter {
t.Errorf("get() = %v, want %v", err.Error(), tt.wantErrWriter)
}
} else {
if gotOutWriter := outWriter.String(); gotOutWriter != tt.wantOutWriter {
t.Errorf("get() = %v, want %v", gotOutWriter, tt.wantOutWriter)
}
}
})
}
Expand Down
Loading

0 comments on commit 463cb74

Please sign in to comment.