Skip to content

Instantly share code, notes, and snippets.

@syguer
Created October 25, 2017 07:34
Show Gist options
  • Save syguer/3364fc1bd10cfb96901458765d2bc893 to your computer and use it in GitHub Desktop.
Save syguer/3364fc1bd10cfb96901458765d2bc893 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"os/exec"
"strings"
)
func main() {
login_cmd, err := exec.Command("aws", "ecr", "get-login").Output()
if err != nil {
fmt.Printf("%s", err)
}
token := strings.Split(string(login_cmd), " ")[5]
token_param := "--docker-password=" + token
exec.Command("kubectl", "delete", "secret", "ecr").Run()
output, err := exec.Command(
"kubectl", "create", "secret", "docker-registry", "ecr",
"--docker-server=https://xxxxxxxxxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com",
"--docker-username=AWS",
token_param,
"--docker-email=xxxxxxxxxx",
).Output()
if err != nil {
fmt.Printf("%s", err)
}
fmt.Printf("%s", output)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment