Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
48 changes: 38 additions & 10 deletions cli/azd/pkg/containerapps/container_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcontainers/armappcontainers/v3"
azdinternal "github.com/azure/azure-dev/cli/azd/internal"
"github.com/azure/azure-dev/cli/azd/pkg/account"
"github.com/azure/azure-dev/cli/azd/pkg/alpha"
"github.com/azure/azure-dev/cli/azd/pkg/convert"
"github.com/azure/azure-dev/cli/azd/pkg/httputil"
"github.com/benbjohnson/clock"
Expand Down Expand Up @@ -59,22 +60,25 @@ func NewContainerAppService(
httpClient httputil.HttpClient,
clock clock.Clock,
armClientOptions *arm.ClientOptions,
alphaFeatureManager *alpha.FeatureManager,
) ContainerAppService {
return &containerAppService{
credentialProvider: credentialProvider,
httpClient: httpClient,
userAgent: azdinternal.UserAgent(),
clock: clock,
armClientOptions: armClientOptions,
credentialProvider: credentialProvider,
httpClient: httpClient,
userAgent: azdinternal.UserAgent(),
clock: clock,
armClientOptions: armClientOptions,
alphaFeatureManager: alphaFeatureManager,
}
}

type containerAppService struct {
credentialProvider account.SubscriptionCredentialProvider
httpClient httputil.HttpClient
userAgent string
clock clock.Clock
armClientOptions *arm.ClientOptions
credentialProvider account.SubscriptionCredentialProvider
httpClient httputil.HttpClient
userAgent string
clock clock.Clock
armClientOptions *arm.ClientOptions
alphaFeatureManager *alpha.FeatureManager
}

type ContainerAppIngressConfiguration struct {
Expand Down Expand Up @@ -112,6 +116,8 @@ func (cas *containerAppService) GetIngressConfiguration(
// or updating the container app. When unset, we use the default API version of the armappcontainers.ContainerAppsClient.
const apiVersionKey = "api-version"

var persistCustomDomainsFeature = alpha.MustFeatureKey("aca.persistDomains")

func (cas *containerAppService) DeployYaml(
ctx context.Context,
subscriptionId string,
Expand All @@ -124,6 +130,28 @@ func (cas *containerAppService) DeployYaml(
return fmt.Errorf("decoding yaml: %w", err)
}

if shouldPersist := cas.alphaFeatureManager.IsEnabled(persistCustomDomainsFeature); shouldPersist {
aca, err := cas.getContainerApp(ctx, subscriptionId, resourceGroupName, appName)
if err == nil {
containerAppJson, err := json.Marshal(obj)
if err != nil {
panic("marshalling container app json failed")
}
var containerApp armappcontainers.ContainerApp
if err := json.Unmarshal(containerAppJson, &containerApp); err != nil {
return fmt.Errorf("converting to container app type: %w", err)
}
containerApp.Properties.Configuration.Ingress.CustomDomains = aca.Properties.Configuration.Ingress.CustomDomains
backToByte, err := json.Marshal(containerApp)
if err != nil {
panic("marshalling container app json failed")
}
if err := yaml.Unmarshal(backToByte, &obj); err != nil {
return fmt.Errorf("decoding yaml: %w", err)
}
}
}

var poller *runtime.Poller[armappcontainers.ContainerAppsClientCreateOrUpdateResponse]

// The way we make the initial request depends on whether the apiVersion is specified in the YAML.
Expand Down
2 changes: 2 additions & 0 deletions cli/azd/resources/alpha_features.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
description: "Enable Helm support for AKS deployments."
- id: aks.kustomize
description: "Enable Kustomize support for AKS deployments."
- id: aca.persistDomains
description: "Do not change custom domains when deploying Azure Container Apps."