From f8165cebb89739869845c51734f95833aa497286 Mon Sep 17 00:00:00 2001 From: Nobuto Murata Date: Fri, 27 May 2022 19:39:09 +0900 Subject: [PATCH] Support --visibility option for simplestreams With the new option, Glance images can be uploaded with "visibility=shared" for example instead of "public" so those can be hidden from usual projects by default. Closes-Bug: #1975663 Change-Id: I1955f3d2a56654c9a683a2b9d36b33c0f0fd63d4 --- config.yaml | 6 ++++++ files/glance_simplestreams_sync.py | 8 ++++++++ hooks/hooks.py | 1 + templates/mirrors.yaml | 1 + 4 files changed, 16 insertions(+) diff --git a/config.yaml b/config.yaml index e4d5d21..dbbbbcc 100644 --- a/config.yaml +++ b/config.yaml @@ -49,6 +49,12 @@ options: type: string default: "auto-sync/" description: "This is prefixed to the object name when uploading to glance." + visibility: + type: string + default: "public" + description: > + Visibility to apply to stored images. Possible values are + 'public', 'private', 'community', and 'shared'. custom_properties: type: string default: diff --git a/files/glance_simplestreams_sync.py b/files/glance_simplestreams_sync.py index 6869c0a..cee23c2 100755 --- a/files/glance_simplestreams_sync.py +++ b/files/glance_simplestreams_sync.py @@ -299,6 +299,14 @@ def do_sync(ksc, charm_conf): custom_property ] + # --visibility is relatively new so use it only when the + # default value is modified for backward compatibility + if charm_conf['visibility'] != "public": + sync_command += [ + "--visibility", + charm_conf['visibility'], + ] + sync_command += [ mirror_info['url'], ] diff --git a/hooks/hooks.py b/hooks/hooks.py index 83086df..eb1cb64 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -173,6 +173,7 @@ class MirrorsConfigServiceContext(OSContextGenerator): return dict(mirror_list=config['mirror_list'], modify_hook_scripts=', '.join(modify_hook_scripts), name_prefix=config['name_prefix'], + visibility=config['visibility'], content_id_template=config['content_id_template'], use_swift=config['use_swift'], ignore_proxy_for_object_store=config[ diff --git a/templates/mirrors.yaml b/templates/mirrors.yaml index 67c1e59..bdbac86 100644 --- a/templates/mirrors.yaml +++ b/templates/mirrors.yaml @@ -2,6 +2,7 @@ mirror_list: {{ mirror_list }} user_agent: {{ user_agent }} modify_hook_scripts: {{ modify_hook_scripts }} name_prefix: {{ name_prefix }} +visibility: {{ visibility }} use_swift: {{ use_swift }} ignore_proxy_for_object_store: {{ ignore_proxy_for_object_store }} region: {{ region }}