1+ <%
2+ require "json"
3+
4+ # Ensure Azure CLI connection_config has a default timeout if none is set
5+ def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds: 41)
6+ cfg = (connection_cfg || {}).dup
7+ if blobstore_type == 'storage_cli'
8+ if !cfg.key?('put_timeout_in_seconds') || cfg['put_timeout_in_seconds'].to_s.empty?
9+ cfg['put_timeout_in_seconds'] = default_seconds.to_s
10+ end
11+ end
12+ cfg
13+ end
14+
15+ # helper: add key only when value is present
16+ def add_optional(h, key, val)
17+ return if val.nil?
18+ return if val.respond_to?(:empty?) && val.empty?
19+ h[key] = val
20+ end
21+
22+ l = link("cloud_controller_internal")
23+
24+ scope = "cc.buildpacks.connection_config"
25+ provider = l.p("cc.buildpacks.blobstore_provider", nil)
26+ options = {}
27+
28+ if provider == "AzureRM"
29+ options["provider"] = provider
30+ options["account_name"] = l.p("#{scope}.azure_storage_account_name")
31+ options["container_name"] = l.p("#{scope}.container_name")
32+ options["account_key"] = l.p("#{scope}.azure_storage_access_key")
33+ add_optional(options, "environment", l.p("#{scope}.environment", "AzureCloud"))
34+ add_optional(options, "put_timeout_in_seconds", l.p("#{scope}.put_timeout_in_seconds", nil))
35+ options = cli_cfg_with_default_timeout(options, 'storage_cli')
36+ end
37+
38+ if provider == "Google"
39+ options["provider"] = provider
40+ options["credentials_source"] = "static"
41+ options["json_key"] = l.p("#{scope}.google_json_key_string")
42+ options["bucket_name"] = l.p("#{scope}.bucket_name")
43+ add_optional(options, "storage_class", l.p("#{scope}.storage_class", nil))
44+ add_optional(options, "encryption_key", l.p("#{scope}.encryption_key", nil))
45+ end
46+
47+ if provider == "AWS"
48+ options["provider"] = provider
49+ options["bucket_name"] = l.p("#{scope}.bucket_name")
50+ options["credentials_source"] = "static"
51+ options["access_key_id"] = l.p("#{scope}.aws_access_key_id")
52+ options["secret_access_key"] = l.p("#{scope}.aws_secret_access_key")
53+ add_optional(options, "region", l.p("#{scope}.region", nil))
54+ add_optional(options, "host", l.p("#{scope}.host", nil))
55+ add_optional(options, "port", l.p("#{scope}.port", nil))
56+ add_optional(options, "ssl_verify_peer", l.p("#{scope}.ssl_verify_peer", nil))
57+ add_optional(options, "use_ssl", l.p("#{scope}.use_ssl", nil))
58+ add_optional(options, "signature_version", l.p("#{scope}.signature_version", nil))
59+ add_optional(options, "server_side_encryption", l.p("#{scope}.encryption", nil))
60+ add_optional(options, "sse_kms_key_id", l.p("#{scope}.x-amz-server-side-encryption-aws-kms-key-id", nil))
61+ add_optional(options, "multipart_upload", l.p("#{scope}.multipart_upload", nil))
62+ end
63+
64+ if provider == "aliyun"
65+ options["provider"] = provider
66+ options["access_key_id"] = l.p("#{scope}.aliyun_accesskey_id")
67+ options["access_key_secret"] = l.p("#{scope}.aliyun_accesskey_secret")
68+ options["endpoint"] = l.p("#{scope}.aliyun_oss_endpoint")
69+ options["bucket_name"] = l.p("#{scope}.aliyun_oss_bucket")
70+ end
71+
72+ if provider == "webdav"
73+ options["provider"] = provider
74+ options["user"] = l.p("#{scope}.username")
75+ options["password"] = l.p("#{scope}.password")
76+ options["endpoint"] = l.p("#{scope}.public_endpoint")
77+ add_optional(options, "secret", l.p("#{scope}.secret", nil))
78+ add_optional(options, "retry_attempts", l.p("#{scope}.retry_attempts", nil))
79+
80+ # TLS nested object with a Cert inside
81+ ca_cert=l.p("#{scope}.ca_cert",nil)
82+ unless ca_cert.empty?
83+ options["tls"]={"cert"=>ca_cert}
84+ end
85+ end
86+
87+ -%>
88+ <%= JSON.pretty_generate(options) %>
0 commit comments