Skip to content

Commit

Permalink
fix: logging (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuart-warren committed Dec 20, 2019
1 parent dceecf5 commit 7082211
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ current implimentations:

## Lastpass

Prerequisites:

- [lpass](https://github.com/lastpass/lastpass-cli/blob/master/README.md)
- [aws-iam-authenticator](https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html)

Create an entry in lastpass with username the AWS_ACCESS_KEY_ID and password the AWS_SECRET_ACCESS_KEY

Then configure your kubeconfig as normal but use `aws-iam-authenticator-lpass` as the command
Expand All @@ -33,6 +38,4 @@ users:
- "REPLACE_ME_WITH_YOUR_ROLE_ARN"
```

You must still have `aws-iam-authenticator` installed.

See https://github.com/kubernetes-sigs/aws-iam-authenticator for more details
10 changes: 7 additions & 3 deletions cmd/aws-iam-authenticator-lpass/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ type Entry struct {
}

func mergeEnv(original, extra []string) []string {
m := map[string]string{}
if len(extra) == 0 {
return original
}
m := map[string]string{}
for _, e := range append(original, extra...) {
p := strings.SplitN(e, "=", 2)
m[p[0]] = p[1]
Expand Down Expand Up @@ -54,8 +54,12 @@ func log(msg ...interface{}) {
fmt.Println(msg...)
}

func errr(msg ...interface{}) {
fmt.Fprintln(os.Stdout, msg...)
}

func fatal(msg ...interface{}) {
log(msg...)
errr(msg...)
os.Exit(1)
}

Expand All @@ -72,7 +76,7 @@ func main() {
var entries []Entry
err = dec.Decode(&entries)
if err != nil {
log("Unexpected output from lpass, perhaps multiple entries with same name? Please be more specific")
errr("Unexpected output from lpass, perhaps multiple entries with same name? Please be more specific")
fatal(string(out))
}
accessKey := entries[0].Username
Expand Down

0 comments on commit 7082211

Please sign in to comment.