Skip to content

Commit

Permalink
feat: upgraded to aws-sdk-go-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
bnormington committed Aug 23, 2024
1 parent 14a0f45 commit 26254c2
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 106 deletions.
38 changes: 22 additions & 16 deletions cmd/sm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package cmd
import (
"encoding/json"
"fmt"
"os"
"sort"
"strings"

"github.com/AlecAivazis/survey/v2"
"github.com/GoodwayGroup/gwsm/sm"
"github.com/TylerBrock/colorjson"
"github.com/a8m/djson"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/urfave/cli/v2"
"os"
"sort"
"strings"
)

// truncateString limits the length of a string while also appending an ellipses.
Expand Down Expand Up @@ -41,7 +42,7 @@ func selectSecretNameFromList(c *cli.Context) (string, error) {

secretNames := make([]string, 0, len(secrets))
for _, secret := range secrets {
secretNames = append(secretNames, aws.StringValue(secret.Name))
secretNames = append(secretNames, aws.ToString(secret.Name))
}
sort.Strings(secretNames)

Expand Down Expand Up @@ -155,13 +156,13 @@ func ListSecrets(c *cli.Context) error {
})

for _, secret := range secrets {
lastdt := aws.TimeValue(secret.LastAccessedDate)
updateddt := aws.TimeValue(secret.LastChangedDate)
lastdt := aws.ToTime(secret.LastAccessedDate)
updateddt := aws.ToTime(secret.LastChangedDate)
t.AppendRow([]interface{}{
aws.StringValue(secret.Name),
aws.ToString(secret.Name),
fmt.Sprintf("%d-%02d-%02d", updateddt.Year(), updateddt.Month(), updateddt.Day()),
fmt.Sprintf("%d-%02d-%02d", lastdt.Year(), lastdt.Month(), lastdt.Day()),
truncateString(aws.StringValue(secret.Description), 40),
truncateString(aws.ToString(secret.Description), 40),
})
}

Expand All @@ -185,10 +186,10 @@ func ViewSecret(c *cli.Context) error {
if c.Bool("binary") {
fmt.Println(string(secret.SecretBinary))
} else {
result, err := djson.Decode([]byte(aws.StringValue(secret.SecretString)))
result, err := djson.Decode([]byte(aws.ToString(secret.SecretString)))
if err != nil {
PrintWarn("stored string value is not valid JSON.")
fmt.Println(aws.StringValue(secret.SecretString))
fmt.Println(aws.ToString(secret.SecretString))
} else {
f := colorjson.NewFormatter()
f.Indent = 4
Expand All @@ -213,7 +214,12 @@ func DescribeSecret(c *cli.Context) error {
return cli.Exit(err, 2)
}

fmt.Println(secret.String())
jString, err := json.MarshalIndent(secret, "", " ")
if err != nil {
return cli.Exit(err, 2)
}

fmt.Println(string(jString))

return nil
}
Expand All @@ -234,10 +240,10 @@ func EditSecret(c *cli.Context) error {
if c.Bool("binary") {
s = secret.SecretBinary
} else {
result, err := djson.Decode([]byte(aws.StringValue(secret.SecretString)))
result, err := djson.Decode([]byte(aws.ToString(secret.SecretString)))
if err != nil {
PrintWarn("stored string value is not valid JSON.")
s = []byte(aws.StringValue(secret.SecretString))
s = []byte(aws.ToString(secret.SecretString))
} else {
s, err = json.MarshalIndent(result, "", " ")
if err != nil {
Expand Down Expand Up @@ -369,10 +375,10 @@ func PutSecret(c *cli.Context) error {
if c.Bool("binary") {
value = secret.SecretBinary
} else {
result, err := djson.Decode([]byte(aws.StringValue(secret.SecretString)))
result, err := djson.Decode([]byte(aws.ToString(secret.SecretString)))
if err != nil {
PrintWarn("stored string value is not valid JSON.")
value = []byte(aws.StringValue(secret.SecretString))
value = []byte(aws.ToString(secret.SecretString))
} else {
value, err = json.MarshalIndent(result, "", " ")
if err != nil {
Expand Down
80 changes: 72 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,29 +1,93 @@
module github.com/GoodwayGroup/gwsm

go 1.16
go 1.20

require (
github.com/AlecAivazis/survey/v2 v2.2.12
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2
github.com/a8m/djson v0.0.0-20170509170705-c02c5aef757f
github.com/aws/aws-sdk-go v1.38.63
github.com/aws/aws-sdk-go-v2 v1.30.4
github.com/aws/aws-sdk-go-v2/config v1.27.28
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.12
github.com/aws/aws-sdk-go-v2/service/s3 v1.60.0
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.5
github.com/clok/avtool/v2 v2.1.1
github.com/clok/awssession v1.1.1
github.com/clok/cdocs v1.2.0
github.com/clok/kemba v1.1.1
github.com/clok/kemba v1.2.1
github.com/cyberark/summon v0.8.4
github.com/fatih/color v1.9.0 // indirect
github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e // indirect
github.com/imdario/mergo v0.3.9 // indirect
github.com/jedib0t/go-pretty/v6 v6.2.2
github.com/logrusorgru/aurora/v3 v3.0.0
github.com/manifoldco/promptui v0.8.0
github.com/r3labs/diff/v2 v2.13.1
github.com/sergi/go-diff v1.2.0
github.com/urfave/cli/v2 v2.3.0
golang.org/x/term v0.0.0-20210503060354-a79de5458b56
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.21.1
k8s.io/apimachinery v0.21.1
k8s.io/client-go v0.21.1
)

require (
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.4 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.28 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.12 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.16 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.16 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.16 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.18 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.18 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.16 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.22.5 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.5 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.30.4 // indirect
github.com/aws/smithy-go v1.20.4 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/google/go-cmp v0.5.2 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/googleapis/gnostic v0.4.1 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e // indirect
github.com/imdario/mergo v0.3.9 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.11 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
golang.org/x/crypto v0.0.0-20210513122933-cd7d49e622d5 // indirect
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.3.4 // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.8.0 // indirect
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
Loading

0 comments on commit 26254c2

Please sign in to comment.