Skip to content

Commit

Permalink
add bin/azk8spull.
Browse files Browse the repository at this point in the history
  • Loading branch information
xuxinkun committed Nov 24, 2019
1 parent 07e122f commit db17d37
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ chmod +x install.sh
source /etc/profile
```

`azk8spull` function can not work with zsh. So, `bin/azk8spull` is provided for zsh. Install it as follow if using zsh.

```
cp bin/azk8spull /usr/bin
chmod +x /usr/bin/azk8spull
sed -i '/source \/etc\/littletools\/azk8spull.sh/d' /etc/littletools/littletools.sh
```

## docker tools(docker-tools)

| command | params | description |
Expand Down
52 changes: 52 additions & 0 deletions bin/azk8spull
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
image=$1
if [ -z $image ]; then
echo "## azk8spull image name cannot be null."
else
array=(`echo $image | tr '/' ' '` )

domainName=""
repoName=""
imageName=""

if [ ${#array[*]} -eq 3 ]; then
repoName=${array[1]}
imageName=${array[2]}
if [ "${array[0]}"x = "docker.io"x ]; then
domainName="dockerhub.azk8s.cn"
elif [ "${array[0]}"x = "gcr.io"x ]; then
domainName="gcr.azk8s.cn"
elif [ "${array[0]}"x = "quay.io"x ]; then
domainName="quay.azk8s.cn"
else
echo '## azk8spull can not support pulling $image right now.'
fi
elif [ ${#array[*]} -eq 2 ]; then
if [ "${array[0]}"x = "k8s.gcr.io"x ]; then
domainName="gcr.azk8s.cn"
repoName="google_containers"
imageName=${array[1]}
else
domainName="dockerhub.azk8s.cn"
repoName=${array[0]}
imageName=${array[1]}
fi
elif [ ${#array[*]} -eq 1 ]; then
domainName="dockerhub.azk8s.cn"
repoName="library"
imageName=${array[0]}
else
echo '## azk8spull can not support pulling $image right now.'
fi
if [ $domainName != "" ]; then
echo "## azk8spull try to pull image from mirror $domainName/$repoName/$imageName."
docker pull $domainName/$repoName/$imageName
if [ $? -eq 0 ]; then
echo "## azk8spull try to tag $domainName/$repoName/$imageName to $image."
docker tag $domainName/$repoName/$imageName $image
if [ $? -eq 0 ]; then
echo '## azk8spull finish pulling. '
fi
fi
fi
fi

0 comments on commit db17d37

Please sign in to comment.