Azure BlobStorage components: Add `disableEntityManagement` metadata option (#3213)

Signed-off-by: Bernd Verst <github@bernd.dev>
This commit is contained in:
Bernd Verst 2023-11-06 14:19:40 -08:00 committed by GitHub
parent fe466beaa2
commit 20a46e6657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 14 deletions

View File

@ -87,4 +87,9 @@ metadata:
example: '3'
description: |
Specifies the maximum number of HTTP requests that will be made to retry blob operations.
A value of zero means that no additional attempts will be made after a failure.
A value of zero means that no additional attempts will be made after a failure.
- name: disableEntityManagement
description: "Disable entity management. Skips the attempt to create the specified storage container. This is useful when operating with minimal Azure AD permissions."
example: "true"
default: '"false"'
type: bool

View File

@ -62,16 +62,19 @@ func CreateContainerStorageClient(parentCtx context.Context, log logger.Logger,
return nil, nil, err
}
// Create the container if it doesn't already exist
var accessLevel *azblob.PublicAccessType
if m.PublicAccessLevel != "" && m.PublicAccessLevel != "none" {
accessLevel = &m.PublicAccessLevel
}
ctx, cancel := context.WithTimeout(parentCtx, 30*time.Second)
defer cancel()
err = m.EnsureContainer(ctx, client, accessLevel)
if err != nil {
return nil, nil, fmt.Errorf("failed to create Azure Storage container %s: %w", m.ContainerName, err)
// if entity management is disabled, do not attempt to create the container
if !m.DisableEntityManagement {
// Create the container if it doesn't already exist
var accessLevel *azblob.PublicAccessType
if m.PublicAccessLevel != "" && m.PublicAccessLevel != "none" {
accessLevel = &m.PublicAccessLevel
}
ctx, cancel := context.WithTimeout(parentCtx, 30*time.Second)
defer cancel()
err = m.EnsureContainer(ctx, client, accessLevel)
if err != nil {
return nil, nil, fmt.Errorf("failed to create Azure Storage container %s: %w", m.ContainerName, err)
}
}
return client, m, nil

View File

@ -25,9 +25,10 @@ import (
)
type BlobStorageMetadata struct {
ContainerClientOpts `json:",inline" mapstructure:",squash"`
DecodeBase64 bool `json:"decodeBase64,string" mapstructure:"decodeBase64" mdonly:"bindings"`
PublicAccessLevel azblob.PublicAccessType
ContainerClientOpts `json:",inline" mapstructure:",squash"`
DecodeBase64 bool `json:"decodeBase64,string" mapstructure:"decodeBase64" mdonly:"bindings"`
PublicAccessLevel azblob.PublicAccessType
DisableEntityManagement bool `json:"disableEntityManagement,string" mapstructure:"disableEntityManagement"`
}
type ContainerClientOpts struct {

View File

@ -74,3 +74,8 @@ metadata:
description: |
Specifies the maximum number of HTTP requests that will be made to retry blob operations.
A value of zero means that no additional attempts will be made after a failure.
- name: disableEntityManagement
description: "Disable entity management. Skips the attempt to create the specified storage container. This is useful when operating with minimal Azure AD permissions."
example: "true"
default: '"false"'
type: bool

View File

@ -74,3 +74,8 @@ metadata:
description: |
Specifies the maximum number of HTTP requests that will be made to retry blob operations.
A value of zero means that no additional attempts will be made after a failure.
- name: disableEntityManagement
description: "Disable entity management. Skips the attempt to create the specified storage container. This is useful when operating with minimal Azure AD permissions."
example: "true"
default: '"false"'
type: bool