From eead8b75c8c0ab7562e3e35b7d1aa2138d3fc48a Mon Sep 17 00:00:00 2001 From: Katharina Przybill <30441792+kathap@users.noreply.github.com> Date: Tue, 25 Nov 2025 12:15:15 +0100 Subject: [PATCH 1/2] Add AliOSS storage-cli support in capi-release - Render AliOSS storage-cli JSON configs for droplets, packages, buildpacks, and resource_pool via cc.*.connection_config templates - Add Aliyun-specific keys (access_key_id, access_key_secret, endpoint, bucket_name, region_id) to storage-cli config generation --- .../storage_cli_config_buildpacks.json.erb | 46 ++++++++++++++----- .../storage_cli_config_droplets.json.erb | 46 ++++++++++++++----- .../storage_cli_config_packages.json.erb | 46 ++++++++++++++----- .../storage_cli_config_resource_pool.json.erb | 46 ++++++++++++++----- jobs/cloud_controller_clock/spec | 1 + .../storage_cli_config_buildpacks.json.erb | 44 +++++++++++++----- .../storage_cli_config_droplets.json.erb | 44 +++++++++++++----- .../storage_cli_config_packages.json.erb | 44 +++++++++++++----- .../storage_cli_config_resource_pool.json.erb | 44 +++++++++++++----- jobs/cloud_controller_ng/spec | 1 + .../storage_cli_config_buildpacks.json.erb | 44 +++++++++++++----- .../storage_cli_config_droplets.json.erb | 43 ++++++++++++----- .../storage_cli_config_packages.json.erb | 44 +++++++++++++----- .../storage_cli_config_resource_pool.json.erb | 44 +++++++++++++----- jobs/cloud_controller_worker/spec | 1 + .../storage_cli_config_buildpacks.json.erb | 44 +++++++++++++----- .../storage_cli_config_droplets.json.erb | 44 +++++++++++++----- .../storage_cli_config_packages.json.erb | 44 +++++++++++++----- .../storage_cli_config_resource_pool.json.erb | 44 +++++++++++++----- packages/ali-storage-cli/README.md | 9 ++++ packages/ali-storage-cli/packaging | 5 ++ packages/ali-storage-cli/spec | 4 ++ 22 files changed, 540 insertions(+), 192 deletions(-) create mode 100644 packages/ali-storage-cli/README.md create mode 100644 packages/ali-storage-cli/packaging create mode 100644 packages/ali-storage-cli/spec diff --git a/jobs/cc_deployment_updater/templates/storage_cli_config_buildpacks.json.erb b/jobs/cc_deployment_updater/templates/storage_cli_config_buildpacks.json.erb index 36ba5f755a..9eb13c7853 100644 --- a/jobs/cc_deployment_updater/templates/storage_cli_config_buildpacks.json.erb +++ b/jobs/cc_deployment_updater/templates/storage_cli_config_buildpacks.json.erb @@ -19,32 +19,54 @@ def add(h, key, val) h[key] = val end +# helper: merge optional custom flags into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + + custom.each do |k, v| + add(options, k.to_s, v) + end +end + +def apply_custom_from_link!(options, link, scope) + begin + custom = link.p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + l = link("cloud_controller_internal") scope = "cc.buildpacks.connection_config" provider = l.p("cc.buildpacks.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = l.p("#{scope}.azure_storage_account_name") options["container_name"] = l.p("#{scope}.container_name") - add(options, "account_key", l.p("#{scope}.azure_storage_access_key")) + options["account_key"] = l.p("#{scope}.azure_storage_access_key") add(options, "environment", l.p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", l.p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = l.p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_link!(options, l, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = l.p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = l.p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = l.p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = l.p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", l.p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_link!(options, l, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cc_deployment_updater/templates/storage_cli_config_droplets.json.erb b/jobs/cc_deployment_updater/templates/storage_cli_config_droplets.json.erb index 363a7011f6..bb17a2c4e5 100644 --- a/jobs/cc_deployment_updater/templates/storage_cli_config_droplets.json.erb +++ b/jobs/cc_deployment_updater/templates/storage_cli_config_droplets.json.erb @@ -19,32 +19,54 @@ def add(h, key, val) h[key] = val end +# helper: merge optional custom flags into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + + custom.each do |k, v| + add(options, k.to_s, v) + end +end + +def apply_custom_from_link!(options, link, scope) + begin + custom = link.p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + l = link("cloud_controller_internal") scope = "cc.droplets.connection_config" provider = l.p("cc.droplets.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = l.p("#{scope}.azure_storage_account_name") options["container_name"] = l.p("#{scope}.container_name") - add(options, "account_key", l.p("#{scope}.azure_storage_access_key")) + options["account_key"] = l.p("#{scope}.azure_storage_access_key") add(options, "environment", l.p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", l.p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = l.p("cc.droplets.connection_config.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_link!(options, l, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = l.p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = l.p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = l.p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = l.p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", l.p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_link!(options, l, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cc_deployment_updater/templates/storage_cli_config_packages.json.erb b/jobs/cc_deployment_updater/templates/storage_cli_config_packages.json.erb index 4de210731c..fbeb529db2 100644 --- a/jobs/cc_deployment_updater/templates/storage_cli_config_packages.json.erb +++ b/jobs/cc_deployment_updater/templates/storage_cli_config_packages.json.erb @@ -19,32 +19,54 @@ def add(h, key, val) h[key] = val end +# helper: merge optional custom flags into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + + custom.each do |k, v| + add(options, k.to_s, v) + end +end + +def apply_custom_from_link!(options, link, scope) + begin + custom = link.p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + l = link("cloud_controller_internal") scope = "cc.packages.connection_config" provider = l.p("cc.packages.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = l.p("#{scope}.azure_storage_account_name") options["container_name"] = l.p("#{scope}.container_name") - add(options, "account_key", l.p("#{scope}.azure_storage_access_key")) + options["account_key"] = l.p("#{scope}.azure_storage_access_key") add(options, "environment", l.p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", l.p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = l.p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_link!(options, l, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = l.p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = l.p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = l.p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = l.p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", l.p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_link!(options, l, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cc_deployment_updater/templates/storage_cli_config_resource_pool.json.erb b/jobs/cc_deployment_updater/templates/storage_cli_config_resource_pool.json.erb index bbf336fcfb..e530375ce2 100644 --- a/jobs/cc_deployment_updater/templates/storage_cli_config_resource_pool.json.erb +++ b/jobs/cc_deployment_updater/templates/storage_cli_config_resource_pool.json.erb @@ -19,32 +19,54 @@ def add(h, key, val) h[key] = val end +# helper: merge optional custom flags into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + + custom.each do |k, v| + add(options, k.to_s, v) + end +end + +def apply_custom_from_link!(options, link, scope) + begin + custom = link.p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + l = link("cloud_controller_internal") scope = "cc.resource_pool.connection_config" provider = l.p("cc.resource_pool.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = l.p("#{scope}.azure_storage_account_name") options["container_name"] = l.p("#{scope}.container_name") - add(options, "account_key", l.p("#{scope}.azure_storage_access_key")) + options["account_key"] = l.p("#{scope}.azure_storage_access_key") add(options, "environment", l.p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", l.p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = l.p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_link!(options, l, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = l.p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = l.p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = l.p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = l.p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", l.p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_link!(options, l, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_clock/spec b/jobs/cloud_controller_clock/spec index 5b8a7d3134..1d6cbf83d6 100644 --- a/jobs/cloud_controller_clock/spec +++ b/jobs/cloud_controller_clock/spec @@ -31,6 +31,7 @@ templates: storage_cli_config_resource_pool.json.erb: config/storage_cli_config_resource_pool.json packages: + - ali-storage-cli - azure-storage-cli - capi_utils - cloud_controller_ng diff --git a/jobs/cloud_controller_clock/templates/storage_cli_config_buildpacks.json.erb b/jobs/cloud_controller_clock/templates/storage_cli_config_buildpacks.json.erb index 400ccf3d01..04b15a22a2 100644 --- a/jobs/cloud_controller_clock/templates/storage_cli_config_buildpacks.json.erb +++ b/jobs/cloud_controller_clock/templates/storage_cli_config_buildpacks.json.erb @@ -19,30 +19,50 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + scope = "cc.buildpacks.connection_config" provider = p("cc.buildpacks.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_clock/templates/storage_cli_config_droplets.json.erb b/jobs/cloud_controller_clock/templates/storage_cli_config_droplets.json.erb index 60e46c9f30..9ef3520754 100644 --- a/jobs/cloud_controller_clock/templates/storage_cli_config_droplets.json.erb +++ b/jobs/cloud_controller_clock/templates/storage_cli_config_droplets.json.erb @@ -19,30 +19,50 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + scope = "cc.droplets.connection_config" provider = p("cc.droplets.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("cc.droplets.connection_config.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_clock/templates/storage_cli_config_packages.json.erb b/jobs/cloud_controller_clock/templates/storage_cli_config_packages.json.erb index f11ec11221..a63dd35911 100644 --- a/jobs/cloud_controller_clock/templates/storage_cli_config_packages.json.erb +++ b/jobs/cloud_controller_clock/templates/storage_cli_config_packages.json.erb @@ -19,30 +19,50 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + scope = "cc.packages.connection_config" provider = p("cc.packages.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_clock/templates/storage_cli_config_resource_pool.json.erb b/jobs/cloud_controller_clock/templates/storage_cli_config_resource_pool.json.erb index 9b3f7f40d9..2dcecf718c 100644 --- a/jobs/cloud_controller_clock/templates/storage_cli_config_resource_pool.json.erb +++ b/jobs/cloud_controller_clock/templates/storage_cli_config_resource_pool.json.erb @@ -19,30 +19,50 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + scope = "cc.resource_pool.connection_config" provider = p("cc.resource_pool.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_ng/spec b/jobs/cloud_controller_ng/spec index 5139762f95..bf9ac40672 100644 --- a/jobs/cloud_controller_ng/spec +++ b/jobs/cloud_controller_ng/spec @@ -70,6 +70,7 @@ templates: cloud_controller_local_worker_override.yml.erb: config/cloud_controller_local_worker_override.yml packages: + - ali-storage-cli - azure-storage-cli - capi_utils - cloud_controller_ng diff --git a/jobs/cloud_controller_ng/templates/storage_cli_config_buildpacks.json.erb b/jobs/cloud_controller_ng/templates/storage_cli_config_buildpacks.json.erb index 400ccf3d01..04b15a22a2 100644 --- a/jobs/cloud_controller_ng/templates/storage_cli_config_buildpacks.json.erb +++ b/jobs/cloud_controller_ng/templates/storage_cli_config_buildpacks.json.erb @@ -19,30 +19,50 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + scope = "cc.buildpacks.connection_config" provider = p("cc.buildpacks.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_ng/templates/storage_cli_config_droplets.json.erb b/jobs/cloud_controller_ng/templates/storage_cli_config_droplets.json.erb index 60e46c9f30..6a33fe3be1 100644 --- a/jobs/cloud_controller_ng/templates/storage_cli_config_droplets.json.erb +++ b/jobs/cloud_controller_ng/templates/storage_cli_config_droplets.json.erb @@ -19,30 +19,49 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end scope = "cc.droplets.connection_config" provider = p("cc.droplets.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("cc.droplets.connection_config.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_ng/templates/storage_cli_config_packages.json.erb b/jobs/cloud_controller_ng/templates/storage_cli_config_packages.json.erb index f11ec11221..a63dd35911 100644 --- a/jobs/cloud_controller_ng/templates/storage_cli_config_packages.json.erb +++ b/jobs/cloud_controller_ng/templates/storage_cli_config_packages.json.erb @@ -19,30 +19,50 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + scope = "cc.packages.connection_config" provider = p("cc.packages.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_ng/templates/storage_cli_config_resource_pool.json.erb b/jobs/cloud_controller_ng/templates/storage_cli_config_resource_pool.json.erb index 9b3f7f40d9..2dcecf718c 100644 --- a/jobs/cloud_controller_ng/templates/storage_cli_config_resource_pool.json.erb +++ b/jobs/cloud_controller_ng/templates/storage_cli_config_resource_pool.json.erb @@ -19,30 +19,50 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + scope = "cc.resource_pool.connection_config" provider = p("cc.resource_pool.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_worker/spec b/jobs/cloud_controller_worker/spec index 21f5c555f0..af7dc5f8e0 100644 --- a/jobs/cloud_controller_worker/spec +++ b/jobs/cloud_controller_worker/spec @@ -41,6 +41,7 @@ templates: storage_cli_config_resource_pool.json.erb: config/storage_cli_config_resource_pool.json packages: + - ali-storage-cli - azure-storage-cli - capi_utils - cloud_controller_ng diff --git a/jobs/cloud_controller_worker/templates/storage_cli_config_buildpacks.json.erb b/jobs/cloud_controller_worker/templates/storage_cli_config_buildpacks.json.erb index 400ccf3d01..04b15a22a2 100644 --- a/jobs/cloud_controller_worker/templates/storage_cli_config_buildpacks.json.erb +++ b/jobs/cloud_controller_worker/templates/storage_cli_config_buildpacks.json.erb @@ -19,30 +19,50 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + scope = "cc.buildpacks.connection_config" provider = p("cc.buildpacks.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_worker/templates/storage_cli_config_droplets.json.erb b/jobs/cloud_controller_worker/templates/storage_cli_config_droplets.json.erb index 60e46c9f30..9ef3520754 100644 --- a/jobs/cloud_controller_worker/templates/storage_cli_config_droplets.json.erb +++ b/jobs/cloud_controller_worker/templates/storage_cli_config_droplets.json.erb @@ -19,30 +19,50 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + scope = "cc.droplets.connection_config" provider = p("cc.droplets.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("cc.droplets.connection_config.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_worker/templates/storage_cli_config_packages.json.erb b/jobs/cloud_controller_worker/templates/storage_cli_config_packages.json.erb index f11ec11221..a63dd35911 100644 --- a/jobs/cloud_controller_worker/templates/storage_cli_config_packages.json.erb +++ b/jobs/cloud_controller_worker/templates/storage_cli_config_packages.json.erb @@ -19,30 +19,50 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + scope = "cc.packages.connection_config" provider = p("cc.packages.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/jobs/cloud_controller_worker/templates/storage_cli_config_resource_pool.json.erb b/jobs/cloud_controller_worker/templates/storage_cli_config_resource_pool.json.erb index 9b3f7f40d9..2dcecf718c 100644 --- a/jobs/cloud_controller_worker/templates/storage_cli_config_resource_pool.json.erb +++ b/jobs/cloud_controller_worker/templates/storage_cli_config_resource_pool.json.erb @@ -19,30 +19,50 @@ def add(h, key, val) h[key] = val end +# shared: merge custom hash into options +def apply_custom!(options, custom) + return unless custom.respond_to?(:each) + custom.each { |k, v| add(options, k.to_s, v) } +end + +# for templates that use plain `p(...)` +def apply_custom_from_props!(options, scope) + begin + custom = p("#{scope}.custom", {}) + apply_custom!(options, custom) + rescue + # ignore if property not defined + end +end + scope = "cc.resource_pool.connection_config" provider = p("cc.resource_pool.blobstore_provider", nil) -if provider != "AzureRM" - options = {} # for now: all non-azure providers output an empty JSON object -else +if provider == "AzureRM" options = {} options["provider"] = provider options["account_name"] = p("#{scope}.azure_storage_account_name") options["container_name"] = p("#{scope}.container_name") - add(options, "account_key", p("#{scope}.azure_storage_access_key")) + options["account_key"] = p("#{scope}.azure_storage_access_key") add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) # optional passthrough for extra storage-cli flags - begin - custom = p("#{scope}.custom", {}) - if custom.respond_to?(:each) - custom.each { |k, v| add(options, k.to_s, v) } - end - rescue - # ignore if property not defined - end + apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') +elsif provider == "aliyun" + options = {} + options["provider"] = provider + options["access_key_id"] = p("#{scope}.aliyun_accesskey_id") + options["access_key_secret"] = p("#{scope}.aliyun_accesskey_secret") + options["endpoint"] = p("#{scope}.aliyun_oss_endpoint") + options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") + add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) + + # optional passthrough for extra storage-cli flags + apply_custom_from_props!(options, scope) +else + options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object end -%> <%= JSON.pretty_generate(options) %> \ No newline at end of file diff --git a/packages/ali-storage-cli/README.md b/packages/ali-storage-cli/README.md new file mode 100644 index 0000000000..24aa31ccf9 --- /dev/null +++ b/packages/ali-storage-cli/README.md @@ -0,0 +1,9 @@ +ali-storage-cli-package +============ +ali-storage-cli, a command line interface for AliOSS Storage, is used for BOSH deployments instead of outdated fog-aliyun tools. + +The file can be downloaded from the following location: + +| Filename | Download URL | +|----------|--------------------| +| xxx | [xxx](example url) | diff --git a/packages/ali-storage-cli/packaging b/packages/ali-storage-cli/packaging new file mode 100644 index 0000000000..3d8aa073b0 --- /dev/null +++ b/packages/ali-storage-cli/packaging @@ -0,0 +1,5 @@ +set -e + +mkdir -p ${BOSH_INSTALL_TARGET}/bin +mv ali-storage-cli/ali-storage-cli-linux-amd64 ${BOSH_INSTALL_TARGET}/bin/ali-storage-cli +chmod +x ${BOSH_INSTALL_TARGET}/bin/ali-storage-cli diff --git a/packages/ali-storage-cli/spec b/packages/ali-storage-cli/spec new file mode 100644 index 0000000000..0e778f6d8f --- /dev/null +++ b/packages/ali-storage-cli/spec @@ -0,0 +1,4 @@ +--- +name: ali-storage-cli +files: + - ali-storage-cli/ali-storage-cli-linux-amd64 \ No newline at end of file From d7300fda7a039286b218bb291bbb6db46eaa5bf5 Mon Sep 17 00:00:00 2001 From: Katharina Przybill <30441792+kathap@users.noreply.github.com> Date: Tue, 25 Nov 2025 15:08:45 +0100 Subject: [PATCH 2/2] adapt comments --- .../templates/storage_cli_config_buildpacks.json.erb | 6 ++---- .../templates/storage_cli_config_droplets.json.erb | 6 ++---- .../templates/storage_cli_config_packages.json.erb | 6 ++---- .../templates/storage_cli_config_resource_pool.json.erb | 6 ++---- .../templates/storage_cli_config_buildpacks.json.erb | 7 ++----- .../templates/storage_cli_config_droplets.json.erb | 7 ++----- .../templates/storage_cli_config_packages.json.erb | 7 ++----- .../templates/storage_cli_config_resource_pool.json.erb | 7 ++----- .../templates/storage_cli_config_buildpacks.json.erb | 7 ++----- .../templates/storage_cli_config_droplets.json.erb | 7 ++----- .../templates/storage_cli_config_packages.json.erb | 7 ++----- .../templates/storage_cli_config_resource_pool.json.erb | 7 ++----- .../templates/storage_cli_config_buildpacks.json.erb | 7 ++----- .../templates/storage_cli_config_droplets.json.erb | 7 ++----- .../templates/storage_cli_config_packages.json.erb | 7 ++----- .../templates/storage_cli_config_resource_pool.json.erb | 7 ++----- 16 files changed, 32 insertions(+), 76 deletions(-) diff --git a/jobs/cc_deployment_updater/templates/storage_cli_config_buildpacks.json.erb b/jobs/cc_deployment_updater/templates/storage_cli_config_buildpacks.json.erb index 9eb13c7853..5539ab779c 100644 --- a/jobs/cc_deployment_updater/templates/storage_cli_config_buildpacks.json.erb +++ b/jobs/cc_deployment_updater/templates/storage_cli_config_buildpacks.json.erb @@ -12,14 +12,14 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# helper: merge optional custom flags into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) @@ -51,7 +51,6 @@ if provider == "AzureRM" add(options, "environment", l.p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", l.p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_link!(options, l, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -63,7 +62,6 @@ elsif provider == "aliyun" options["bucket_name"] = l.p("#{scope}.aliyun_oss_bucket") add(options, "region_id", l.p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_link!(options, l, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cc_deployment_updater/templates/storage_cli_config_droplets.json.erb b/jobs/cc_deployment_updater/templates/storage_cli_config_droplets.json.erb index bb17a2c4e5..bbff337c84 100644 --- a/jobs/cc_deployment_updater/templates/storage_cli_config_droplets.json.erb +++ b/jobs/cc_deployment_updater/templates/storage_cli_config_droplets.json.erb @@ -12,14 +12,14 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# helper: merge optional custom flags into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) @@ -51,7 +51,6 @@ if provider == "AzureRM" add(options, "environment", l.p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", l.p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_link!(options, l, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -63,7 +62,6 @@ elsif provider == "aliyun" options["bucket_name"] = l.p("#{scope}.aliyun_oss_bucket") add(options, "region_id", l.p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_link!(options, l, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cc_deployment_updater/templates/storage_cli_config_packages.json.erb b/jobs/cc_deployment_updater/templates/storage_cli_config_packages.json.erb index fbeb529db2..d1e2f6a372 100644 --- a/jobs/cc_deployment_updater/templates/storage_cli_config_packages.json.erb +++ b/jobs/cc_deployment_updater/templates/storage_cli_config_packages.json.erb @@ -12,14 +12,14 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# helper: merge optional custom flags into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) @@ -51,7 +51,6 @@ if provider == "AzureRM" add(options, "environment", l.p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", l.p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_link!(options, l, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -63,7 +62,6 @@ elsif provider == "aliyun" options["bucket_name"] = l.p("#{scope}.aliyun_oss_bucket") add(options, "region_id", l.p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_link!(options, l, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cc_deployment_updater/templates/storage_cli_config_resource_pool.json.erb b/jobs/cc_deployment_updater/templates/storage_cli_config_resource_pool.json.erb index e530375ce2..b6ef873213 100644 --- a/jobs/cc_deployment_updater/templates/storage_cli_config_resource_pool.json.erb +++ b/jobs/cc_deployment_updater/templates/storage_cli_config_resource_pool.json.erb @@ -12,14 +12,14 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# helper: merge optional custom flags into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) @@ -51,7 +51,6 @@ if provider == "AzureRM" add(options, "environment", l.p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", l.p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_link!(options, l, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -63,7 +62,6 @@ elsif provider == "aliyun" options["bucket_name"] = l.p("#{scope}.aliyun_oss_bucket") add(options, "region_id", l.p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_link!(options, l, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_clock/templates/storage_cli_config_buildpacks.json.erb b/jobs/cloud_controller_clock/templates/storage_cli_config_buildpacks.json.erb index 04b15a22a2..479f4bb8a7 100644 --- a/jobs/cloud_controller_clock/templates/storage_cli_config_buildpacks.json.erb +++ b/jobs/cloud_controller_clock/templates/storage_cli_config_buildpacks.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -47,7 +46,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -59,7 +57,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_clock/templates/storage_cli_config_droplets.json.erb b/jobs/cloud_controller_clock/templates/storage_cli_config_droplets.json.erb index 9ef3520754..9cd8f94d10 100644 --- a/jobs/cloud_controller_clock/templates/storage_cli_config_droplets.json.erb +++ b/jobs/cloud_controller_clock/templates/storage_cli_config_droplets.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -47,7 +46,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -59,7 +57,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_clock/templates/storage_cli_config_packages.json.erb b/jobs/cloud_controller_clock/templates/storage_cli_config_packages.json.erb index a63dd35911..363bde44e6 100644 --- a/jobs/cloud_controller_clock/templates/storage_cli_config_packages.json.erb +++ b/jobs/cloud_controller_clock/templates/storage_cli_config_packages.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -47,7 +46,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -59,7 +57,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_clock/templates/storage_cli_config_resource_pool.json.erb b/jobs/cloud_controller_clock/templates/storage_cli_config_resource_pool.json.erb index 2dcecf718c..5895ced893 100644 --- a/jobs/cloud_controller_clock/templates/storage_cli_config_resource_pool.json.erb +++ b/jobs/cloud_controller_clock/templates/storage_cli_config_resource_pool.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -47,7 +46,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -59,7 +57,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_ng/templates/storage_cli_config_buildpacks.json.erb b/jobs/cloud_controller_ng/templates/storage_cli_config_buildpacks.json.erb index 04b15a22a2..479f4bb8a7 100644 --- a/jobs/cloud_controller_ng/templates/storage_cli_config_buildpacks.json.erb +++ b/jobs/cloud_controller_ng/templates/storage_cli_config_buildpacks.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -47,7 +46,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -59,7 +57,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_ng/templates/storage_cli_config_droplets.json.erb b/jobs/cloud_controller_ng/templates/storage_cli_config_droplets.json.erb index 6a33fe3be1..f797aca703 100644 --- a/jobs/cloud_controller_ng/templates/storage_cli_config_droplets.json.erb +++ b/jobs/cloud_controller_ng/templates/storage_cli_config_droplets.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -46,7 +45,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -58,7 +56,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_ng/templates/storage_cli_config_packages.json.erb b/jobs/cloud_controller_ng/templates/storage_cli_config_packages.json.erb index a63dd35911..363bde44e6 100644 --- a/jobs/cloud_controller_ng/templates/storage_cli_config_packages.json.erb +++ b/jobs/cloud_controller_ng/templates/storage_cli_config_packages.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -47,7 +46,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -59,7 +57,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_ng/templates/storage_cli_config_resource_pool.json.erb b/jobs/cloud_controller_ng/templates/storage_cli_config_resource_pool.json.erb index 2dcecf718c..5895ced893 100644 --- a/jobs/cloud_controller_ng/templates/storage_cli_config_resource_pool.json.erb +++ b/jobs/cloud_controller_ng/templates/storage_cli_config_resource_pool.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -47,7 +46,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -59,7 +57,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_worker/templates/storage_cli_config_buildpacks.json.erb b/jobs/cloud_controller_worker/templates/storage_cli_config_buildpacks.json.erb index 04b15a22a2..479f4bb8a7 100644 --- a/jobs/cloud_controller_worker/templates/storage_cli_config_buildpacks.json.erb +++ b/jobs/cloud_controller_worker/templates/storage_cli_config_buildpacks.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -47,7 +46,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -59,7 +57,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_worker/templates/storage_cli_config_droplets.json.erb b/jobs/cloud_controller_worker/templates/storage_cli_config_droplets.json.erb index 9ef3520754..9cd8f94d10 100644 --- a/jobs/cloud_controller_worker/templates/storage_cli_config_droplets.json.erb +++ b/jobs/cloud_controller_worker/templates/storage_cli_config_droplets.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -47,7 +46,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -59,7 +57,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_worker/templates/storage_cli_config_packages.json.erb b/jobs/cloud_controller_worker/templates/storage_cli_config_packages.json.erb index a63dd35911..363bde44e6 100644 --- a/jobs/cloud_controller_worker/templates/storage_cli_config_packages.json.erb +++ b/jobs/cloud_controller_worker/templates/storage_cli_config_packages.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -47,7 +46,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -59,7 +57,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object diff --git a/jobs/cloud_controller_worker/templates/storage_cli_config_resource_pool.json.erb b/jobs/cloud_controller_worker/templates/storage_cli_config_resource_pool.json.erb index 2dcecf718c..5895ced893 100644 --- a/jobs/cloud_controller_worker/templates/storage_cli_config_resource_pool.json.erb +++ b/jobs/cloud_controller_worker/templates/storage_cli_config_resource_pool.json.erb @@ -12,20 +12,19 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds cfg end -# helper: add key only when value is present +# add key only when value is present def add(h, key, val) return if val.nil? return if val.respond_to?(:empty?) && val.empty? h[key] = val end -# shared: merge custom hash into options +# merge optional custom flags into options def apply_custom!(options, custom) return unless custom.respond_to?(:each) custom.each { |k, v| add(options, k.to_s, v) } end -# for templates that use plain `p(...)` def apply_custom_from_props!(options, scope) begin custom = p("#{scope}.custom", {}) @@ -47,7 +46,6 @@ if provider == "AzureRM" add(options, "environment", p("#{scope}.environment", "AzureCloud")) add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) options = cli_cfg_with_default_timeout(options, 'storage_cli') elsif provider == "aliyun" @@ -59,7 +57,6 @@ elsif provider == "aliyun" options["bucket_name"] = p("#{scope}.aliyun_oss_bucket") add(options, "region_id", p("#{scope}.aliyun_region_id", nil)) - # optional passthrough for extra storage-cli flags apply_custom_from_props!(options, scope) else options = {} # for now: all non-azure and non-aliyun providers output an empty JSON object