From e963a956cd33f6fc2ef09e1a6277586fef108a35 Mon Sep 17 00:00:00 2001 From: "J. Randall Hunt" Date: Thu, 16 Feb 2017 17:54:13 -0800 Subject: [PATCH] add docker-repo-uri get the docker repo uri for pushing an image: ``` $ aws docker-repo-uri helloworld 054060359478.dkr.ecr.us-west-2.amazonaws.com/helloworld $ docker push `aws docker-repo-uri helloworld` ``` accepts region arguments as well --- alias | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/alias b/alias index fc01acd..4d47627 100644 --- a/alias +++ b/alias @@ -108,6 +108,21 @@ docker-ecr-login = docker login -u AWS -p $passwd $endpoint }; f +docker-repo-uri = + !f() { + oargs=($(ps -o args= $PPID | cut -d' ' -f 3-)) + for i in "${!oargs[@]}"; do + if [[ "${oargs[$i]}" == "--region" ]]; then + region="--region ${oargs[$i+1]}" + elif [[ "${oargs[$i]}" == "--profile" ]]; then + profile="--profile ${oargs[$i+1]}" + fi + done + aws ecr $region $profile \ + describe-repositories --output text \ + --query "repositories[?repositoryName == '${1}'].repositoryUri" + }; f + myip = !f() { dig +short myip.opendns.com @resolver1.opendns.com