Skip to content

Commit

Permalink
modify prepare for genrate all common/config files from template
Browse files Browse the repository at this point in the history
  • Loading branch information
yhua committed Nov 8, 2016
1 parent 9c91fdc commit 09b6215
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 181 deletions.
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
harbor
make/common/config/registry/config.yml
make/common/config/ui/env
make/common/config/ui/app.conf
make/common/config/db/env
make/common/config/jobservice/env
make/common/config/nginx/nginx.conf
make/common/config/nginx/cert/*
make/common/config/*
make/dev/ui/harbor_ui
make/dev/jobservice/harbor_jobservice
src/ui/ui
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ package_online: modify_composefile
@cp LICENSE $(HARBORPKG)/LICENSE
@cp NOTICE $(HARBORPKG)/NOTICE
@$(TARCMD) -zcvf harbor-online-installer-$(VERSIONTAG).tgz \
--exclude=$(HARBORPKG)/common/db \
--exclude=$(HARBORPKG)/common/db --exclude=$(HARBORPKG)/common/config\
--exclude=$(HARBORPKG)/common/log --exclude=$(HARBORPKG)/ubuntu \
--exclude=$(HARBORPKG)/photon --exclude=$(HARBORPKG)/kubernetes \
--exclude=$(HARBORPKG)/dev --exclude=$(DOCKERCOMPOSETPLFILENAME) \
Expand Down Expand Up @@ -279,7 +279,7 @@ package_offline: compile build modify_composefile
nginx:1.11.5 registry:2.5.0

@$(TARCMD) -zcvf harbor-offline-installer-$(VERSIONTAG).tgz \
--exclude=$(HARBORPKG)/common/db \
--exclude=$(HARBORPKG)/common/db --exclude=$(HARBORPKG)/common/config\
--exclude=$(HARBORPKG)/common/log --exclude=$(HARBORPKG)/ubuntu \
--exclude=$(HARBORPKG)/photon --exclude=$(HARBORPKG)/kubernetes \
--exclude=$(HARBORPKG)/dev --exclude=$(DOCKERCOMPOSETPLFILENAME) \
Expand Down
Empty file.
75 changes: 0 additions & 75 deletions make/common/config/nginx/nginx.conf

This file was deleted.

35 changes: 0 additions & 35 deletions make/common/config/registry/root.crt

This file was deleted.

51 changes: 0 additions & 51 deletions make/common/config/ui/private_key.pem

This file was deleted.

File renamed without changes.
37 changes: 26 additions & 11 deletions make/prepare
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ job_config_dir = os.path.join(config_dir, "jobservice")
if not os.path.exists(job_config_dir):
os.makedirs(job_config_dir)

registry_config_dir = os.path.join(config_dir, "registry")
if not os.path.exists(registry_config_dir):
os.makedirs(registry_config_dir)

nginx_config_dir = os.path.join(config_dir, "nginx")
if not os.path.exists(nginx_config_dir):
os.makedirs(nginx_config_dir)

def render(src, dest, **kw):
t = Template(open(src, 'r').read())
with open(dest, 'w') as f:
Expand All @@ -140,20 +148,24 @@ def render(src, dest, **kw):

ui_conf_env = os.path.join(config_dir, "ui", "env")
ui_conf = os.path.join(config_dir, "ui", "app.conf")
jobservice_conf = os.path.join(config_dir, "jobservice", "app.conf")
registry_conf = os.path.join(config_dir, "registry", "config.yml")
db_conf_env = os.path.join(config_dir, "db", "env")
job_conf_env = os.path.join(config_dir, "jobservice", "env")
nginx_conf = os.path.join(config_dir, "nginx", "nginx.conf")
cert_dir = os.path.join(config_dir, "nginx", "cert")
conf_files = [ ui_conf, ui_conf_env, registry_conf, db_conf_env, job_conf_env, nginx_conf, cert_dir ]
def rmdir(cf):
for f in cf:
if os.path.isdir(f):
rmdir(map(lambda x: os.path.join(f,x), os.listdir(f)))
elif os.path.exists(f) and os.path.basename(f) != ".gitignore":
print("Clearing the configuration file: %s" % f)
os.remove(f)
rmdir(conf_files)
def delfile(src):
if os.path.isfile(src):
try:
os.remove(src)
print("Clearing the configuration file: %s" % src)
except:
pass
elif os.path.isdir(src):
for item in os.listdir(src):
itemsrc=os.path.join(src,item)
delfile(itemsrc)
delfile(config_dir)

if protocol == "https":
target_cert_path = os.path.join(cert_dir, os.path.basename(cert_path))
Expand Down Expand Up @@ -215,6 +227,9 @@ render(os.path.join(templates_dir, "jobservice", "env"),
secret_key=secret_key,
ui_url=ui_url,
verify_remote_cert=verify_remote_cert)

print("Generated configuration file: %s" % jobservice_conf)
shutil.copyfile(os.path.join(templates_dir, "jobservice", "app.conf"), jobservice_conf)

def validate_crt_subj(dirty_subj):
subj_list = [item for item in dirty_subj.strip().split("/") \
Expand Down Expand Up @@ -262,8 +277,8 @@ if customize_crt == 'on':
if openssl_is_installed(shell_stat):
private_key_pem = os.path.join(config_dir, "ui", "private_key.pem")
root_crt = os.path.join(config_dir, "registry", "root.crt")
crt_conf_files = [ private_key_pem, root_crt ]
rmdir(crt_conf_files)
delfile(private_key_pem)
delfile(root_crt)

check_private_key_stat(path=private_key_pem)
check_certificate_stat(path=root_crt)
Expand Down

0 comments on commit 09b6215

Please sign in to comment.