Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,59 @@ 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

# 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))

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) %>
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,59 @@ 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

# 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))

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) %>
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,59 @@ 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

# 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))

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) %>
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,59 @@ 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

# 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))

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) %>
1 change: 1 addition & 0 deletions jobs/cloud_controller_clock/spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,54 @@ 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

# 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

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))

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) %>
Loading