Created
October 25, 2017 07:34
-
-
Save syguer/3364fc1bd10cfb96901458765d2bc893 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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