-
Notifications
You must be signed in to change notification settings - Fork 0
Add Crossplane Azure Blob Storage claim template and associated tests #12
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
Conversation
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.
Pull Request Overview
This PR adds support for provisioning Azure Blob Storage resources through Crossplane by introducing a comprehensive claim template and associated test suite. The implementation provides flexible configuration options for both existing and new Azure storage accounts with auto-generated naming conventions.
Key changes:
- Added infrastructure configuration section to values.yaml with detailed Azure storage account parameters
- Created Crossplane claim template for Azure Blob Storage with fallback logic for resource naming
- Implemented comprehensive test suite covering various configuration scenarios
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
charts/mycarrier-helm/values.yaml | Added infrastructure.azure.storage configuration section with extensive documentation and examples |
charts/mycarrier-helm/templates/crossplane/azure/storage/claim.yaml | New Crossplane claim template with conditional logic for storage account and resource group provisioning |
charts/mycarrier-helm/tests/crossplane_azure_storage_test.yaml | Test suite covering default naming, minimal configuration, empty configuration, and label verification scenarios |
name: {{ $instance.existingStorageAccount.name }} | ||
{{- else if $instance.newStorageAccount }} | ||
newStorageAccount: | ||
name: {{ $instance.newStorageAccount.name | default (printf "st%s%s" ($.Values.global.appStack | replace "-" "" | lower) ($.Values.environment.name | replace "-" "" | lower)) }} |
Copilot
AI
Aug 20, 2025
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.
The storage account name generation logic is duplicated on lines 11, 30, and 44. This violates the DRY principle and makes maintenance difficult. Consider extracting this logic into a helper template in _helpers.tpl.
Copilot uses AI. Check for mistakes.
{{- if $instance.writeConnectionSecretsToRef }} | ||
# writeConnectionSecretsToRef: | ||
# name: {{ $instance.writeConnectionSecretsToRef.name | default (printf "%s-connection" ($instance.name | default (printf "st-%s-%s" $.Values.global.appStack $.Values.environment.name))) }} | ||
# namespace: {{ $instance.writeConnectionSecretsToRef.namespace | default (printf "%s-%s" $.Values.environment.name $.Values.global.appStack) }} |
Copilot
AI
Aug 20, 2025
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.
The commented-out writeConnectionSecretsToRef section should either be implemented or removed. Having commented code in production templates can be confusing and adds maintenance overhead.
# namespace: {{ $instance.writeConnectionSecretsToRef.namespace | default (printf "%s-%s" $.Values.environment.name $.Values.global.appStack) }} | |
writeConnectionSecretsToRef: | |
name: {{ $instance.writeConnectionSecretsToRef.name | default (printf "%s-connection" ($instance.name | default (printf "st-%s-%s" $.Values.global.appStack $.Values.environment.name))) }} | |
namespace: {{ $instance.writeConnectionSecretsToRef.namespace | default (printf "%s-%s" $.Values.environment.name $.Values.global.appStack) }} |
Copilot uses AI. Check for mistakes.
) | ||
) | ||
) | ||
}} |
Copilot
AI
Aug 20, 2025
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.
[nitpick] The nested default expressions for name generation (lines 7-15) create complex and hard-to-read logic. This could be simplified by extracting the logic into a helper template or using a more straightforward conditional structure.
}} | |
{{- /* Helper template for Azure storage account name generation */ -}} | |
{{- define "azure.storage.account.name" -}} | |
{{- $instance := . -}} | |
{{- if $instance.name -}} | |
{{ $instance.name }} | |
{{- else if $instance.newStorageAccount.name -}} | |
{{ $instance.newStorageAccount.name }} | |
{{- else if $instance.existingStorageAccount.name -}} | |
{{ $instance.existingStorageAccount.name }} | |
{{- else -}} | |
{{ printf "st%s%s" ($.Values.global.appStack | replace "-" "") ($.Values.environment.name | replace "-" "") }} | |
{{- end -}} | |
{{- end }} | |
{{- if .Values.infrastructure.azure.storage.accounts }} | |
{{- range $instance := .Values.infrastructure.azure.storage.accounts }} | |
--- | |
apiVersion: azure.platform.io/v1alpha1 | |
kind: AzureBlobStorage | |
metadata: | |
name: {{ template "azure.storage.account.name" $instance }} |
Copilot uses AI. Check for mistakes.
{{- else }} | ||
# Default: create new resource group with auto-generated name (Azure compliant: 1-90 chars, alphanumeric, hyphens, underscores, periods, parentheses) | ||
newResourceGroup: | ||
name: {{ ($instance.newResourceGroup).name | default (printf "rg-%s-%s" $.Values.global.appStack $.Values.environment.name) }} |
Copilot
AI
Aug 20, 2025
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.
The resource group name generation logic is also duplicated. Consider creating a helper template for consistent resource naming patterns across the chart.
name: {{ ($instance.newResourceGroup).name | default (printf "rg-%s-%s" $.Values.global.appStack $.Values.environment.name) }} | |
name: {{ ($instance.newResourceGroup).name | default (include "azure.resourceGroupName" (dict "appStack" $.Values.global.appStack "environmentName" $.Values.environment.name)) }} |
Copilot uses AI. Check for mistakes.
Improvements based on Copilot review:
|
No description provided.