-
Notifications
You must be signed in to change notification settings - Fork 106
Storage CLI Client #595
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
base: develop
Are you sure you want to change the base?
Storage CLI Client #595
Changes from all commits
3a2b7a7
9699941
5f11cea
35fe566
fbfc692
d1cce59
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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| <%# Generate json configuration for buildpacks bucket depending on provider; Azure, Google, AWS, Ali, WebDAV %> | ||
| <% | ||
| require "json" | ||
|
|
||
|
|
@@ -13,7 +14,7 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds | |
| end | ||
|
|
||
| # helper: add key only when value is present | ||
| def add(h, key, val) | ||
| def add_optional(h, key, val) | ||
| return if val.nil? | ||
| return if val.respond_to?(:empty?) && val.empty? | ||
| h[key] = val | ||
|
|
@@ -23,28 +24,66 @@ l = link("cloud_controller_internal") | |
|
|
||
| scope = "cc.buildpacks.connection_config" | ||
| provider = l.p("cc.buildpacks.blobstore_provider", nil) | ||
| options = {} | ||
|
|
||
| if provider != "AzureRM" | ||
| options = {} # for now: all non-azure providers output an empty JSON object | ||
| else | ||
| options = {} | ||
| if provider == "AzureRM" | ||
| 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")) | ||
| 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 | ||
| options["account_key"] = l.p("#{scope}.azure_storage_access_key") | ||
| add_optional(options, "environment", l.p("#{scope}.environment", "AzureCloud")) | ||
| add_optional(options, "put_timeout_in_seconds", l.p("#{scope}.put_timeout_in_seconds", nil)) | ||
| options = cli_cfg_with_default_timeout(options, 'storage_cli') | ||
| end | ||
|
|
||
| if provider == "Google" | ||
| options["provider"] = provider | ||
| options["credentials_source"] = "static" | ||
| options["json_key"] = l.p("#{scope}.google_json_key_string") | ||
| options["bucket_name"] = l.p("#{scope}.bucket_name") | ||
| add_optional(options, "storage_class", l.p("#{scope}.storage_class", nil)) | ||
| add_optional(options, "encryption_key", l.p("#{scope}.encryption_key", nil)) | ||
| end | ||
|
|
||
| if provider == "AWS" | ||
| options["provider"] = provider | ||
| options["bucket_name"] = l.p("#{scope}.bucket_name") | ||
| options["credentials_source"] = "static" | ||
| options["access_key_id"] = l.p("#{scope}.aws_access_key_id") | ||
| options["secret_access_key"] = l.p("#{scope}.aws_secret_access_key") | ||
| options["region"]=l.p("#{scope}.region") | ||
| add_optional(options, "host", l.p("#{scope}.host", nil)) | ||
| add_optional(options, "port", l.p("#{scope}.port", nil)) | ||
| add_optional(options, "ssl_verify_peer", l.p("#{scope}.ssl_verify_peer", nil)) | ||
| add_optional(options, "use_ssl", l.p("#{scope}.use_ssl", nil)) | ||
| add_optional(options, "singnature_version", l.p("#{scope}.singnature_version", nil)) | ||
|
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. spelling error: singnature_version -> signature_version |
||
| add_optional(options, "server_side_encryption", l.p("#{scope}.encryption", nil)) | ||
| add_optional(options, "sse_kms_key_id", l.p("#{scope}.x-amz-server-side-encryption-aws-kms-key-id", nil)) | ||
| add_optional(options, "multipart_upload", l.p("#{scope}.multipart_upload", nil)) | ||
| end | ||
|
|
||
| if provider == "aliyun" | ||
| 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") | ||
| end | ||
|
|
||
| if provider == "webdav" | ||
| options["provider"] = provider | ||
| options["user"] = l.p("#{scope}.username") | ||
| options["password"] = l.p("#{scope}.password") | ||
| options["endpoint"] = l.p("#{scope}.public_endpoint") | ||
| add_optional(options, "secret", l.p("#{scope}.secret", nil)) | ||
| add_optional(options, "retry_attempts", l.p("#{scope}.retry_attempts", nil)) | ||
|
|
||
| # TLS nested object with a Cert inside | ||
| ca_cert=l.p("#{scope}.ca_cert",nil) | ||
| unless ca_cert.empty? | ||
| options["tls"]={"cert"=>ca_cert} | ||
| end | ||
|
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. Should we stick to the naming like in cf-deployment.yml for webdav? |
||
| end | ||
|
|
||
| -%> | ||
| <%= JSON.pretty_generate(options) %> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| <%# Generate json configuration for droplets bucket depending on provider; Azure, Google, AWS, Ali, WebDAV %> | ||
| <% | ||
| require "json" | ||
|
|
||
|
|
@@ -13,7 +14,7 @@ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds | |
| end | ||
|
|
||
| # helper: add key only when value is present | ||
| def add(h, key, val) | ||
| def add_optional(h, key, val) | ||
| return if val.nil? | ||
| return if val.respond_to?(:empty?) && val.empty? | ||
| h[key] = val | ||
|
|
@@ -23,28 +24,66 @@ l = link("cloud_controller_internal") | |
|
|
||
| scope = "cc.droplets.connection_config" | ||
| provider = l.p("cc.droplets.blobstore_provider", nil) | ||
| options = {} | ||
|
|
||
| if provider != "AzureRM" | ||
| options = {} # for now: all non-azure providers output an empty JSON object | ||
| else | ||
| options = {} | ||
| if provider == "AzureRM" | ||
| 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")) | ||
| 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 | ||
| options["account_key"] = l.p("#{scope}.azure_storage_access_key") | ||
| add_optional(options, "environment", l.p("#{scope}.environment", "AzureCloud")) | ||
| add_optional(options, "put_timeout_in_seconds", l.p("#{scope}.put_timeout_in_seconds", nil)) | ||
| options = cli_cfg_with_default_timeout(options, 'storage_cli') | ||
| end | ||
|
|
||
| if provider == "Google" | ||
| options["provider"] = provider | ||
| options["credentials_source"] = "static" | ||
| options["json_key"] = l.p("#{scope}.google_json_key_string") | ||
| options["bucket_name"] = l.p("#{scope}.bucket_name") | ||
| add_optional(options, "storage_class", l.p("#{scope}.storage_class", nil)) | ||
| add_optional(options, "encryption_key", l.p("#{scope}.encryption_key", nil)) | ||
| end | ||
|
|
||
| if provider == "AWS" | ||
| options["provider"] = provider | ||
| options["bucket_name"] = l.p("#{scope}.bucket_name") | ||
| options["credentials_source"] = "static" | ||
| options["access_key_id"] = l.p("#{scope}.aws_access_key_id") | ||
| options["secret_access_key"] = l.p("#{scope}.aws_secret_access_key") | ||
| options["region"]=l.p("#{scope}.region") | ||
| add_optional(options, "host", l.p("#{scope}.host", nil)) | ||
| add_optional(options, "port", l.p("#{scope}.port", nil)) | ||
| add_optional(options, "ssl_verify_peer", l.p("#{scope}.ssl_verify_peer", nil)) | ||
| add_optional(options, "use_ssl", l.p("#{scope}.use_ssl", nil)) | ||
| add_optional(options, "singnature_version", l.p("#{scope}.singnature_version", nil)) | ||
|
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. same spelling error as above and in all the other jsons ;) |
||
| add_optional(options, "server_side_encryption", l.p("#{scope}.encryption", nil)) | ||
| add_optional(options, "sse_kms_key_id", l.p("#{scope}.x-amz-server-side-encryption-aws-kms-key-id", nil)) | ||
| add_optional(options, "multipart_upload", l.p("#{scope}.multipart_upload", nil)) | ||
| end | ||
|
|
||
| if provider == "aliyun" | ||
| 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") | ||
| end | ||
|
|
||
| if provider == "webdav" | ||
| options["provider"] = provider | ||
| options["user"] = l.p("#{scope}.username") | ||
| options["password"] = l.p("#{scope}.password") | ||
| options["endpoint"] = l.p("#{scope}.public_endpoint") | ||
| add_optional(options, "secret", l.p("#{scope}.secret", nil)) | ||
| add_optional(options, "retry_attempts", l.p("#{scope}.retry_attempts", nil)) | ||
|
|
||
| # TLS nested object with a Cert inside | ||
| ca_cert=l.p("#{scope}.ca_cert",nil) | ||
| unless ca_cert.empty? | ||
| options["tls"]={"cert"=>ca_cert} | ||
| end | ||
| end | ||
|
|
||
| -%> | ||
| <%= JSON.pretty_generate(options) %> | ||
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.
"region" is not required by the original config, and it defaults to "us-east-1" (like AzureCloud for azure environment)