-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3ae00c
commit 6bf1f87
Showing
183 changed files
with
14,752 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} |
145 changes: 145 additions & 0 deletions
145
internal/services/containerapps/container_app_environment_certificate_data_source.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}, | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
internal/services/containerapps/container_app_environment_certificate_data_source_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
Oops, something went wrong.