mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
* fix: misspelling Signed-off-by: joyceliu <joyceliu@yunify.com> * fix: misspelling Signed-off-by: joyceliu <joyceliu@yunify.com> * fix: misspelling Signed-off-by: joyceliu <joyceliu@yunify.com> * fix: misspelling Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: user go-template instance pongo2-template Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: not set incorrect Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> --------- Signed-off-by: joyceliu <joyceliu@yunify.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
55 lines
2.2 KiB
YAML
55 lines
2.2 KiB
YAML
---
|
|
- name: Create harbor project for each image
|
|
tags: ["only_image"]
|
|
command: |
|
|
{{- if .image_registry.namespace_override | eq "" -}}
|
|
for dir in /tmp/kubekey/images/*; do
|
|
if [ ! -d "$dir" ]; then
|
|
# only deal with directories
|
|
continue
|
|
fi
|
|
|
|
dir_name=${dir##*/}
|
|
IFS='=' set -- $dir_name
|
|
image_array="$@"
|
|
array_length=$#
|
|
|
|
if [ "$array_length" -gt 3 ]; then
|
|
project=$2
|
|
dest_image=$(shift 2 && echo "$*" | tr ' ' '/')
|
|
tag=$(echo "$@" | awk '{print $NF}')
|
|
else
|
|
echo "unsupported image: $dir_name"
|
|
exit 1
|
|
fi
|
|
|
|
# if project is not exist, create if
|
|
http_code=$(curl -Iks -u "{{ .image_registry.auth.username }}:{{ .image_registry.auth.password }}" 'https://localhost/api/v2.0/projects?project_name=${project}' | grep HTTP | awk '{print $2}')
|
|
if [ $http_code == 404 ]; then
|
|
# create project
|
|
curl -u "{{ .image_registry.auth.username }}:{{ .image_registry.auth.password }}" -k -X POST -H "Content-Type: application/json" "https://localhost/api/v2.0/projects" -d "{ \"project_name\": \"${project}\", \"public\": true}"
|
|
fi
|
|
done
|
|
{{- else -}}
|
|
# if project is not exist, create if
|
|
http_code=$(curl -Iks -u "{{ .image_registry.auth.username }}:{{ .image_registry.auth.password }}" 'https://localhost/api/v2.0/projects?project_name={{ .image_registry.namespace_override }}' | grep HTTP | awk '{print $2}')
|
|
if [ $http_code == 404 ]; then
|
|
# create project
|
|
curl -u "{{ .image_registry.auth.username }}:{{ .image_registry.auth.password }}" -k -X POST -H "Content-Type: application/json" "https://localhost/api/v2.0/projects" -d "{ \"project_name\": \"{{ .image_registry.namespace_override }}\", \"public\": true}"
|
|
fi
|
|
{{- end -}}
|
|
when: .image_registry.type | eq "harbor"
|
|
|
|
- name: Sync images package to harbor
|
|
tags: ["only_image"]
|
|
image:
|
|
push:
|
|
registry: |
|
|
{{ .image_registry.auth.registry }}
|
|
namespace_override: |
|
|
{{ .image_registry.namespace_override }}
|
|
username: |
|
|
{{ .image_registry.auth.username }}
|
|
password: |
|
|
{{ .image_registry.auth.password }}
|