Skip to content

Commit 1e1a9fc

Browse files
authored
Merge pull request moby#3476 from crazy-max/azblob-acct-name
azblob cache: account_name attribute
2 parents 983554b + ef0a352 commit 1e1a9fc

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,11 @@ There are 2 options supported for Azure Blob Storage authentication:
536536
* Any system using environment variables supported by the [Azure SDK for Go](https://docs.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication). The configuration must be available for the buildkit daemon, not for the client.
537537
* Secret Access Key, using the `secret_access_key` attribute to specify the primary or secondary account key for your Azure Blob Storage account. [Azure Blob Storage account keys](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-keys-manage)
538538

539+
> **Note**
540+
>
541+
> Account name can also be specified with `account_name` attribute (or `$BUILDKIT_AZURE_STORAGE_ACCOUNT_NAME`)
542+
> if it is not part of the account URL host.
543+
539544
`--export-cache` options:
540545
* `type=azblob`
541546
* `mode=<min|max>`: specify cache layers to export (default: `min`)

cache/remotecache/azblob/utils.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
const (
1717
attrSecretAccessKey = "secret_access_key"
18+
attrAccountName = "account_name"
1819
attrAccountURL = "account_url"
1920
attrPrefix = "prefix"
2021
attrManifestsPrefix = "manifests_prefix"
@@ -50,7 +51,16 @@ func getConfig(attrs map[string]string) (*Config, error) {
5051
return &Config{}, errors.Wrap(err, "azure storage account url provided is not a valid url")
5152
}
5253

53-
accountName := strings.Split(accountURL.Hostname(), ".")[0]
54+
accountName, ok := attrs[attrAccountName]
55+
if !ok {
56+
accountName, ok = os.LookupEnv("BUILDKIT_AZURE_STORAGE_ACCOUNT_NAME")
57+
if !ok {
58+
accountName = strings.Split(accountURL.Hostname(), ".")[0]
59+
}
60+
}
61+
if accountName == "" {
62+
return &Config{}, errors.New("unable to retrieve account name from account url or ${BUILDKIT_AZURE_STORAGE_ACCOUNT_NAME} or account_name attribute for azblob cache")
63+
}
5464

5565
container, ok := attrs[attrContainer]
5666
if !ok {

0 commit comments

Comments
 (0)