Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions docs/spec/v1/buckets.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ with:
with the `AZURE_CLIENT_ID`
- Managed Identity with a system-assigned identity

is attempted by default. If no chain can be established, the bucket
is assumed to be publicly reachable.
is attempted by default.

When a reference is specified, it expects a Secret with one of the following
sets of `.data` fields:
Expand All @@ -359,23 +358,6 @@ For any Managed Identity and/or Microsoft Entra ID (Formerly Azure Active Direct
the base URL can be configured using `.data.authorityHost`. If not supplied,
[`AzurePublicCloud` is assumed](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity#AuthorityHost).

##### Azure example

```yaml
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: Bucket
metadata:
name: azure-public
namespace: default
spec:
interval: 5m0s
provider: azure
bucketName: podinfo
endpoint: https://podinfoaccount.blob.core.windows.net
timeout: 30s
```

##### Azure Service Principal Secret example

```yaml
Expand Down Expand Up @@ -1004,9 +986,6 @@ the `.spec.provider` field:
feature gate `ObjectLevelWorkloadIdentity` must be enabled, otherwise the
controller will error out.

**Note:** that for a publicly accessible object storage, you don't need to
provide a `secretRef` nor `serviceAccountName`.

**Important:** `.spec.secretRef` and `.spec.serviceAccountName` are mutually
exclusive and cannot be set at the same time. This constraint is enforced
at the CRD level.
Expand Down
16 changes: 4 additions & 12 deletions internal/bucket/azure/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,8 @@ func NewClient(ctx context.Context, obj *sourcev1.Bucket, opts ...Option) (c *Bl
err = fmt.Errorf("failed to create environment credential chain: %w", err)
return nil, err
}
if token != nil {
c.Client, err = azblob.NewClient(obj.Spec.Endpoint, token, clientOpts)
return
}

// Fallback to simple client.
c.Client, err = azblob.NewClientWithNoCredential(obj.Spec.Endpoint, clientOpts)
c.Client, err = azblob.NewClient(obj.Spec.Endpoint, token, clientOpts)
return
}

Expand Down Expand Up @@ -501,7 +496,8 @@ func sasTokenFromSecret(ep string, secret *corev1.Secret) (string, error) {
// environment variable, if found.
// - azidentity.ManagedIdentityCredential with defaults.
//
// If no valid token is created, it returns nil.
// The chain always contains at least one credential, so this never returns a nil
// TokenCredential; Azure buckets are not supported without authentication.
func chainCredentialWithSecret(ctx context.Context, secret *corev1.Secret, opts ...auth.Option) (azcore.TokenCredential, error) {
var creds []azcore.TokenCredential

Expand All @@ -519,11 +515,7 @@ func chainCredentialWithSecret(ctx context.Context, secret *corev1.Secret, opts
creds = append(creds, token)
}

if len(creds) > 0 {
return azidentity.NewChainedTokenCredential(creds, nil)
}

return nil, nil
return azidentity.NewChainedTokenCredential(creds, nil)
}

// extractAccountNameFromEndpoint extracts the Azure account name from the
Expand Down