Skip to content
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

New Service: Containerapps #18008

Merged
merged 54 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
afe3591
WIP container app RP support
jackofallops Aug 11, 2022
58e6f7f
update cert tests with working files
jackofallops Aug 15, 2022
dfbeb62
add docs, fixup formatting
jackofallops Aug 16, 2022
522281f
make generate
jackofallops Aug 16, 2022
810f6c0
go mod vendor
jackofallops Aug 16, 2022
6e78c0f
docs frontmatter fix post make generate
jackofallops Aug 16, 2022
a50c12d
linter changes and some test fixes
jackofallops Aug 17, 2022
936af97
add customisedff for secret deletion detection
jackofallops Sep 9, 2022
4522c49
rebase and update for SDK changes. guard against secret removal
jackofallops Oct 11, 2022
1b85311
go mod
jackofallops Oct 11, 2022
822ab02
more tests
jackofallops Oct 11, 2022
8217350
add doc for container_app
jackofallops Oct 11, 2022
b54cf49
switch to new pointer helpers
jackofallops Oct 11, 2022
11441d3
remove unnecessary ptr func
jackofallops Oct 11, 2022
a0aead2
remove now unused utils func
jackofallops Oct 11, 2022
5697b25
fix requ inport test
jackofallops Oct 24, 2022
c6f3f79
update nil checking for read before update
jackofallops Oct 24, 2022
04eceeb
change secrets to set
jackofallops Oct 24, 2022
ccb9955
remove systemdata workarounds pending fix in go-azure-helpers
jackofallops Oct 25, 2022
72e1922
hack for updates to remove incomplete read property
jackofallops Oct 26, 2022
84c1af5
test fixes
jackofallops Oct 26, 2022
eb2511f
add tc override to limit concurrent tests due to managed env limits
jackofallops Oct 26, 2022
9336e3f
review feedback - schema naming
jackofallops Oct 27, 2022
77327ce
update generated files on registered name
jackofallops Oct 27, 2022
ccd4ab7
fix datasource read 404 returns
jackofallops Oct 27, 2022
d2bf6c4
missed doc update in review amendments
jackofallops Oct 27, 2022
e92a26a
add available location config to TC
jackofallops Oct 27, 2022
13a5880
update tests for schema changes
jackofallops Oct 27, 2022
42398ed
linting an generation
jackofallops Nov 15, 2022
9622de3
remove computed props from test configs
jackofallops Nov 17, 2022
63cc5c9
fixup volumes
jackofallops Jan 5, 2023
dc1971d
rebased for log analytics client update
jackofallops Jan 6, 2023
d1ceabd
linting fixes
jackofallops Jan 6, 2023
957cb3d
azurerm_container_app - fixup `ephemeral_storage` for new default (an…
jackofallops Jan 13, 2023
d6cebd0
azurerm_container_app_environment_certificate - Review feedback changes
jackofallops Jan 13, 2023
2dc5c4c
container_app_environment_certificate review feedback
jackofallops Jan 19, 2023
1da25ca
container_app_environment_dapr_component review feedback
jackofallops Jan 19, 2023
d3c9e2b
container_app_environment review feedback
jackofallops Jan 19, 2023
b8b455e
container_app_environment_storage review feedback
jackofallops Jan 19, 2023
fe2ceb9
container_app freedback pt1 plus validation
jackofallops Jan 19, 2023
b133c23
add container app env name validation
jackofallops Jan 23, 2023
fecb9af
refactor validation func names after move from helpers
jackofallops Jan 23, 2023
0134cc6
review changes - container_app et al
jackofallops Jan 24, 2023
b45e5bc
reintroduce identity
jackofallops Jan 24, 2023
08d46c9
rebased and updated for segment names
jackofallops Jan 24, 2023
7e6bf1a
fixup type to component_type rename
jackofallops Jan 24, 2023
4d2b6e5
add identity support to container_app
jackofallops Jan 25, 2023
7753479
fixup casing and ENUMs for probe transports
jackofallops Jan 25, 2023
e36c91d
test updates for probe transport casing change
jackofallops Jan 25, 2023
cc1b9a9
fixup requires import test for dapr_component
jackofallops Jan 25, 2023
44c42d3
shorten expectedError regex for test to remove quoted portion
jackofallops Jan 27, 2023
32bc929
re-review comments. identity comments pending
jackofallops Feb 2, 2023
221c9c5
fix potential crash
jackofallops Feb 2, 2023
585aaa9
fixup casing on revision_mode. Make ephemeral_storage computed only d…
jackofallops Feb 3, 2023
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
1 change: 1 addition & 0 deletions .teamcity/components/generated/services.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var services = mapOf(
"confidentialledger" to "Confidential Ledger",
"connections" to "Connections",
"consumption" to "Consumption",
"containerapps" to "Container Apps",
"containers" to "Container Services",
"cosmos" to "CosmosDB",
"costmanagement" to "Cost Management",
Expand Down
3 changes: 3 additions & 0 deletions .teamcity/components/settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ var serviceTestConfigurationOverrides = mapOf(
//Confidential Ledger
"confidentialledger" to testConfiguration(locationOverride = LocationConfiguration("eastus","southcentralus","westeurope", false)),

// Container App Managed Environments are limited to 5 per location, using 3 as they can take some time to clear
"containerapps" to testConfiguration(parallelism = 3, locationOverride = LocationConfiguration("westeurope","eastus","canadacentral", false)),

// The AKS API has a low rate limit
"containers" to testConfiguration(parallelism = 5, locationOverride = LocationConfiguration("eastus","westeurope","eastus2", false), useDevTestSubscription = true),

Expand Down
3 changes: 3 additions & 0 deletions internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
confidentialledger "github.com/hashicorp/terraform-provider-azurerm/internal/services/confidentialledger/client"
connections "github.com/hashicorp/terraform-provider-azurerm/internal/services/connections/client"
consumption "github.com/hashicorp/terraform-provider-azurerm/internal/services/consumption/client"
containerapps "github.com/hashicorp/terraform-provider-azurerm/internal/services/containerapps/client"
containerServices "github.com/hashicorp/terraform-provider-azurerm/internal/services/containers/client"
cosmosdb "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/client"
costmanagement "github.com/hashicorp/terraform-provider-azurerm/internal/services/costmanagement/client"
Expand Down Expand Up @@ -152,6 +153,7 @@ type Client struct {
ConfidentialLedger *confidentialledger.Client
Connections *connections.Client
Consumption *consumption.Client
ContainerApps *containerapps.Client
Containers *containerServices.Client
Cosmos *cosmosdb.Client
CostManagement *costmanagement.Client
Expand Down Expand Up @@ -274,6 +276,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
client.Connections = connections.NewClient(o)
client.Consumption = consumption.NewClient(o)
client.Containers = containerServices.NewContainersClient(o)
client.ContainerApps = containerapps.NewClient(o)
client.Cosmos = cosmosdb.NewClient(o)
client.CostManagement = costmanagement.NewClient(o)
client.CustomProviders = customproviders.NewClient(o)
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/services/confidentialledger"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/connections"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/consumption"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/containerapps"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/containers"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/costmanagement"
Expand Down Expand Up @@ -129,6 +130,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration {
compute.Registration{},
consumption.Registration{},
cosmos.Registration{},
containerapps.Registration{},
costmanagement.Registration{},
dashboard.Registration{},
databoxedge.Registration{},
Expand Down
49 changes: 49 additions & 0 deletions internal/services/containerapps/client/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package client

import (
"github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2022-03-01/certificates"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2022-03-01/containerapps"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2022-03-01/containerappsrevisions"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2022-03-01/daprcomponents"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2022-03-01/managedenvironments"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2022-03-01/managedenvironmentsstorages"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

type Client struct {
CertificatesClient *certificates.CertificatesClient
ContainerAppClient *containerapps.ContainerAppsClient
ContainerAppRevisionClient *containerappsrevisions.ContainerAppsRevisionsClient
DaprComponentsClient *daprcomponents.DaprComponentsClient
ManagedEnvironmentClient *managedenvironments.ManagedEnvironmentsClient
StorageClient *managedenvironmentsstorages.ManagedEnvironmentsStoragesClient
}

func NewClient(o *common.ClientOptions) *Client {
certificatesClient := certificates.NewCertificatesClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&certificatesClient.Client, o.ResourceManagerAuthorizer)

containerAppsClient := containerapps.NewContainerAppsClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&containerAppsClient.Client, o.ResourceManagerAuthorizer)

containerAppsRevisionsClient := containerappsrevisions.NewContainerAppsRevisionsClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&containerAppsRevisionsClient.Client, o.ResourceManagerAuthorizer)

managedEnvironmentClient := managedenvironments.NewManagedEnvironmentsClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&managedEnvironmentClient.Client, o.ResourceManagerAuthorizer)

managedEnvironmentStoragesClient := managedenvironmentsstorages.NewManagedEnvironmentsStoragesClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&managedEnvironmentStoragesClient.Client, o.ResourceManagerAuthorizer)

daprComponentClient := daprcomponents.NewDaprComponentsClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&daprComponentClient.Client, o.ResourceManagerAuthorizer)

return &Client{
CertificatesClient: &certificatesClient,
ContainerAppClient: &containerAppsClient,
ContainerAppRevisionClient: &containerAppsRevisionsClient,
DaprComponentsClient: &daprComponentClient,
ManagedEnvironmentClient: &managedEnvironmentClient,
StorageClient: &managedEnvironmentStoragesClient,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package containerapps

import (
"context"
"fmt"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2022-03-01/certificates"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/containerapps/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
)

type ContainerAppEnvironmentCertificateDataSource struct{}

type ContainerAppEnvironmentCertificateDataSourceModel struct {
Name string `tfschema:"name"`
ManagedEnvironmentId string `tfschema:"container_app_environment_id"`

// Read Only
SubjectName string `tfschema:"subject_name"`
Issuer string `tfschema:"issuer"`
IssueDate string `tfschema:"issue_date"`
ExpirationDate string `tfschema:"expiration_date"`
Thumbprint string `tfschema:"thumbprint"`
Tags map[string]interface{} `tfschema:"tags"`
}

var _ sdk.DataSource = ContainerAppEnvironmentCertificateDataSource{}

func (r ContainerAppEnvironmentCertificateDataSource) ModelObject() interface{} {
return &ContainerAppEnvironmentCertificateDataSourceModel{}
}

func (r ContainerAppEnvironmentCertificateDataSource) ResourceType() string {
return "azurerm_container_app_environment_certificate"
}

func (r ContainerAppEnvironmentCertificateDataSource) Arguments() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.CertificateName,
Description: "The name of the Container Apps Certificate.",
},

"container_app_environment_id": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: certificates.ValidateManagedEnvironmentID,
Description: "The Container App Managed Environment ID to configure this Certificate on.",
},
}
}

func (r ContainerAppEnvironmentCertificateDataSource) Attributes() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
"subject_name": {
Type: pluginsdk.TypeString,
Computed: true,
Description: "The Subject Name for the Certificate.",
},

"issuer": {
Type: pluginsdk.TypeString,
Computed: true,
Description: "The Certificate Issuer.",
},

"issue_date": {
Type: pluginsdk.TypeString,
Computed: true,
Description: "The date of issue for the Certificate.",
},

"expiration_date": {
Type: pluginsdk.TypeString,
Computed: true,
Description: "The expiration date for the Certificate.",
},

"thumbprint": {
Type: pluginsdk.TypeString,
Computed: true,
Description: "The Thumbprint of the Certificate.",
},

"tags": commonschema.TagsDataSource(),
}
}

func (r ContainerAppEnvironmentCertificateDataSource) Read() sdk.ResourceFunc {
return sdk.ResourceFunc{
Timeout: 5 * time.Minute,
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
client := metadata.Client.ContainerApps.CertificatesClient

var cert ContainerAppEnvironmentCertificateDataSourceModel
if err := metadata.Decode(&cert); err != nil {
return err
}

envId, err := certificates.ParseManagedEnvironmentID(cert.ManagedEnvironmentId)
if err != nil {
return err
}

id := certificates.NewCertificateID(envId.SubscriptionId, envId.ResourceGroupName, envId.ManagedEnvironmentName, cert.Name)

existing, err := client.Get(ctx, id)
if err != nil {
if response.WasNotFound(existing.HttpResponse) {
return fmt.Errorf("%s was not found", id)
}
return fmt.Errorf("reading %s: %+v", id, err)
}

cert.Name = id.CertificateName
cert.ManagedEnvironmentId = envId.ID()

if model := existing.Model; model != nil {
cert.Tags = tags.Flatten(model.Tags)

if props := model.Properties; props != nil {
cert.Issuer = pointer.From(props.Issuer)
cert.IssueDate = pointer.From(props.IssueDate)
cert.ExpirationDate = pointer.From(props.ExpirationDate)
cert.Thumbprint = pointer.From(props.Thumbprint)
cert.SubjectName = pointer.From(props.SubjectName)
}
}

metadata.SetID(id)

return metadata.Encode(&cert)
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package containerapps_test

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
)

type ContainerAppEnvironmentCertificateDataSource struct{}

func TestAccContainerAppEnvironmentCertificateDataSource_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "data.azurerm_container_app_environment_certificate", "test")
r := ContainerAppEnvironmentCertificateDataSource{}

data.DataSourceTest(t, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("subject_name").IsSet(),
check.That(data.ResourceName).Key("thumbprint").IsSet(),
check.That(data.ResourceName).Key("issue_date").IsSet(),
check.That(data.ResourceName).Key("expiration_date").IsSet(),
check.That(data.ResourceName).Key("issuer").IsSet(),
),
},
})
}

func (d ContainerAppEnvironmentCertificateDataSource) basic(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

data "azurerm_container_app_environment_certificate" "test" {
name = azurerm_container_app_environment_certificate.test.name
container_app_environment_id = azurerm_container_app_environment_certificate.test.container_app_environment_id
}


`, ContainerAppEnvironmentCertificateResource{}.basic(data))
}
Loading