mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 10:15:35 +01:00
Update the related build scripts to package the chart repo server
add env file template for chart repo server in make/common/config/chartserver update the Makefiles to support build chart repo server add docker file and related build scripts for upstream chart server - chartmuseum update prepare to support generating chart server related configs add docker compose file for the chart server add build/install command options to install with/without chart repo server update install.sh to support chart repo server installation
This commit is contained in:
parent
b572e64a68
commit
22ea7dd91f
27
Makefile
27
Makefile
@ -83,6 +83,8 @@ REBUILDCLARITYFLAG=false
|
||||
NEWCLARITYVERSION=
|
||||
BUILDBIN=false
|
||||
MIGRATORFLAG=false
|
||||
# enable/disable chart repo supporting
|
||||
CHARTFLAG=false
|
||||
|
||||
# version prepare
|
||||
# for docker image tag
|
||||
@ -104,6 +106,8 @@ CLAIRVERSION=v2.0.1
|
||||
CLAIRDBVERSION=$(VERSIONTAG)
|
||||
MIGRATORVERSION=v1.5.0
|
||||
REDISVERSION=$(VERSIONTAG)
|
||||
# version of chartmuseum
|
||||
CHARTMUSEUMVERSION=v0.7.1
|
||||
|
||||
#clarity parameters
|
||||
CLARITYIMAGE=vmware/harbor-clarity-ui-builder[:tag]
|
||||
@ -129,7 +133,7 @@ GOINSTALL=$(GOCMD) install
|
||||
GOTEST=$(GOCMD) test
|
||||
GODEP=$(GOTEST) -i
|
||||
GOFMT=gofmt -w
|
||||
GOBUILDIMAGE=reg.mydomain.com/library/harborgo[:tag]
|
||||
GOBUILDIMAGE=golang:1.9.2
|
||||
GOBUILDPATH=$(GOBASEPATH)/harbor
|
||||
GOIMAGEBUILDCMD=/usr/local/go/bin/go
|
||||
GOIMAGEBUILD=$(GOIMAGEBUILDCMD) build
|
||||
@ -164,6 +168,10 @@ endif
|
||||
ifeq ($(CLAIRFLAG), true)
|
||||
PREPARECMD_PARA+= --with-clair
|
||||
endif
|
||||
# append chartmuseum parameters if set
|
||||
ifeq ($(CHARTFLAG), true)
|
||||
PREPARECMD_PARA+= --with-chartmuseum
|
||||
endif
|
||||
|
||||
# makefile
|
||||
MAKEFILEPATH_PHOTON=$(MAKEPATH)/photon
|
||||
@ -179,6 +187,7 @@ DOCKERIMAGENAME_JOBSERVICE=vmware/harbor-jobservice
|
||||
DOCKERIMAGENAME_LOG=vmware/harbor-log
|
||||
DOCKERIMAGENAME_DB=vmware/harbor-db
|
||||
DOCKERIMAGENAME_CLARITY=vmware/harbor-clarity-ui-builder
|
||||
DOCKERIMAGENAME_CHART_SERVER=vmware/chartmuseum-photon
|
||||
|
||||
# docker-compose files
|
||||
DOCKERCOMPOSEFILEPATH=$(MAKEPATH)
|
||||
@ -188,6 +197,8 @@ DOCKERCOMPOSENOTARYTPLFILENAME=docker-compose.notary.tpl
|
||||
DOCKERCOMPOSENOTARYFILENAME=docker-compose.notary.yml
|
||||
DOCKERCOMPOSECLAIRTPLFILENAME=docker-compose.clair.tpl
|
||||
DOCKERCOMPOSECLAIRFILENAME=docker-compose.clair.yml
|
||||
DOCKERCOMPOSECHARTMUSEUMTPLFILENAME=docker-compose.chartmuseum.tpl
|
||||
DOCKERCOMPOSECHARTMUSEUMFILENAME=docker-compose.chartmuseum.yml
|
||||
|
||||
SEDCMD=$(shell which sed)
|
||||
|
||||
@ -241,6 +252,13 @@ endif
|
||||
ifeq ($(MIGRATORFLAG), true)
|
||||
DOCKERSAVE_PARA+= vmware/harbor-migrator:$(MIGRATORVERSION)
|
||||
endif
|
||||
# append chartmuseum parameters if set
|
||||
ifeq ($(CHARTFLAG), true)
|
||||
DOCKERSAVE_PARA+= $(DOCKERIMAGENAME_CHART_SERVER):$(CHARTMUSEUMVERSION)-$(VERSIONTAG)
|
||||
PACKAGE_OFFLINE_PARA+= $(HARBORPKG)/$(DOCKERCOMPOSECHARTMUSEUMFILENAME)
|
||||
PACKAGE_ONLINE_PARA+= $(HARBORPKG)/$(DOCKERCOMPOSECHARTMUSEUMFILENAME)
|
||||
DOCKERCOMPOSE_LIST+= -f $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSECHARTMUSEUMFILENAME)
|
||||
endif
|
||||
|
||||
version:
|
||||
@printf $(UIVERSIONTAG) > $(VERSIONFILEPATH)/$(VERSIONFILENAME);
|
||||
@ -286,7 +304,7 @@ build:
|
||||
-e CLAIRVERSION=$(CLAIRVERSION) -e CLAIRDBVERSION=$(CLAIRDBVERSION) -e VERSIONTAG=$(VERSIONTAG) \
|
||||
-e BUILDBIN=$(BUILDBIN) -e REDISVERSION=$(REDISVERSION)
|
||||
|
||||
modify_composefile: modify_composefile_notary modify_composefile_clair
|
||||
modify_composefile: modify_composefile_notary modify_composefile_clair modify_composefile_chartmuseum
|
||||
@echo "preparing docker-compose file..."
|
||||
@cp $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSETPLFILENAME) $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSEFILENAME)
|
||||
@cp $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSETPLFILENAME) $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSEFILENAME)
|
||||
@ -313,6 +331,11 @@ modify_composefile_clair:
|
||||
@cp $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSECLAIRTPLFILENAME) $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSECLAIRFILENAME)
|
||||
@$(SEDCMD) -i 's/__clair_version__/$(CLAIRVERSION)-$(VERSIONTAG)/g' $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSECLAIRFILENAME)
|
||||
|
||||
modify_composefile_chartmuseum:
|
||||
@echo "preparing docker-compose chartmuseum file..."
|
||||
@cp $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSECHARTMUSEUMTPLFILENAME) $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSECHARTMUSEUMFILENAME)
|
||||
@$(SEDCMD) -i 's/__chartmuseum_version__/$(CHARTMUSEUMVERSION)-$(VERSIONTAG)/g' $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSECHARTMUSEUMFILENAME)
|
||||
|
||||
modify_sourcefiles:
|
||||
@echo "change mode of source files."
|
||||
@chmod 600 $(MAKEPATH)/common/templates/notary/notary-signer.key
|
||||
|
@ -61,3 +61,4 @@ REGISTRY_STORAGE_PROVIDER_NAME=$storage_provider_name
|
||||
READ_ONLY=false
|
||||
SKIP_RELOAD_ENV_PATTERN=$skip_reload_env_pattern
|
||||
RELOAD_KEY=$reload_key
|
||||
CHART_SERVICE_URL=$chart_service_url
|
||||
|
41
make/common/templates/chartserver/env
Normal file
41
make/common/templates/chartserver/env
Normal file
@ -0,0 +1,41 @@
|
||||
## Settings should be set
|
||||
PORT=9999
|
||||
|
||||
# Only support redis now. If redis is setup, then enable cache
|
||||
CACHE=$cache_store
|
||||
CACHE_REDIS_ADDR=$cache_redis_addr
|
||||
CACHE_REDIS_PASSWORD=$cache_redis_password
|
||||
CACHE_REDIS_DB=$cache_redis_db_index
|
||||
|
||||
# Credential for internal communication
|
||||
BASIC_AUTH_USER="chart_controller"
|
||||
BASIC_AUTH_PASS=$ui_secret
|
||||
|
||||
# Multiple tenants
|
||||
# Must be set with 1 to support project namespace
|
||||
DEPTH=1
|
||||
|
||||
# Backend storage driver: e.g. "local", "amazon", "google" etc.
|
||||
STORAGE=$storage_driver
|
||||
|
||||
# Storage driver settings
|
||||
$all_storage_driver_configs
|
||||
|
||||
## Settings with default values. Just put here for future changes
|
||||
DEBUG=false
|
||||
LOG_JSON=true
|
||||
DISABLE_METRICS=false
|
||||
DISABLE_API=false
|
||||
DISABLE_STATEFILES=false
|
||||
ALLOW_OVERWRITE=false
|
||||
CHART_URL=""
|
||||
AUTH_ANONYMOUS_GET=false
|
||||
TLS_CERT=""
|
||||
TLS_KEY=""
|
||||
CONTEXT_PATH=""
|
||||
INDEX_LIMIT=0
|
||||
MAX_STORAGE_OBJECTS=0
|
||||
MAX_UPLOAD_SIZE=20971520
|
||||
CHART_POST_FORM_FIELD_NAME="chart"
|
||||
PROV_POST_FORM_FIELD_NAME="prov"
|
||||
|
33
make/docker-compose.chartmuseum.tpl
Normal file
33
make/docker-compose.chartmuseum.tpl
Normal file
@ -0,0 +1,33 @@
|
||||
version: '2'
|
||||
services:
|
||||
ui:
|
||||
networks:
|
||||
harbor-chartmuseum:
|
||||
aliases:
|
||||
- harbor-ui
|
||||
redis:
|
||||
networks:
|
||||
harbor-chartmuseum:
|
||||
aliases:
|
||||
- redis
|
||||
chartmuseum:
|
||||
container_name: chartmuseum
|
||||
image: vmware/chartmuseum-photon:__chartmuseum_version__
|
||||
restart: always
|
||||
cpu_quota: 150000
|
||||
networks:
|
||||
- harbor-chartmuseum
|
||||
depends_on:
|
||||
- redis
|
||||
volumes:
|
||||
- /data/chart_storage:/chart_storage:z
|
||||
logging:
|
||||
driver: "syslog"
|
||||
options:
|
||||
syslog-address: "tcp://127.0.0.1:1514"
|
||||
tag: "chartmuseum"
|
||||
env_file:
|
||||
./common/config/chartserver/env
|
||||
networks:
|
||||
harbor-chartmuseum:
|
||||
external: false
|
@ -60,6 +60,9 @@ with_notary=$false
|
||||
with_clair=$false
|
||||
# HA mode is not enabled by default
|
||||
harbor_ha=$false
|
||||
# chartmuseum is not enabled by default
|
||||
with_chartmuseum=$false
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--help)
|
||||
@ -71,6 +74,8 @@ while [ $# -gt 0 ]; do
|
||||
with_clair=true;;
|
||||
--ha)
|
||||
harbor_ha=true;;
|
||||
--with-chartmuseum)
|
||||
with_chartmuseum=true;;
|
||||
*)
|
||||
note "$usage"
|
||||
exit 1;;
|
||||
@ -173,6 +178,11 @@ if [ $harbor_ha ]
|
||||
then
|
||||
prepare_para="${prepare_para} --ha"
|
||||
fi
|
||||
if [ $with_chartmuseum ]
|
||||
then
|
||||
prepare_para="${prepare_para} --with-chartmuseum"
|
||||
fi
|
||||
|
||||
./prepare $prepare_para
|
||||
echo ""
|
||||
|
||||
@ -186,6 +196,10 @@ if [ $with_clair ]
|
||||
then
|
||||
docker_compose_list="${docker_compose_list} -f docker-compose.clair.yml"
|
||||
fi
|
||||
if [ $with_chartmuseum ]
|
||||
then
|
||||
docker_compose_list="${docker_compose_list} -f docker-compose.chartmuseum.yml"
|
||||
fi
|
||||
|
||||
if [ -n "$(docker-compose $docker_compose_list ps -q)" ]
|
||||
then
|
||||
|
@ -85,6 +85,13 @@ DOCKERFILEPATH_MIGRATOR=$(TOOLSPATH)/migration
|
||||
DOCKERFILENAME_MIGRATOR=Dockerfile
|
||||
DOCKERIMAGENAME_MIGRATOR=vmware/harbor-migrator
|
||||
|
||||
# for chart server (chartmuseum)
|
||||
DOCKERFILEPATH_CHART_SERVER=$(DOCKERFILEPATH)/chartserver
|
||||
DOCKERFILENAME_CHART_SERVER=Dockerfile
|
||||
CHART_SERVER_CODE_BASE=github.com/helm/chartmuseum
|
||||
CHART_SERVER_MAIN_PATH=cmd/chartmuseum
|
||||
CHART_SERVER_BIN_NAME=chartm
|
||||
|
||||
_build_db:
|
||||
@echo "building db container for photon..."
|
||||
@cd $(DOCKERFILEPATH_DB) && $(DOCKERBUILD) -f $(DOCKERFILEPATH_DB)/$(DOCKERFILENAME_DB) -t $(DOCKERIMAGENAME_DB):$(VERSIONTAG) .
|
||||
@ -123,6 +130,20 @@ _build_clair:
|
||||
rm -rf $(DOCKERFILEPATH_CLAIR)/binary; \
|
||||
echo "Done." ; \
|
||||
fi
|
||||
|
||||
_build_chart_server:
|
||||
@if [ "$(CHARTFLAG)" = "true" ] ; then \
|
||||
if [ "$(BUILDBIN)" != "true" ] ; then \
|
||||
rm -rf $(DOCKERFILEPATH_CHART_SERVER)/binary && mkdir -p $(DOCKERFILEPATH_CHART_SERVER)/binary && \
|
||||
$(call _get_binary, https://storage.googleapis.com/harbor-builds/bin/chartm, $(DOCKERFILEPATH_CHART_SERVER)/binary/chartm); \
|
||||
else \
|
||||
cd $(DOCKERFILEPATH_CHART_SERVER) && $(DOCKERFILEPATH_CHART_SERVER)/builder $(GOBUILDIMAGE) $(CHART_SERVER_CODE_BASE) $(CHARTMUSEUMVERSION) $(CHART_SERVER_MAIN_PATH) $(CHART_SERVER_BIN_NAME); \
|
||||
fi ; \
|
||||
echo "building chartmuseum container for photon..." ; \
|
||||
cd $(DOCKERFILEPATH_CHART_SERVER) && $(DOCKERBUILD) -f $(DOCKERFILEPATH_CHART_SERVER)/$(DOCKERFILENAME_CHART_SERVER) -t $(DOCKERIMAGENAME_CHART_SERVER):$(CHARTMUSEUMVERSION)-$(VERSIONTAG) . ; \
|
||||
rm -rf $(DOCKERFILEPATH_CHART_SERVER)/binary; \
|
||||
echo "Done." ; \
|
||||
fi
|
||||
|
||||
_build_nginx:
|
||||
@echo "building nginx container for photon..."
|
||||
@ -173,7 +194,7 @@ define _get_binary
|
||||
$(WGET) --timeout 30 --no-check-certificate $1 -O $2
|
||||
endef
|
||||
|
||||
build: _build_db _build_adminiserver _build_ui _build_jobservice _build_log _build_nginx _build_registry _build_notary _build_clair _build_redis _build_migrator
|
||||
build: _build_db _build_adminiserver _build_ui _build_jobservice _build_log _build_nginx _build_registry _build_notary _build_clair _build_redis _build_migrator _build_chart_server
|
||||
|
||||
cleanimage:
|
||||
@echo "cleaning image for photon..."
|
||||
|
23
make/photon/chartserver/Dockerfile
Normal file
23
make/photon/chartserver/Dockerfile
Normal file
@ -0,0 +1,23 @@
|
||||
FROM vmware/photon:1.0
|
||||
|
||||
|
||||
RUN tdnf distro-sync -y \
|
||||
&& tdnf erase vim -y \
|
||||
&& tdnf install -y git shadow sudo bzr rpm xz python-xml >>/dev/null\
|
||||
&& tdnf clean all \
|
||||
&& mkdir /chartserver/ \
|
||||
&& groupadd -r -g 10000 chartuser \
|
||||
&& useradd --no-log-init -m -r -g 10000 -u 10000 chartuser
|
||||
COPY ./binary/chartm /chartserver/
|
||||
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
||||
|
||||
EXPOSE 9999
|
||||
|
||||
RUN chown -R 10000:10000 /chartserver \
|
||||
&& chmod u+x /chartserver/chartm \
|
||||
&& chmod u+x /docker-entrypoint.sh
|
||||
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -sS 127.0.0.1:9999/health || exit 1
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
33
make/photon/chartserver/builder
Executable file
33
make/photon/chartserver/builder
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
set +e
|
||||
|
||||
usage(){
|
||||
echo "Usage: builder <golang image:version> <code path> <code release tag> <main.go path> <binary name>"
|
||||
echo "e.g: builder golang:1.9.2 github.com/helm/chartmuseum v0.7.1 cmd/chartmuseum chartm"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# != 5 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
GOLANG_IMAGE="$1"
|
||||
CODE_PATH="$2"
|
||||
CODE_VERSION="$3"
|
||||
MAIN_GO_PATH="$4"
|
||||
BIN_NAME="$5"
|
||||
|
||||
set -e
|
||||
|
||||
cd `dirname $0`
|
||||
cur=$PWD
|
||||
|
||||
mkdir -p binary
|
||||
rm -rf binary/$BIN_NAME || true
|
||||
cp compile.sh binary/
|
||||
|
||||
docker run -it -v $cur/binary:/go/bin --name golang_code_builder $GOLANG_IMAGE /bin/bash /go/bin/compile.sh $CODE_PATH $CODE_VERSION $MAIN_GO_PATH $BIN_NAME
|
||||
|
||||
#Clear
|
||||
docker rm -f golang_code_builder
|
34
make/photon/chartserver/compile.sh
Normal file
34
make/photon/chartserver/compile.sh
Normal file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
set +e
|
||||
|
||||
usage(){
|
||||
echo "Usage: compile.sh <code path> <code tag> <main.go path> <binary name>"
|
||||
echo "e.g: compile.sh github.com/helm/chartmuseum v0.5.1 cmd/chartmuseum chartm"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# != 4 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
CODE_PATH="$1"
|
||||
VERSION="$2"
|
||||
MAIN_GO_PATH="$3"
|
||||
BIN_NAME="$4"
|
||||
|
||||
#Get the source code of chartmusem
|
||||
go get $CODE_PATH
|
||||
|
||||
set -e
|
||||
|
||||
#Checkout the released tag branch
|
||||
cd /go/src/$CODE_PATH
|
||||
git checkout tags/$VERSION -b $VERSION
|
||||
|
||||
#Install the go dep tool to restore the package dependencies
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
dep ensure
|
||||
|
||||
#Compile
|
||||
cd /go/src/$CODE_PATH/$MAIN_GO_PATH && go build -a -o $BIN_NAME
|
||||
mv $BIN_NAME /go/bin/
|
4
make/photon/chartserver/docker-entrypoint.sh
Normal file
4
make/photon/chartserver/docker-entrypoint.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
sudo -E -H -u \#10000 sh -c "/chartserver/chartm" #Parameters are set by ENV
|
||||
set +e
|
109
make/prepare
109
make/prepare
@ -69,6 +69,16 @@ def validate(conf, args):
|
||||
|
||||
if project_creation != "everyone" and project_creation != "adminonly":
|
||||
raise Exception("Error invalid value for project_creation_restriction: %s" % project_creation)
|
||||
|
||||
valid_storage_drivers = ["filesystem", "azure", "gcs", "s3", "swift", "oss"]
|
||||
storage_provider_name = rcp.get("configuration", "registry_storage_provider_name").strip()
|
||||
if storage_provider_name not in valid_storage_drivers:
|
||||
raise Exception("Error: storage driver %s is not supported, only the following ones are supported: %s" % (storage_provider_name, ",".join(valid_storage_drivers)))
|
||||
|
||||
storage_provider_config = rcp.get("configuration", "registry_storage_provider_config").strip()
|
||||
if storage_provider_name != "filesystem":
|
||||
if storage_provider_config == "":
|
||||
raise Exception("Error: no provider configurations are provided for provider %s" % storage_provider_name)
|
||||
|
||||
#To meet security requirement
|
||||
#By default it will change file mode to 0600, and make the owner of the file to 10000:10000
|
||||
@ -188,6 +198,7 @@ parser.add_argument('--with-notary', dest='notary_mode', default=False, action='
|
||||
parser.add_argument('--with-clair', dest='clair_mode', default=False, action='store_true', help="the Harbor instance is to be deployed with clair")
|
||||
parser.add_argument('--ha', dest='ha_mode', default=False, action='store_true', help="the Harbor instance is to be deployed in HA mode")
|
||||
parser.add_argument('--yes', dest='yes', default=False, action='store_true', help="Answer yes to all questions")
|
||||
parser.add_argument('--with-chartmuseum', dest='chart_mode', default=False, action='store_true', help="the Harbor instance is to be deployed with chart repository supporting")
|
||||
args = parser.parse_args()
|
||||
|
||||
delfile(config_dir)
|
||||
@ -318,6 +329,7 @@ token_service_url = "http://ui:8080/service/token"
|
||||
jobservice_url = "http://jobservice:8080"
|
||||
clair_url = "http://clair:6060"
|
||||
notary_url = "http://notary-server:4443"
|
||||
chart_service_url = "http://chartmuseum:9999"
|
||||
|
||||
if len(admiral_url) != 0 and admiral_url != "NA":
|
||||
#VIC overwrites the data volume path, which by default should be same as the value of secretkey_path
|
||||
@ -401,7 +413,8 @@ render(os.path.join(templates_dir, "adminserver", "env"),
|
||||
clair_url=clair_url,
|
||||
notary_url=notary_url,
|
||||
reload_key=reload_key,
|
||||
skip_reload_env_pattern=skip_reload_env_pattern
|
||||
skip_reload_env_pattern=skip_reload_env_pattern,
|
||||
chart_service_url=chart_service_url
|
||||
)
|
||||
|
||||
render(os.path.join(templates_dir, "ui", "env"),
|
||||
@ -613,5 +626,99 @@ if args.clair_mode:
|
||||
if args.ha_mode:
|
||||
prepare_ha(rcp, args)
|
||||
|
||||
# config chart repository
|
||||
if args.chart_mode:
|
||||
chartm_temp_dir = os.path.join(templates_dir, "chartserver")
|
||||
chrtm_config_dir = os.path.join(config_dir, "chartserver")
|
||||
chartm_env = os.path.join(config_dir, "chartserver", "env")
|
||||
|
||||
if not os.path.isdir(chrtm_config_dir):
|
||||
print ("Create config folder: %s" % chrtm_config_dir)
|
||||
os.makedirs(chrtm_config_dir)
|
||||
|
||||
# process redis info
|
||||
cache_store = ""
|
||||
cache_redis_password = ""
|
||||
cache_redis_addr = ""
|
||||
cache_redis_db_index = 0
|
||||
if redis_url and redis_url.strip():
|
||||
cache_store = "redis"
|
||||
segments = redis_url.split(',', 3)
|
||||
for index, r_cfg in enumerate(segments):
|
||||
# the addr:port
|
||||
if index == 0:
|
||||
cache_redis_addr = r_cfg
|
||||
# the password if existing
|
||||
elif index == 2:
|
||||
cache_redis_password = r_cfg
|
||||
# the database index if existing
|
||||
elif index == 3:
|
||||
cache_redis_db_index = r_cfg
|
||||
|
||||
# process storage info
|
||||
#default using local file system
|
||||
storage_driver = "local"
|
||||
# storage provider configurations
|
||||
# please be aware that, we do not check the validations of the values for the specified keys
|
||||
# convert the configs to config map
|
||||
storage_provider_configs = storage_provider_config.split(",")
|
||||
storgae_provider_confg_map = {}
|
||||
storage_provider_config_options = []
|
||||
|
||||
for k_v in storage_provider_configs:
|
||||
if len(k_v) > 0:
|
||||
kvs = k_v.split(": ") # add space suffix to avoid existing ":" in the value
|
||||
if len(kvs) == 2:
|
||||
#key must not be empty
|
||||
if kvs[0].strip() != "":
|
||||
storgae_provider_confg_map[kvs[0].strip()] = kvs[1].strip()
|
||||
|
||||
if storage_provider_name == "s3":
|
||||
# aws s3 storage
|
||||
storage_driver = "amazon"
|
||||
storage_provider_config_options.append("STORAGE_AMAZON_BUCKET=%s" % storgae_provider_confg_map.get("bucket", ""))
|
||||
storage_provider_config_options.append("STORAGE_AMAZON_PREFIX=%s" % storgae_provider_confg_map.get("rootdirectory", ""))
|
||||
storage_provider_config_options.append("STORAGE_AMAZON_REGION=%s" % storgae_provider_confg_map.get("region", ""))
|
||||
storage_provider_config_options.append("STORAGE_AMAZON_ENDPOINT=%s" % storgae_provider_confg_map.get("regionendpoint", ""))
|
||||
elif storage_provider_name == "gcs":
|
||||
# google cloud storage
|
||||
storage_driver = "google"
|
||||
storage_provider_config_options.append("STORAGE_GOOGLE_BUCKET=%s" % storgae_provider_confg_map.get("bucket", ""))
|
||||
storage_provider_config_options.append("STORAGE_GOOGLE_PREFIX=%s" % storgae_provider_confg_map.get("rootdirectory", ""))
|
||||
elif storage_provider_name == "azure":
|
||||
# azure storage
|
||||
storage_driver = "microsoft"
|
||||
storage_provider_config_options.append("STORAGE_MICROSOFT_CONTAINER=%s" % storgae_provider_confg_map.get("container", ""))
|
||||
storage_provider_config_options.append("STORAGE_MICROSOFT_PREFIX=/azure/harbor/charts")
|
||||
elif storage_provider_name == "swift":
|
||||
# open stack swift
|
||||
storage_driver = "openstack"
|
||||
storage_provider_config_options.append("STORAGE_OPENSTACK_CONTAINER=%s" % storgae_provider_confg_map.get("container", ""))
|
||||
storage_provider_config_options.append("STORAGE_OPENSTACK_PREFIX=%s" % storgae_provider_confg_map.get("rootdirectory", ""))
|
||||
storage_provider_config_options.append("STORAGE_OPENSTACK_REGION=%s" % storgae_provider_confg_map.get("region", ""))
|
||||
elif storage_provider_name == "oss":
|
||||
# aliyun OSS
|
||||
storage_driver = "alibaba"
|
||||
storage_provider_config_options.append("STORAGE_ALIBABA_BUCKET=%s" % storgae_provider_confg_map.get("bucket", ""))
|
||||
storage_provider_config_options.append("STORAGE_ALIBABA_PREFIX=%s" % storgae_provider_confg_map.get("rootdirectory", ""))
|
||||
storage_provider_config_options.append("STORAGE_ALIBABA_ENDPOINT=%s" % storgae_provider_confg_map.get("endpoint", ""))
|
||||
else:
|
||||
# use local file system
|
||||
storage_provider_config_options.append("STORAGE_LOCAL_ROOTDIR=/chart_storage")
|
||||
|
||||
# generate storage provider configuration
|
||||
all_storage_provider_configs = ('\n').join(storage_provider_config_options)
|
||||
|
||||
render(os.path.join(chartm_temp_dir, "env"),
|
||||
chartm_env,
|
||||
cache_store=storage_driver,
|
||||
cache_redis_addr=cache_redis_addr,
|
||||
cache_redis_password=cache_redis_password,
|
||||
cache_redis_db_index=cache_redis_db_index,
|
||||
ui_secret=ui_secret,
|
||||
storage_driver=storage_driver,
|
||||
all_storage_driver_configs=all_storage_provider_configs)
|
||||
|
||||
|
||||
FNULL.close()
|
||||
print("The configuration files are ready, please use docker-compose to start the service.")
|
||||
|
Loading…
Reference in New Issue
Block a user