-
Notifications
You must be signed in to change notification settings - Fork 106
Add Azure Storage CLI connection config to specs and yml.erb files #574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
6571de4
6497b4b
ac99f38
5f72668
0c12f66
52c9d06
07f5aef
d7b2b39
e6173ca
815fb2d
bf0ce46
a3c55ed
0132cad
fd72857
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <% | ||
| require "json" | ||
|
|
||
| def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds: 41) | ||
| cfg = (connection_cfg || {}).dup | ||
| if blobstore_type == 'storage_cli' | ||
| if !cfg.key?('put_timeout_in_seconds') || cfg['put_timeout_in_seconds'].to_s.empty? | ||
| cfg['put_timeout_in_seconds'] = default_seconds.to_s | ||
| end | ||
| end | ||
| cfg | ||
| end | ||
|
|
||
| def add(h, key, val) | ||
| return if val.nil? | ||
| return if val.respond_to?(:empty?) && val.empty? | ||
| h[key] = val | ||
| end | ||
|
|
||
| def options_for(scope_prefix, provider_prop) | ||
| provider = p(provider_prop, nil) | ||
| return {} unless provider == "AzureRM" | ||
|
|
||
| h = {} | ||
| h["provider"] = provider | ||
| h["account_name"] = p("#{scope_prefix}.azure_storage_account_name") | ||
| h["container_name"] = p("#{scope_prefix}.container_name") | ||
| add(h, "account_key", p("#{scope_prefix}.azure_storage_access_key")) | ||
| add(h, "environment", p("#{scope_prefix}.environment", "AzureCloud")) | ||
| add(h, "put_timeout_in_seconds", p("#{scope_prefix}.put_timeout_in_seconds", nil)) | ||
|
|
||
| # optional passthrough for extra storage-cli flags | ||
| begin | ||
| custom = p("#{scope_prefix}.custom", {}) | ||
| if custom.respond_to?(:each) | ||
| custom.each { |k, v| add(h, k.to_s, v) } | ||
| end | ||
| rescue | ||
| # property might not exist; ignore | ||
| end | ||
|
|
||
| cli_cfg_with_default_timeout(h, 'storage_cli') | ||
| end | ||
|
|
||
| all = { | ||
| "buildpacks" => options_for("cc.buildpacks.connection_config", "cc.buildpacks.blobstore_provider"), | ||
| "droplets" => options_for("cc.droplets.connection_config", "cc.droplets.blobstore_provider"), | ||
| "packages" => options_for("cc.packages.connection_config", "cc.packages.blobstore_provider"), | ||
| "resource_pool" => options_for("cc.resource_pool.connection_config", "cc.resource_pool.blobstore_provider"), | ||
| } | ||
| -%> | ||
| <%= JSON.pretty_generate(all) %> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,8 +23,30 @@ function setup_directories { | |
| chown -R vcap:vcap "$LOG_DIR" | ||
| } | ||
|
|
||
| write_blobstore_scope_configs() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would simply name this |
||
| local cfg_json="${CONFIG_DIR}/blobstore_configs.json" | ||
| if [[ ! -f "$cfg_json" ]]; then | ||
| echo "blobstore_configs.json not found at $cfg_json; skipping fan-out" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this really happen? |
||
| return 0 | ||
| fi | ||
|
|
||
| # Use the packaged Ruby if you prefer; system Ruby is usually fine on CF VMs. | ||
| CFG="$cfg_json" DEST="$BUNDLER_DIR" ruby <<'RUBY' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True |
||
| require "json" | ||
| cfg_path = ENV.fetch("CFG") | ||
| dest = ENV.fetch("DEST") | ||
| data = JSON.parse(File.read(cfg_path)) | ||
|
|
||
| %w[buildpacks droplets packages resource_pool].each do |k| | ||
| out = File.join(dest, "storage_cli_config_#{k}.json") | ||
| File.write(out, JSON.pretty_generate(data[k] || {})) | ||
| end | ||
| RUBY | ||
| } | ||
|
|
||
| function main { | ||
| setup_directories | ||
| write_blobstore_scope_configs | ||
| } | ||
|
|
||
| main | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <% | ||
| require "json" | ||
|
|
||
| def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds: 41) | ||
| cfg = (connection_cfg || {}).dup | ||
| if blobstore_type == 'storage_cli' | ||
| if !cfg.key?('put_timeout_in_seconds') || cfg['put_timeout_in_seconds'].to_s.empty? | ||
| cfg['put_timeout_in_seconds'] = default_seconds.to_s | ||
| end | ||
| end | ||
| cfg | ||
| end | ||
|
|
||
| def add(h, key, val) | ||
| return if val.nil? | ||
| return if val.respond_to?(:empty?) && val.empty? | ||
| h[key] = val | ||
| end | ||
|
|
||
| def options_for(scope_prefix, provider_prop) | ||
| provider = p(provider_prop, nil) | ||
| return {} unless provider == "AzureRM" | ||
|
|
||
| h = {} | ||
| h["provider"] = provider | ||
| h["account_name"] = p("#{scope_prefix}.azure_storage_account_name") | ||
| h["container_name"] = p("#{scope_prefix}.container_name") | ||
| add(h, "account_key", p("#{scope_prefix}.azure_storage_access_key")) | ||
| add(h, "environment", p("#{scope_prefix}.environment", "AzureCloud")) | ||
| add(h, "put_timeout_in_seconds", p("#{scope_prefix}.put_timeout_in_seconds", nil)) | ||
|
|
||
| # optional passthrough for extra storage-cli flags | ||
| begin | ||
| custom = p("#{scope_prefix}.custom", {}) | ||
| if custom.respond_to?(:each) | ||
| custom.each { |k, v| add(h, k.to_s, v) } | ||
| end | ||
| rescue | ||
| # property might not exist; ignore | ||
| end | ||
|
|
||
| cli_cfg_with_default_timeout(h, 'storage_cli') | ||
| end | ||
|
|
||
| all = { | ||
| "buildpacks" => options_for("cc.buildpacks.connection_config", "cc.buildpacks.blobstore_provider"), | ||
| "droplets" => options_for("cc.droplets.connection_config", "cc.droplets.blobstore_provider"), | ||
| "packages" => options_for("cc.packages.connection_config", "cc.packages.blobstore_provider"), | ||
| "resource_pool" => options_for("cc.resource_pool.connection_config", "cc.resource_pool.blobstore_provider"), | ||
| } | ||
| -%> | ||
| <%= JSON.pretty_generate(all) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"AzureRM" originates from the fog-azure implementation. Should we use a different name? Maybe "azure-storage-cli"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just azure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or keep AzureRM = Azure Resource Manager