Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

Commit

Permalink
Copy install_dir files to local storage directory
Browse files Browse the repository at this point in the history
  • Loading branch information
sacharya committed Aug 17, 2020
1 parent 8ae5f28 commit f07ffe3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions render_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ def upload_to_s3(s3_endpoint_url, bucket, aws_access_key_id, aws_secret_access_k
upload_to_aws(s3_client, file_path, bucket, s3_file_name)


def debug_print_upload_to_s3(install_dir):
prefix = "dummy_cluster_id"
def copy_to_local_storage(work_dir, install_dir, cluster_id):
os.makedirs(os.path.join(work_dir, cluster_id), exist_ok=True)
for root, _, files in os.walk(install_dir):
for file_name in files:
file_path = os.path.join(root, file_name)
if file_name == "kubeconfig":
file_name = "kubeconfig-noingress"
s3_file_name = "{}/{}".format(prefix, file_name)
print("Uploading file %s as object %s" % (file_path, s3_file_name))
s3_file_name = "/{}/{}/{}".format(work_dir, cluster_id, file_name)
print("Copying file %s to %s" % (file_path, s3_file_name))
shutil.copyfile(file_path, s3_file_name)


@contextmanager
Expand Down Expand Up @@ -202,8 +203,7 @@ def main():
if s3_endpoint_url:
upload_to_s3(s3_endpoint_url, bucket, aws_access_key_id, aws_secret_access_key, config_dir, cluster_id)
else:
# for debug purposes
debug_print_upload_to_s3(config_dir)
copy_to_local_storage(work_dir, config_dir, cluster_id)


if __name__ == "__main__":
Expand Down

0 comments on commit f07ffe3

Please sign in to comment.