Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: logging #6

Merged
merged 1 commit into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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