From 0ad2225b5c67b11b7a96efcb04634d470e7d0488 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:17:02 +0800 Subject: [PATCH 01/16] `azurerm_trusted_signing_account` - new resource support --- go.mod | 4 +- go.sum | 8 +- internal/clients/client.go | 5 + internal/provider/services.go | 2 + .../services/codesigning/client/client.go | 27 ++ internal/services/codesigning/registration.go | 40 +++ .../trusted_signing_account_resource.go | 245 ++++++++++++++++++ .../trusted_signing_account_resource_test.go | 128 +++++++++ .../certificateprofiles/README.md | 103 ++++++++ .../certificateprofiles/client.go | 26 ++ .../certificateprofiles/constants.go | 245 ++++++++++++++++++ .../id_certificateprofile.go | 139 ++++++++++ .../id_codesigningaccount.go | 130 ++++++++++ .../certificateprofiles/method_create.go | 75 ++++++ .../certificateprofiles/method_delete.go | 70 +++++ .../certificateprofiles/method_get.go | 53 ++++ .../method_listbycodesigningaccount.go | 105 ++++++++ .../method_revokecertificate.go | 51 ++++ .../certificateprofiles/model_certificate.go | 15 ++ .../model_certificateprofile.go | 16 ++ .../model_certificateprofileproperties.go | 17 ++ .../certificateprofiles/model_revocation.go | 43 +++ .../model_revokecertificate.go | 27 ++ .../certificateprofiles/predicates.go | 27 ++ .../certificateprofiles/version.go | 10 + .../codesigning/2024-09-30-preview/client.go | 37 +++ .../codesigningaccounts/README.md | 138 ++++++++++ .../codesigningaccounts/client.go | 26 ++ .../codesigningaccounts/constants.go | 145 +++++++++++ .../id_codesigningaccount.go | 130 ++++++++++ .../method_checknameavailability.go | 59 +++++ .../codesigningaccounts/method_create.go | 75 ++++++ .../codesigningaccounts/method_delete.go | 70 +++++ .../codesigningaccounts/method_get.go | 53 ++++ .../method_listbyresourcegroup.go | 106 ++++++++ .../method_listbysubscription.go | 106 ++++++++ .../codesigningaccounts/method_update.go | 75 ++++++ .../codesigningaccounts/model_accountsku.go | 8 + .../model_accountskupatch.go | 8 + .../model_checknameavailability.go | 8 + .../model_checknameavailabilityresult.go | 10 + .../model_codesigningaccount.go | 18 ++ .../model_codesigningaccountpatch.go | 9 + ...model_codesigningaccountpatchproperties.go | 8 + .../model_codesigningaccountproperties.go | 10 + .../codesigningaccounts/predicates.go | 32 +++ .../codesigningaccounts/version.go | 10 + ...utonomousdatabasecharactersetproperties.go | 2 +- ...sdatabasenationalcharactersetproperties.go | 2 +- .../model_autonomousdbversionproperties.go | 2 +- .../dbnodes/model_dbnodeproperties.go | 17 +- .../model_dbsystemshapeproperties.go | 2 +- .../model_dnsprivateviewproperties.go | 30 +-- .../model_dnsprivatezoneproperties.go | 27 +- .../giversions/model_giversionproperties.go | 2 +- .../model_systemversionproperties.go | 2 +- .../appserviceplans/model_siteproperties.go | 1 + .../webapps/model_siteproperties.go | 1 + vendor/modules.txt | 7 +- .../r/trusted_signing_account.html.markdown | 75 ++++++ 60 files changed, 2865 insertions(+), 57 deletions(-) create mode 100644 internal/services/codesigning/client/client.go create mode 100644 internal/services/codesigning/registration.go create mode 100644 internal/services/codesigning/trusted_signing_account_resource.go create mode 100644 internal/services/codesigning/trusted_signing_account_resource_test.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_certificateprofile.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_codesigningaccount.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_create.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_listbycodesigningaccount.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_revokecertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofile.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofileproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revocation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revokecertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/id_codesigningaccount.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_checknameavailability.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_create.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbyresourcegroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbysubscription.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountsku.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountskupatch.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailability.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailabilityresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccount.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatch.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatchproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/version.go create mode 100644 website/docs/r/trusted_signing_account.html.markdown diff --git a/go.mod b/go.mod index b4fc159132f5..126e6c07387c 100644 --- a/go.mod +++ b/go.mod @@ -17,8 +17,8 @@ require ( github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 github.com/hashicorp/go-azure-helpers v0.70.1 - github.com/hashicorp/go-azure-sdk/resource-manager v0.20241009.1142232 - github.com/hashicorp/go-azure-sdk/sdk v0.20241009.1142232 + github.com/hashicorp/go-azure-sdk/resource-manager v0.20241017.1093842 + github.com/hashicorp/go-azure-sdk/sdk v0.20241017.1093842 github.com/hashicorp/go-hclog v1.6.3 github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-uuid v1.0.3 diff --git a/go.sum b/go.sum index d5c9fb1daa1c..5309789aa8cb 100644 --- a/go.sum +++ b/go.sum @@ -93,10 +93,10 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-azure-helpers v0.70.1 h1:7hlnRrZobMZxpOzdlNEsayzAayj/KRG4wpDS1jgo4GM= github.com/hashicorp/go-azure-helpers v0.70.1/go.mod h1:BmbF4JDYXK5sEmFeU5hcn8Br21uElcqLfdQxjatwQKw= -github.com/hashicorp/go-azure-sdk/resource-manager v0.20241009.1142232 h1:LAN6wm2cHFo56ly09tg0jXHioh4ygq3SzDoX+XBsMOU= -github.com/hashicorp/go-azure-sdk/resource-manager v0.20241009.1142232/go.mod h1:Zifz0xUVKdiNCzvp3HTa0CNCueZlxD2tdgqPf2QA3qs= -github.com/hashicorp/go-azure-sdk/sdk v0.20241009.1142232 h1:CxBWfnrsR/Vdyd+4N782xzYoqw5bczBSguwOpiF7VO8= -github.com/hashicorp/go-azure-sdk/sdk v0.20241009.1142232/go.mod h1:dMKF6bXrgGmy1d3pLzkmBpG2JIHgSAV2/OMSCEgyMwE= +github.com/hashicorp/go-azure-sdk/resource-manager v0.20241017.1093842 h1:GRGeerwPZiUHLkujG//JgbsB0gEoE65mnKhzQR9m6pg= +github.com/hashicorp/go-azure-sdk/resource-manager v0.20241017.1093842/go.mod h1:w43bj+jYD+kL5Tp1T+cxgmZjdU5/zjlEZ5A1nwJlEOs= +github.com/hashicorp/go-azure-sdk/sdk v0.20241017.1093842 h1:lqU3vkM+F2F8TrkIGnhLB4H9nBjtLlzkOVMWxZNtio8= +github.com/hashicorp/go-azure-sdk/sdk v0.20241017.1093842/go.mod h1:dMKF6bXrgGmy1d3pLzkmBpG2JIHgSAV2/OMSCEgyMwE= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= diff --git a/internal/clients/client.go b/internal/clients/client.go index a6d41ef7e774..a96b3a23def5 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -43,6 +43,7 @@ import ( blueprints "github.com/hashicorp/terraform-provider-azurerm/internal/services/blueprints/client" bot "github.com/hashicorp/terraform-provider-azurerm/internal/services/bot/client" cdn "github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/client" + codesigning "github.com/hashicorp/terraform-provider-azurerm/internal/services/codesigning/client" cognitiveServices "github.com/hashicorp/terraform-provider-azurerm/internal/services/cognitive/client" communication "github.com/hashicorp/terraform-provider-azurerm/internal/services/communication/client" compute "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/client" @@ -174,6 +175,7 @@ type Client struct { Blueprints *blueprints.Client Bot *bot.Client Cdn *cdn.Client + CodeSigning *codesigning.Client Cognitive *cognitiveServices.Client Communication *communication.Client Compute *compute.Client @@ -347,6 +349,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error return fmt.Errorf("building clients for Bot: %+v", err) } client.Cdn = cdn.NewClient(o) + if client.CodeSigning, err = codesigning.NewClient(o); err != nil { + return fmt.Errorf("building clients for Code Signing: %+v", err) + } if client.Cognitive, err = cognitiveServices.NewClient(o); err != nil { return fmt.Errorf("building clients for Cognitive: %+v", err) } diff --git a/internal/provider/services.go b/internal/provider/services.go index 1ce4a513b544..d13b5cdf2de0 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -24,6 +24,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/blueprints" "github.com/hashicorp/terraform-provider-azurerm/internal/services/bot" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/codesigning" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cognitive" "github.com/hashicorp/terraform-provider-azurerm/internal/services/communication" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute" @@ -148,6 +149,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { azurestackhci.Registration{}, batch.Registration{}, bot.Registration{}, + codesigning.Registration{}, cognitive.Registration{}, communication.Registration{}, compute.Registration{}, diff --git a/internal/services/codesigning/client/client.go b/internal/services/codesigning/client/client.go new file mode 100644 index 000000000000..800d446eb98d --- /dev/null +++ b/internal/services/codesigning/client/client.go @@ -0,0 +1,27 @@ +package client + +import ( + "fmt" + + codesigning_v2024_09_30_preview "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/terraform-provider-azurerm/internal/common" +) + +type Client struct { + V20240930previewClient codesigning_v2024_09_30_preview.Client +} + +func NewClient(o *common.ClientOptions) (*Client, error) { + V20240930previewClient, err := codesigning_v2024_09_30_preview.NewClientWithBaseURI(o.Environment.ResourceManager, func(c *resourcemanager.Client) { + o.Configure(c, o.Authorizers.ResourceManager) + }) + if err != nil { + return nil, fmt.Errorf("building client for codesigning v20240930preview: %+v", err) + } + + return &Client{ + V20240930previewClient: *V20240930previewClient, + }, nil +} diff --git a/internal/services/codesigning/registration.go b/internal/services/codesigning/registration.go new file mode 100644 index 000000000000..e92ca24471c5 --- /dev/null +++ b/internal/services/codesigning/registration.go @@ -0,0 +1,40 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package codesigning + +import ( + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" +) + +type Registration struct{} + +var _ sdk.TypedServiceRegistration = Registration{} + +func (r Registration) AssociatedGitHubLabel() string { + return "service/codesigning" +} + +// Name is the name of this Service +func (r Registration) Name() string { + return "Trusted Signing" +} + +// WebsiteCategories returns a list of categories which can be used for the sidebar +func (r Registration) WebsiteCategories() []string { + return []string{ + "Trusted Signing", + } +} + +// DataSources returns a list of Data Sources supported by this Service +func (r Registration) DataSources() []sdk.DataSource { + return []sdk.DataSource{} +} + +// Resources returns a list of Resources supported by this Service +func (r Registration) Resources() []sdk.Resource { + return []sdk.Resource{ + TrustedSigningAccountResource{}, + } +} diff --git a/internal/services/codesigning/trusted_signing_account_resource.go b/internal/services/codesigning/trusted_signing_account_resource.go new file mode 100644 index 000000000000..7fc9e9b88f62 --- /dev/null +++ b/internal/services/codesigning/trusted_signing_account_resource.go @@ -0,0 +1,245 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package codesigning + +import ( + "context" + "fmt" + "regexp" + "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-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type TruestedSigningAccountModel struct { + Name string `tfschema:"name"` + Location string `tfschema:"location"` + ResourceGroupName string `tfschema:"resource_group_name"` + AccountUri string `tfschema:"account_uri"` + Sku []Sku `tfschema:"sku"` + Tags map[string]string `tfschema:"tags"` +} + +type Sku struct { + Name string `tfschema:"name"` +} + +type TrustedSigningAccountResource struct{} + +var _ sdk.Resource = (*TrustedSigningAccountResource)(nil) + +func (m TrustedSigningAccountResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.All( + validation.StringLenBetween(3, 24), + validation.StringMatch( + regexp.MustCompile("^[A-Za-z][A-Za-z0-9]*(?:-[A-Za-z0-9]+)*$"), + "An account's name must be between 3-24 alphanumeric characters. The name must begin with a letter, end with a letter or digit, and not contain consecutive hyphens.", + ), + ), + }, + + "location": commonschema.Location(), + + "resource_group_name": commonschema.ResourceGroupName(), + + "sku": { + Type: pluginsdk.TypeList, + Required: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice( + codesigningaccounts.PossibleValuesForSkuName(), + false), + }, + }, + }, + }, + + "tags": commonschema.Tags(), + } +} + +func (m TrustedSigningAccountResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "account_uri": { + Type: pluginsdk.TypeString, + Computed: true, + }, + } +} + +func (m TrustedSigningAccountResource) ModelObject() interface{} { + return &TruestedSigningAccountModel{} +} + +func (m TrustedSigningAccountResource) ResourceType() string { + return "azurerm_trusted_signing_account" +} + +func (m TrustedSigningAccountResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { + client := meta.Client.CodeSigning.V20240930previewClient.CodeSigningAccounts + + var model TruestedSigningAccountModel + if err := meta.Decode(&model); err != nil { + return err + } + + subscriptionID := meta.Client.Account.SubscriptionId + id := codesigningaccounts.NewCodeSigningAccountID(subscriptionID, model.ResourceGroupName, model.Name) + existing, err := client.Get(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { + return fmt.Errorf("retrieving %s: %v", id, err) + } + return meta.ResourceRequiresImport(m.ResourceType(), id) + } + + req := codesigningaccounts.CodeSigningAccount{} + req.Name = &model.Name + req.Location = model.Location + req.Properties = pointer.To(codesigningaccounts.CodeSigningAccountProperties{}) + if len(model.Sku) > 0 { + ele := model.Sku[0] + req.Properties.Sku = pointer.To(codesigningaccounts.AccountSku{}) + req.Properties.Sku.Name = codesigningaccounts.SkuName(ele.Name) + } + req.Tags = &model.Tags + + future, err := client.Create(ctx, id, req) + if err != nil { + return fmt.Errorf("creating %s: %v", id, err) + } + + if err := future.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("waiting for creation of %s: %v", id, err) + } + + meta.SetID(id) + return nil + }, + } +} + +func (m TrustedSigningAccountResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { + id, err := codesigningaccounts.ParseCodeSigningAccountID(meta.ResourceData.Id()) + if err != nil { + return err + } + + client := meta.Client.CodeSigning.V20240930previewClient.CodeSigningAccounts + result, err := client.Get(ctx, *id) + if err != nil { + return err + } + + if result.Model == nil { + return fmt.Errorf("retrieving %s got nil model", id) + } + var output TruestedSigningAccountModel + output.Name = id.CodeSigningAccountName + output.ResourceGroupName = id.ResourceGroupName + + if result.Model == nil { + return fmt.Errorf("Get response nil Model") + } + model := result.Model + output.Location = model.Location + output.Tags = pointer.From(model.Tags) + if ptrProp := model.Properties; ptrProp != nil { + itemProp := *ptrProp + output.AccountUri = pointer.From(itemProp.AccountUri) + if ptrSku := itemProp.Sku; ptrSku != nil { + itemSku := *ptrSku + var accountSku Sku + accountSku.Name = string(itemSku.Name) + output.Sku = append(output.Sku, accountSku) + } + } + + return meta.Encode(&output) + }, + } +} + +func (m TrustedSigningAccountResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 10 * time.Minute, + Func: func(ctx context.Context, meta sdk.ResourceMetaData) (err error) { + client := meta.Client.CodeSigning.V20240930previewClient.CodeSigningAccounts + id, err := codesigningaccounts.ParseCodeSigningAccountID(meta.ResourceData.Id()) + if err != nil { + return err + } + + var model TruestedSigningAccountModel + if err = meta.Decode(&model); err != nil { + return fmt.Errorf("decoding %s: %+v", id, err) + } + + var upd codesigningaccounts.CodeSigningAccountPatch + + if meta.ResourceData.HasChange("sku") { + upd.Properties = pointer.To(codesigningaccounts.CodeSigningAccountPatchProperties{}) + if len(model.Sku) > 0 { + ele := model.Sku[0] + upd.Properties.Sku = pointer.To(codesigningaccounts.AccountSkuPatch{}) + upd.Properties.Sku.Name = pointer.To(codesigningaccounts.SkuName(ele.Name)) + } + } + if meta.ResourceData.HasChange("tags") { + upd.Tags = pointer.To(model.Tags) + } + + if _, err = client.Update(ctx, *id, upd); err != nil { + return fmt.Errorf("updating %s: %v", id, err) + } + + return nil + }, + } +} + +func (m TrustedSigningAccountResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 10 * time.Minute, + Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { + id, err := codesigningaccounts.ParseCodeSigningAccountID(meta.ResourceData.Id()) + if err != nil { + return err + } + + meta.Logger.Infof("deleting %s", id) + client := meta.Client.CodeSigning.V20240930previewClient.CodeSigningAccounts + if _, err = client.Delete(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %v", id, err) + } + return nil + }, + } +} + +func (m TrustedSigningAccountResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return codesigningaccounts.ValidateCodeSigningAccountID +} diff --git a/internal/services/codesigning/trusted_signing_account_resource_test.go b/internal/services/codesigning/trusted_signing_account_resource_test.go new file mode 100644 index 000000000000..2fd7c6ba0892 --- /dev/null +++ b/internal/services/codesigning/trusted_signing_account_resource_test.go @@ -0,0 +1,128 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package codesigning_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/codesigning" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type TrustedSigningAccountResource struct{} + +func (a TrustedSigningAccountResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := codesigningaccounts.ParseCodeSigningAccountID(state.ID) + if err != nil { + return nil, err + } + resp, err := client.CodeSigning.V20240930previewClient.CodeSigningAccounts.Get(ctx, *id) + if err != nil { + return nil, fmt.Errorf("retrieving TrustedSigningAccount %s: %+v", id, err) + } + return utils.Bool(resp.Model != nil), nil +} + +func TestAccTrustedSigningAccount_basic(t *testing.T) { + data := acceptance.BuildTestData(t, codesigning.TrustedSigningAccountResource{}.ResourceType(), "test") + r := TrustedSigningAccountResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccTrustedSigningAccount_update(t *testing.T) { + data := acceptance.BuildTestData(t, codesigning.TrustedSigningAccountResource{}.ResourceType(), "test") + r := TrustedSigningAccountResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccTrustedSigningAccount_complete(t *testing.T) { + data := acceptance.BuildTestData(t, codesigning.TrustedSigningAccountResource{}.ResourceType(), "test") + r := TrustedSigningAccountResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func (a TrustedSigningAccountResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_trusted_signing_account" "test" { + name = "acctest-%[2]s" + location = "%[3]s" + resource_group_name = azurerm_resource_group.test.name + sku { + name = "Basic" + } +} +`, a.template(data), data.RandomString, data.Locations.Primary) +} + +func (a TrustedSigningAccountResource) complete(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_trusted_signing_account" "test" { + + name = "acctest-%[2]s" + location = "%[3]s" + resource_group_name = azurerm_resource_group.test.name + sku { + name = "Premium" + } + tags = { + key = "example" + } +} +`, a.template(data), data.RandomString, data.Locations.Primary) +} + +func (a TrustedSigningAccountResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%[1]d" + location = "%[2]s" +} +`, data.RandomInteger, data.Locations.Primary) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/README.md new file mode 100644 index 000000000000..20a2cc90ad88 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/README.md @@ -0,0 +1,103 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles` Documentation + +The `certificateprofiles` SDK allows for interaction with Azure Resource Manager `codesigning` (API Version `2024-09-30-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles" +``` + + +### Client Initialization + +```go +client := certificateprofiles.NewCertificateProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CertificateProfilesClient.Create` + +```go +ctx := context.TODO() +id := certificateprofiles.NewCertificateProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName", "certificateProfileName") + +payload := certificateprofiles.CertificateProfile{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CertificateProfilesClient.Delete` + +```go +ctx := context.TODO() +id := certificateprofiles.NewCertificateProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName", "certificateProfileName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CertificateProfilesClient.Get` + +```go +ctx := context.TODO() +id := certificateprofiles.NewCertificateProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName", "certificateProfileName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificateProfilesClient.ListByCodeSigningAccount` + +```go +ctx := context.TODO() +id := certificateprofiles.NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + +// alternatively `client.ListByCodeSigningAccount(ctx, id)` can be used to do batched pagination +items, err := client.ListByCodeSigningAccountComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificateProfilesClient.RevokeCertificate` + +```go +ctx := context.TODO() +id := certificateprofiles.NewCertificateProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName", "certificateProfileName") + +payload := certificateprofiles.RevokeCertificate{ + // ... +} + + +read, err := client.RevokeCertificate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/client.go new file mode 100644 index 000000000000..e559a6f92422 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/client.go @@ -0,0 +1,26 @@ +package certificateprofiles + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProfilesClient struct { + Client *resourcemanager.Client +} + +func NewCertificateProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*CertificateProfilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "certificateprofiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificateProfilesClient: %+v", err) + } + + return &CertificateProfilesClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/constants.go new file mode 100644 index 000000000000..e3191e196a96 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/constants.go @@ -0,0 +1,245 @@ +package certificateprofiles + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProfileStatus string + +const ( + CertificateProfileStatusActive CertificateProfileStatus = "Active" + CertificateProfileStatusDisabled CertificateProfileStatus = "Disabled" + CertificateProfileStatusSuspended CertificateProfileStatus = "Suspended" +) + +func PossibleValuesForCertificateProfileStatus() []string { + return []string{ + string(CertificateProfileStatusActive), + string(CertificateProfileStatusDisabled), + string(CertificateProfileStatusSuspended), + } +} + +func (s *CertificateProfileStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProfileStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProfileStatus(input string) (*CertificateProfileStatus, error) { + vals := map[string]CertificateProfileStatus{ + "active": CertificateProfileStatusActive, + "disabled": CertificateProfileStatusDisabled, + "suspended": CertificateProfileStatusSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProfileStatus(input) + return &out, nil +} + +type CertificateStatus string + +const ( + CertificateStatusActive CertificateStatus = "Active" + CertificateStatusExpired CertificateStatus = "Expired" + CertificateStatusRevoked CertificateStatus = "Revoked" +) + +func PossibleValuesForCertificateStatus() []string { + return []string{ + string(CertificateStatusActive), + string(CertificateStatusExpired), + string(CertificateStatusRevoked), + } +} + +func (s *CertificateStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateStatus(input string) (*CertificateStatus, error) { + vals := map[string]CertificateStatus{ + "active": CertificateStatusActive, + "expired": CertificateStatusExpired, + "revoked": CertificateStatusRevoked, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateStatus(input) + return &out, nil +} + +type ProfileType string + +const ( + ProfileTypePrivateTrust ProfileType = "PrivateTrust" + ProfileTypePrivateTrustCIPolicy ProfileType = "PrivateTrustCIPolicy" + ProfileTypePublicTrust ProfileType = "PublicTrust" + ProfileTypePublicTrustTest ProfileType = "PublicTrustTest" + ProfileTypeVBSEnclave ProfileType = "VBSEnclave" +) + +func PossibleValuesForProfileType() []string { + return []string{ + string(ProfileTypePrivateTrust), + string(ProfileTypePrivateTrustCIPolicy), + string(ProfileTypePublicTrust), + string(ProfileTypePublicTrustTest), + string(ProfileTypeVBSEnclave), + } +} + +func (s *ProfileType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProfileType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProfileType(input string) (*ProfileType, error) { + vals := map[string]ProfileType{ + "privatetrust": ProfileTypePrivateTrust, + "privatetrustcipolicy": ProfileTypePrivateTrustCIPolicy, + "publictrust": ProfileTypePublicTrust, + "publictrusttest": ProfileTypePublicTrustTest, + "vbsenclave": ProfileTypeVBSEnclave, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProfileType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RevocationStatus string + +const ( + RevocationStatusFailed RevocationStatus = "Failed" + RevocationStatusInProgress RevocationStatus = "InProgress" + RevocationStatusSucceeded RevocationStatus = "Succeeded" +) + +func PossibleValuesForRevocationStatus() []string { + return []string{ + string(RevocationStatusFailed), + string(RevocationStatusInProgress), + string(RevocationStatusSucceeded), + } +} + +func (s *RevocationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevocationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevocationStatus(input string) (*RevocationStatus, error) { + vals := map[string]RevocationStatus{ + "failed": RevocationStatusFailed, + "inprogress": RevocationStatusInProgress, + "succeeded": RevocationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevocationStatus(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_certificateprofile.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_certificateprofile.go new file mode 100644 index 000000000000..dbf303fd6f40 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_certificateprofile.go @@ -0,0 +1,139 @@ +package certificateprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateProfileId{}) +} + +var _ resourceids.ResourceId = &CertificateProfileId{} + +// CertificateProfileId is a struct representing the Resource ID for a Certificate Profile +type CertificateProfileId struct { + SubscriptionId string + ResourceGroupName string + CodeSigningAccountName string + CertificateProfileName string +} + +// NewCertificateProfileID returns a new CertificateProfileId struct +func NewCertificateProfileID(subscriptionId string, resourceGroupName string, codeSigningAccountName string, certificateProfileName string) CertificateProfileId { + return CertificateProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CodeSigningAccountName: codeSigningAccountName, + CertificateProfileName: certificateProfileName, + } +} + +// ParseCertificateProfileID parses 'input' into a CertificateProfileId +func ParseCertificateProfileID(input string) (*CertificateProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateProfileIDInsensitively parses 'input' case-insensitively into a CertificateProfileId +// note: this method should only be used for API response data and not user input +func ParseCertificateProfileIDInsensitively(input string) (*CertificateProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateProfileId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CodeSigningAccountName, ok = input.Parsed["codeSigningAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeSigningAccountName", input) + } + + if id.CertificateProfileName, ok = input.Parsed["certificateProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateProfileName", input) + } + + return nil +} + +// ValidateCertificateProfileID checks that 'input' can be parsed as a Certificate Profile ID +func ValidateCertificateProfileID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Profile ID +func (id CertificateProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CodeSigning/codeSigningAccounts/%s/certificateProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CodeSigningAccountName, id.CertificateProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Profile ID +func (id CertificateProfileId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCodeSigning", "Microsoft.CodeSigning", "Microsoft.CodeSigning"), + resourceids.StaticSegment("staticCodeSigningAccounts", "codeSigningAccounts", "codeSigningAccounts"), + resourceids.UserSpecifiedSegment("codeSigningAccountName", "codeSigningAccountName"), + resourceids.StaticSegment("staticCertificateProfiles", "certificateProfiles", "certificateProfiles"), + resourceids.UserSpecifiedSegment("certificateProfileName", "certificateProfileName"), + } +} + +// String returns a human-readable description of this Certificate Profile ID +func (id CertificateProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Code Signing Account Name: %q", id.CodeSigningAccountName), + fmt.Sprintf("Certificate Profile Name: %q", id.CertificateProfileName), + } + return fmt.Sprintf("Certificate Profile (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_codesigningaccount.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_codesigningaccount.go new file mode 100644 index 000000000000..e62cccb18c10 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_codesigningaccount.go @@ -0,0 +1,130 @@ +package certificateprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CodeSigningAccountId{}) +} + +var _ resourceids.ResourceId = &CodeSigningAccountId{} + +// CodeSigningAccountId is a struct representing the Resource ID for a Code Signing Account +type CodeSigningAccountId struct { + SubscriptionId string + ResourceGroupName string + CodeSigningAccountName string +} + +// NewCodeSigningAccountID returns a new CodeSigningAccountId struct +func NewCodeSigningAccountID(subscriptionId string, resourceGroupName string, codeSigningAccountName string) CodeSigningAccountId { + return CodeSigningAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CodeSigningAccountName: codeSigningAccountName, + } +} + +// ParseCodeSigningAccountID parses 'input' into a CodeSigningAccountId +func ParseCodeSigningAccountID(input string) (*CodeSigningAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeSigningAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeSigningAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCodeSigningAccountIDInsensitively parses 'input' case-insensitively into a CodeSigningAccountId +// note: this method should only be used for API response data and not user input +func ParseCodeSigningAccountIDInsensitively(input string) (*CodeSigningAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeSigningAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeSigningAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CodeSigningAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CodeSigningAccountName, ok = input.Parsed["codeSigningAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeSigningAccountName", input) + } + + return nil +} + +// ValidateCodeSigningAccountID checks that 'input' can be parsed as a Code Signing Account ID +func ValidateCodeSigningAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCodeSigningAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Code Signing Account ID +func (id CodeSigningAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CodeSigning/codeSigningAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CodeSigningAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Code Signing Account ID +func (id CodeSigningAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCodeSigning", "Microsoft.CodeSigning", "Microsoft.CodeSigning"), + resourceids.StaticSegment("staticCodeSigningAccounts", "codeSigningAccounts", "codeSigningAccounts"), + resourceids.UserSpecifiedSegment("codeSigningAccountName", "codeSigningAccountName"), + } +} + +// String returns a human-readable description of this Code Signing Account ID +func (id CodeSigningAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Code Signing Account Name: %q", id.CodeSigningAccountName), + } + return fmt.Sprintf("Code Signing Account (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_create.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_create.go new file mode 100644 index 000000000000..2cca3685e90c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_create.go @@ -0,0 +1,75 @@ +package certificateprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CertificateProfile +} + +// Create ... +func (c CertificateProfilesClient) Create(ctx context.Context, id CertificateProfileId, input CertificateProfile) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c CertificateProfilesClient) CreateThenPoll(ctx context.Context, id CertificateProfileId, input CertificateProfile) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_delete.go new file mode 100644 index 000000000000..058788bfe34c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_delete.go @@ -0,0 +1,70 @@ +package certificateprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CertificateProfilesClient) Delete(ctx context.Context, id CertificateProfileId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c CertificateProfilesClient) DeleteThenPoll(ctx context.Context, id CertificateProfileId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_get.go new file mode 100644 index 000000000000..3f45ab39998f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_get.go @@ -0,0 +1,53 @@ +package certificateprofiles + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateProfile +} + +// Get ... +func (c CertificateProfilesClient) Get(ctx context.Context, id CertificateProfileId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CertificateProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_listbycodesigningaccount.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_listbycodesigningaccount.go new file mode 100644 index 000000000000..7c89789a7983 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_listbycodesigningaccount.go @@ -0,0 +1,105 @@ +package certificateprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByCodeSigningAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateProfile +} + +type ListByCodeSigningAccountCompleteResult struct { + LatestHttpResponse *http.Response + Items []CertificateProfile +} + +type ListByCodeSigningAccountCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByCodeSigningAccountCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByCodeSigningAccount ... +func (c CertificateProfilesClient) ListByCodeSigningAccount(ctx context.Context, id CodeSigningAccountId) (result ListByCodeSigningAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByCodeSigningAccountCustomPager{}, + Path: fmt.Sprintf("%s/certificateProfiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CertificateProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByCodeSigningAccountComplete retrieves all the results into a single object +func (c CertificateProfilesClient) ListByCodeSigningAccountComplete(ctx context.Context, id CodeSigningAccountId) (ListByCodeSigningAccountCompleteResult, error) { + return c.ListByCodeSigningAccountCompleteMatchingPredicate(ctx, id, CertificateProfileOperationPredicate{}) +} + +// ListByCodeSigningAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificateProfilesClient) ListByCodeSigningAccountCompleteMatchingPredicate(ctx context.Context, id CodeSigningAccountId, predicate CertificateProfileOperationPredicate) (result ListByCodeSigningAccountCompleteResult, err error) { + items := make([]CertificateProfile, 0) + + resp, err := c.ListByCodeSigningAccount(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByCodeSigningAccountCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_revokecertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_revokecertificate.go new file mode 100644 index 000000000000..b24ef796a1d9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_revokecertificate.go @@ -0,0 +1,51 @@ +package certificateprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RevokeCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RevokeCertificate ... +func (c CertificateProfilesClient) RevokeCertificate(ctx context.Context, id CertificateProfileId, input RevokeCertificate) (result RevokeCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/revokeCertificate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificate.go new file mode 100644 index 000000000000..ab301ee146e9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificate.go @@ -0,0 +1,15 @@ +package certificateprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Certificate struct { + CreatedDate *string `json:"createdDate,omitempty"` + EnhancedKeyUsage *string `json:"enhancedKeyUsage,omitempty"` + ExpiryDate *string `json:"expiryDate,omitempty"` + Revocation *Revocation `json:"revocation,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + Status *CertificateStatus `json:"status,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofile.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofile.go new file mode 100644 index 000000000000..2e47218eb895 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofile.go @@ -0,0 +1,16 @@ +package certificateprofiles + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CertificateProfileProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofileproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofileproperties.go new file mode 100644 index 000000000000..06390d807eba --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofileproperties.go @@ -0,0 +1,17 @@ +package certificateprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProfileProperties struct { + Certificates *[]Certificate `json:"certificates,omitempty"` + IdentityValidationId string `json:"identityValidationId"` + IncludeCity *bool `json:"includeCity,omitempty"` + IncludeCountry *bool `json:"includeCountry,omitempty"` + IncludePostalCode *bool `json:"includePostalCode,omitempty"` + IncludeState *bool `json:"includeState,omitempty"` + IncludeStreetAddress *bool `json:"includeStreetAddress,omitempty"` + ProfileType ProfileType `json:"profileType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *CertificateProfileStatus `json:"status,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revocation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revocation.go new file mode 100644 index 000000000000..1cd45d74417a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revocation.go @@ -0,0 +1,43 @@ +package certificateprofiles + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Revocation struct { + EffectiveAt *string `json:"effectiveAt,omitempty"` + FailureReason *string `json:"failureReason,omitempty"` + Reason *string `json:"reason,omitempty"` + Remarks *string `json:"remarks,omitempty"` + RequestedAt *string `json:"requestedAt,omitempty"` + Status *RevocationStatus `json:"status,omitempty"` +} + +func (o *Revocation) GetEffectiveAtAsTime() (*time.Time, error) { + if o.EffectiveAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EffectiveAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *Revocation) SetEffectiveAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EffectiveAt = &formatted +} + +func (o *Revocation) GetRequestedAtAsTime() (*time.Time, error) { + if o.RequestedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RequestedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *Revocation) SetRequestedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RequestedAt = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revokecertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revokecertificate.go new file mode 100644 index 000000000000..b8bea125a782 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revokecertificate.go @@ -0,0 +1,27 @@ +package certificateprofiles + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RevokeCertificate struct { + EffectiveAt string `json:"effectiveAt"` + Reason string `json:"reason"` + Remarks *string `json:"remarks,omitempty"` + SerialNumber string `json:"serialNumber"` + Thumbprint string `json:"thumbprint"` +} + +func (o *RevokeCertificate) GetEffectiveAtAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.EffectiveAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *RevokeCertificate) SetEffectiveAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EffectiveAt = formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/predicates.go new file mode 100644 index 000000000000..3044be14db45 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/predicates.go @@ -0,0 +1,27 @@ +package certificateprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProfileOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p CertificateProfileOperationPredicate) Matches(input CertificateProfile) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/version.go new file mode 100644 index 000000000000..2f1d629a008b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/version.go @@ -0,0 +1,10 @@ +package certificateprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-30-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/certificateprofiles/2024-09-30-preview" +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/client.go new file mode 100644 index 000000000000..868e723d9797 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/client.go @@ -0,0 +1,37 @@ +package v2024_09_30_preview + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + CertificateProfiles *certificateprofiles.CertificateProfilesClient + CodeSigningAccounts *codesigningaccounts.CodeSigningAccountsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + certificateProfilesClient, err := certificateprofiles.NewCertificateProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CertificateProfiles client: %+v", err) + } + configureFunc(certificateProfilesClient.Client) + + codeSigningAccountsClient, err := codesigningaccounts.NewCodeSigningAccountsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CodeSigningAccounts client: %+v", err) + } + configureFunc(codeSigningAccountsClient.Client) + + return &Client{ + CertificateProfiles: certificateProfilesClient, + CodeSigningAccounts: codeSigningAccountsClient, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/README.md new file mode 100644 index 000000000000..914bd4802c38 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/README.md @@ -0,0 +1,138 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts` Documentation + +The `codesigningaccounts` SDK allows for interaction with Azure Resource Manager `codesigning` (API Version `2024-09-30-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts" +``` + + +### Client Initialization + +```go +client := codesigningaccounts.NewCodeSigningAccountsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CodeSigningAccountsClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := codesigningaccounts.CheckNameAvailability{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CodeSigningAccountsClient.Create` + +```go +ctx := context.TODO() +id := codesigningaccounts.NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + +payload := codesigningaccounts.CodeSigningAccount{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CodeSigningAccountsClient.Delete` + +```go +ctx := context.TODO() +id := codesigningaccounts.NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CodeSigningAccountsClient.Get` + +```go +ctx := context.TODO() +id := codesigningaccounts.NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CodeSigningAccountsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CodeSigningAccountsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CodeSigningAccountsClient.Update` + +```go +ctx := context.TODO() +id := codesigningaccounts.NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + +payload := codesigningaccounts.CodeSigningAccountPatch{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/client.go new file mode 100644 index 000000000000..dabcf27b25c5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/client.go @@ -0,0 +1,26 @@ +package codesigningaccounts + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeSigningAccountsClient struct { + Client *resourcemanager.Client +} + +func NewCodeSigningAccountsClientWithBaseURI(sdkApi sdkEnv.Api) (*CodeSigningAccountsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "codesigningaccounts", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CodeSigningAccountsClient: %+v", err) + } + + return &CodeSigningAccountsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/constants.go new file mode 100644 index 000000000000..48cb12493f22 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/constants.go @@ -0,0 +1,145 @@ +package codesigningaccounts + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameUnavailabilityReason string + +const ( + NameUnavailabilityReasonAccountNameInvalid NameUnavailabilityReason = "AccountNameInvalid" + NameUnavailabilityReasonAlreadyExists NameUnavailabilityReason = "AlreadyExists" +) + +func PossibleValuesForNameUnavailabilityReason() []string { + return []string{ + string(NameUnavailabilityReasonAccountNameInvalid), + string(NameUnavailabilityReasonAlreadyExists), + } +} + +func (s *NameUnavailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNameUnavailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNameUnavailabilityReason(input string) (*NameUnavailabilityReason, error) { + vals := map[string]NameUnavailabilityReason{ + "accountnameinvalid": NameUnavailabilityReasonAccountNameInvalid, + "alreadyexists": NameUnavailabilityReasonAlreadyExists, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NameUnavailabilityReason(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameBasic SkuName = "Basic" + SkuNamePremium SkuName = "Premium" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameBasic), + string(SkuNamePremium), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "basic": SkuNameBasic, + "premium": SkuNamePremium, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/id_codesigningaccount.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/id_codesigningaccount.go new file mode 100644 index 000000000000..345dd35145c5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/id_codesigningaccount.go @@ -0,0 +1,130 @@ +package codesigningaccounts + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CodeSigningAccountId{}) +} + +var _ resourceids.ResourceId = &CodeSigningAccountId{} + +// CodeSigningAccountId is a struct representing the Resource ID for a Code Signing Account +type CodeSigningAccountId struct { + SubscriptionId string + ResourceGroupName string + CodeSigningAccountName string +} + +// NewCodeSigningAccountID returns a new CodeSigningAccountId struct +func NewCodeSigningAccountID(subscriptionId string, resourceGroupName string, codeSigningAccountName string) CodeSigningAccountId { + return CodeSigningAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CodeSigningAccountName: codeSigningAccountName, + } +} + +// ParseCodeSigningAccountID parses 'input' into a CodeSigningAccountId +func ParseCodeSigningAccountID(input string) (*CodeSigningAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeSigningAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeSigningAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCodeSigningAccountIDInsensitively parses 'input' case-insensitively into a CodeSigningAccountId +// note: this method should only be used for API response data and not user input +func ParseCodeSigningAccountIDInsensitively(input string) (*CodeSigningAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeSigningAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeSigningAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CodeSigningAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CodeSigningAccountName, ok = input.Parsed["codeSigningAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeSigningAccountName", input) + } + + return nil +} + +// ValidateCodeSigningAccountID checks that 'input' can be parsed as a Code Signing Account ID +func ValidateCodeSigningAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCodeSigningAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Code Signing Account ID +func (id CodeSigningAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CodeSigning/codeSigningAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CodeSigningAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Code Signing Account ID +func (id CodeSigningAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCodeSigning", "Microsoft.CodeSigning", "Microsoft.CodeSigning"), + resourceids.StaticSegment("staticCodeSigningAccounts", "codeSigningAccounts", "codeSigningAccounts"), + resourceids.UserSpecifiedSegment("codeSigningAccountName", "codeSigningAccountName"), + } +} + +// String returns a human-readable description of this Code Signing Account ID +func (id CodeSigningAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Code Signing Account Name: %q", id.CodeSigningAccountName), + } + return fmt.Sprintf("Code Signing Account (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_checknameavailability.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_checknameavailability.go new file mode 100644 index 000000000000..2a800d7f6115 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_checknameavailability.go @@ -0,0 +1,59 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c CodeSigningAccountsClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailability) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.CodeSigning/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CheckNameAvailabilityResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_create.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_create.go new file mode 100644 index 000000000000..7d665533d73e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_create.go @@ -0,0 +1,75 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CodeSigningAccount +} + +// Create ... +func (c CodeSigningAccountsClient) Create(ctx context.Context, id CodeSigningAccountId, input CodeSigningAccount) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c CodeSigningAccountsClient) CreateThenPoll(ctx context.Context, id CodeSigningAccountId, input CodeSigningAccount) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_delete.go new file mode 100644 index 000000000000..88c742301081 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_delete.go @@ -0,0 +1,70 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CodeSigningAccountsClient) Delete(ctx context.Context, id CodeSigningAccountId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c CodeSigningAccountsClient) DeleteThenPoll(ctx context.Context, id CodeSigningAccountId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_get.go new file mode 100644 index 000000000000..f56a3fc5585b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_get.go @@ -0,0 +1,53 @@ +package codesigningaccounts + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CodeSigningAccount +} + +// Get ... +func (c CodeSigningAccountsClient) Get(ctx context.Context, id CodeSigningAccountId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CodeSigningAccount + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbyresourcegroup.go new file mode 100644 index 000000000000..dcbd40870936 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CodeSigningAccount +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []CodeSigningAccount +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c CodeSigningAccountsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CodeSigning/codeSigningAccounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CodeSigningAccount `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c CodeSigningAccountsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CodeSigningAccountOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CodeSigningAccountsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CodeSigningAccountOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]CodeSigningAccount, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbysubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbysubscription.go new file mode 100644 index 000000000000..af7e03ceac42 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbysubscription.go @@ -0,0 +1,106 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CodeSigningAccount +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []CodeSigningAccount +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c CodeSigningAccountsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CodeSigning/codeSigningAccounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CodeSigningAccount `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c CodeSigningAccountsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, CodeSigningAccountOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CodeSigningAccountsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate CodeSigningAccountOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]CodeSigningAccount, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_update.go new file mode 100644 index 000000000000..d1a3d395e082 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_update.go @@ -0,0 +1,75 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CodeSigningAccount +} + +// Update ... +func (c CodeSigningAccountsClient) Update(ctx context.Context, id CodeSigningAccountId, input CodeSigningAccountPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c CodeSigningAccountsClient) UpdateThenPoll(ctx context.Context, id CodeSigningAccountId, input CodeSigningAccountPatch) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountsku.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountsku.go new file mode 100644 index 000000000000..301eca38210d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountsku.go @@ -0,0 +1,8 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountSku struct { + Name SkuName `json:"name"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountskupatch.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountskupatch.go new file mode 100644 index 000000000000..0f09a8660b89 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountskupatch.go @@ -0,0 +1,8 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountSkuPatch struct { + Name *SkuName `json:"name,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailability.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailability.go new file mode 100644 index 000000000000..f01c090ec694 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailability.go @@ -0,0 +1,8 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailability struct { + Name string `json:"name"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailabilityresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailabilityresult.go new file mode 100644 index 000000000000..9fee693bf9ff --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailabilityresult.go @@ -0,0 +1,10 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResult struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *NameUnavailabilityReason `json:"reason,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccount.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccount.go new file mode 100644 index 000000000000..e21b9375fb82 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccount.go @@ -0,0 +1,18 @@ +package codesigningaccounts + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeSigningAccount struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CodeSigningAccountProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatch.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatch.go new file mode 100644 index 000000000000..704c7e415880 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatch.go @@ -0,0 +1,9 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeSigningAccountPatch struct { + Properties *CodeSigningAccountPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatchproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatchproperties.go new file mode 100644 index 000000000000..7ddd60275fe9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatchproperties.go @@ -0,0 +1,8 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeSigningAccountPatchProperties struct { + Sku *AccountSkuPatch `json:"sku,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountproperties.go new file mode 100644 index 000000000000..30d1d196fb96 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountproperties.go @@ -0,0 +1,10 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeSigningAccountProperties struct { + AccountUri *string `json:"accountUri,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Sku *AccountSku `json:"sku,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/predicates.go new file mode 100644 index 000000000000..cea979dacf80 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/predicates.go @@ -0,0 +1,32 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeSigningAccountOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CodeSigningAccountOperationPredicate) Matches(input CodeSigningAccount) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/version.go new file mode 100644 index 000000000000..4f6d304868e9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/version.go @@ -0,0 +1,10 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-30-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/codesigningaccounts/2024-09-30-preview" +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go index 901e37d3b140..7be031b5131a 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go @@ -4,5 +4,5 @@ package autonomousdatabasecharactersets // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type AutonomousDatabaseCharacterSetProperties struct { - CharacterSet *string `json:"characterSet,omitempty"` + CharacterSet string `json:"characterSet"` } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go index 075fdf79954a..f55ed168e3f8 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go @@ -4,5 +4,5 @@ package autonomousdatabasenationalcharactersets // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type AutonomousDatabaseNationalCharacterSetProperties struct { - CharacterSet *string `json:"characterSet,omitempty"` + CharacterSet string `json:"characterSet"` } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go index 0a7cad672e79..a3d0639949b6 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go @@ -9,5 +9,5 @@ type AutonomousDbVersionProperties struct { IsDefaultForPaid *bool `json:"isDefaultForPaid,omitempty"` IsFreeTierEnabled *bool `json:"isFreeTierEnabled,omitempty"` IsPaidEnabled *bool `json:"isPaidEnabled,omitempty"` - Version *string `json:"version,omitempty"` + Version string `json:"version"` } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go index 57c6546805b9..f8ed526badb5 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go @@ -17,34 +17,31 @@ type DbNodeProperties struct { CpuCoreCount *int64 `json:"cpuCoreCount,omitempty"` DbNodeStorageSizeInGbs *int64 `json:"dbNodeStorageSizeInGbs,omitempty"` DbServerId *string `json:"dbServerId,omitempty"` - DbSystemId *string `json:"dbSystemId,omitempty"` + DbSystemId string `json:"dbSystemId"` FaultDomain *string `json:"faultDomain,omitempty"` HostIPId *string `json:"hostIpId,omitempty"` Hostname *string `json:"hostname,omitempty"` LifecycleDetails *string `json:"lifecycleDetails,omitempty"` - LifecycleState *DbNodeProvisioningState `json:"lifecycleState,omitempty"` + LifecycleState DbNodeProvisioningState `json:"lifecycleState"` MaintenanceType *DbNodeMaintenanceType `json:"maintenanceType,omitempty"` MemorySizeInGbs *int64 `json:"memorySizeInGbs,omitempty"` - Ocid *string `json:"ocid,omitempty"` + Ocid string `json:"ocid"` ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` SoftwareStorageSizeInGb *int64 `json:"softwareStorageSizeInGb,omitempty"` - TimeCreated *string `json:"timeCreated,omitempty"` + TimeCreated string `json:"timeCreated"` TimeMaintenanceWindowEnd *string `json:"timeMaintenanceWindowEnd,omitempty"` TimeMaintenanceWindowStart *string `json:"timeMaintenanceWindowStart,omitempty"` Vnic2Id *string `json:"vnic2Id,omitempty"` - VnicId *string `json:"vnicId,omitempty"` + VnicId string `json:"vnicId"` } func (o *DbNodeProperties) GetTimeCreatedAsTime() (*time.Time, error) { - if o.TimeCreated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeCreated, "2006-01-02T15:04:05Z07:00") } func (o *DbNodeProperties) SetTimeCreatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeCreated = &formatted + o.TimeCreated = formatted } func (o *DbNodeProperties) GetTimeMaintenanceWindowEndAsTime() (*time.Time, error) { diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go index a7642317091f..126cec39c376 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go @@ -4,7 +4,7 @@ package dbsystemshapes // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type DbSystemShapeProperties struct { - AvailableCoreCount *int64 `json:"availableCoreCount,omitempty"` + AvailableCoreCount int64 `json:"availableCoreCount"` AvailableCoreCountPerNode *int64 `json:"availableCoreCountPerNode,omitempty"` AvailableDataStorageInTbs *int64 `json:"availableDataStorageInTbs,omitempty"` AvailableDataStoragePerServerInTbs *float64 `json:"availableDataStoragePerServerInTbs,omitempty"` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go index 40cd3cf0a934..6f06446ebce9 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go @@ -10,36 +10,30 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type DnsPrivateViewProperties struct { - DisplayName *string `json:"displayName,omitempty"` - IsProtected *bool `json:"isProtected,omitempty"` - LifecycleState *DnsPrivateViewsLifecycleState `json:"lifecycleState,omitempty"` - Ocid *string `json:"ocid,omitempty"` - ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` - Self *string `json:"self,omitempty"` - TimeCreated *string `json:"timeCreated,omitempty"` - TimeUpdated *string `json:"timeUpdated,omitempty"` + DisplayName string `json:"displayName"` + IsProtected bool `json:"isProtected"` + LifecycleState DnsPrivateViewsLifecycleState `json:"lifecycleState"` + Ocid string `json:"ocid"` + ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` + Self string `json:"self"` + TimeCreated string `json:"timeCreated"` + TimeUpdated string `json:"timeUpdated"` } func (o *DnsPrivateViewProperties) GetTimeCreatedAsTime() (*time.Time, error) { - if o.TimeCreated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeCreated, "2006-01-02T15:04:05Z07:00") } func (o *DnsPrivateViewProperties) SetTimeCreatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeCreated = &formatted + o.TimeCreated = formatted } func (o *DnsPrivateViewProperties) GetTimeUpdatedAsTime() (*time.Time, error) { - if o.TimeUpdated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeUpdated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeUpdated, "2006-01-02T15:04:05Z07:00") } func (o *DnsPrivateViewProperties) SetTimeUpdatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeUpdated = &formatted + o.TimeUpdated = formatted } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go index 680bff102fe7..5c84986be864 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go @@ -10,26 +10,23 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type DnsPrivateZoneProperties struct { - IsProtected *bool `json:"isProtected,omitempty"` - LifecycleState *DnsPrivateZonesLifecycleState `json:"lifecycleState,omitempty"` - Ocid *string `json:"ocid,omitempty"` - ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` - Self *string `json:"self,omitempty"` - Serial *int64 `json:"serial,omitempty"` - TimeCreated *string `json:"timeCreated,omitempty"` - Version *string `json:"version,omitempty"` - ViewId *string `json:"viewId,omitempty"` - ZoneType *ZoneType `json:"zoneType,omitempty"` + IsProtected bool `json:"isProtected"` + LifecycleState DnsPrivateZonesLifecycleState `json:"lifecycleState"` + Ocid string `json:"ocid"` + ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` + Self string `json:"self"` + Serial int64 `json:"serial"` + TimeCreated string `json:"timeCreated"` + Version string `json:"version"` + ViewId *string `json:"viewId,omitempty"` + ZoneType ZoneType `json:"zoneType"` } func (o *DnsPrivateZoneProperties) GetTimeCreatedAsTime() (*time.Time, error) { - if o.TimeCreated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeCreated, "2006-01-02T15:04:05Z07:00") } func (o *DnsPrivateZoneProperties) SetTimeCreatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeCreated = &formatted + o.TimeCreated = formatted } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go index ca86e602826a..0a54f3aaee23 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go @@ -4,5 +4,5 @@ package giversions // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type GiVersionProperties struct { - Version *string `json:"version,omitempty"` + Version string `json:"version"` } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go index 5eda04761332..2684d8672adb 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go @@ -4,5 +4,5 @@ package systemversions // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type SystemVersionProperties struct { - SystemVersion *string `json:"systemVersion,omitempty"` + SystemVersion string `json:"systemVersion"` } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go index e2cb76178838..1c11378cc2e0 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go @@ -24,6 +24,7 @@ type SiteProperties struct { DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` HTTPSOnly *bool `json:"httpsOnly,omitempty"` HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps/model_siteproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps/model_siteproperties.go index dcb3e020b678..7f844ec75786 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps/model_siteproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps/model_siteproperties.go @@ -24,6 +24,7 @@ type SiteProperties struct { DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` HTTPSOnly *bool `json:"httpsOnly,omitempty"` HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` diff --git a/vendor/modules.txt b/vendor/modules.txt index 475723526d83..4d4742919a6d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -148,7 +148,7 @@ github.com/hashicorp/go-azure-helpers/resourcemanager/tags github.com/hashicorp/go-azure-helpers/resourcemanager/zones github.com/hashicorp/go-azure-helpers/sender github.com/hashicorp/go-azure-helpers/storage -# github.com/hashicorp/go-azure-sdk/resource-manager v0.20241009.1142232 +# github.com/hashicorp/go-azure-sdk/resource-manager v0.20241017.1093842 ## explicit; go 1.21 github.com/hashicorp/go-azure-sdk/resource-manager/aad/2021-05-01/domainservices github.com/hashicorp/go-azure-sdk/resource-manager/aadb2c/2021-04-01-preview @@ -315,6 +315,9 @@ github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01/capabi github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01/experiments github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01/targets github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01/targettypes +github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview +github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles +github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2023-05-01/cognitiveservicesaccounts github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2023-05-01/deployments github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/communicationservices @@ -1116,7 +1119,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2023-04-01/saplands github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2023-04-01/saprecommendations github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2023-04-01/sapsupportedsku github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2023-04-01/sapvirtualinstances -# github.com/hashicorp/go-azure-sdk/sdk v0.20241009.1142232 +# github.com/hashicorp/go-azure-sdk/sdk v0.20241017.1093842 ## explicit; go 1.21 github.com/hashicorp/go-azure-sdk/sdk/auth github.com/hashicorp/go-azure-sdk/sdk/auth/autorest diff --git a/website/docs/r/trusted_signing_account.html.markdown b/website/docs/r/trusted_signing_account.html.markdown new file mode 100644 index 000000000000..b40d473611b2 --- /dev/null +++ b/website/docs/r/trusted_signing_account.html.markdown @@ -0,0 +1,75 @@ +--- +subcategory: "Trusted Signing" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_trusted_signing_account" +description: |- + Manages a Trusted Signing Account. +--- + +# azurerm_trusted_signing_account + +Manages a Trusted Signing Account. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example" + location = "West Europe" +} + +resource "azurerm_trusted_signing_account" "example" { + resource_group_name = "example" + location = "West Europe" + sku { + name = "Basic" + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name which should be used for this Trusted Signing. Changing this forces a new Trusted Signing Account to be created. + +* `location` - (Required) The Azure Region where the Trusted Signing should exist. Changing this forces a new Trusted Signing Account to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the Trusted Signing should exist. Changing this forces a new Trusted Signing to be created. + +* `sku` - (Required) One `sku` blocks as defined below. + +--- + +* `tags` - (Optional) A mapping of tags which should be assigned to the Trusted Signing. + +--- + +A `sku` block supports the following: + +* `name` - (Required) The sku name of this Trusted Signing Account. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Trusted Signing. + +* `account_uri` - The URI of the trusted signing account which is used during signing files. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Trusted Signing. +* `read` - (Defaults to 5 minutes) Used when retrieving the Trusted Signing. +* `update` - (Defaults to 10 minutes) Used when updating the Trusted Signing. +* `delete` - (Defaults to 10 minutes) Used when deleting the Trusted Signing. + +## Import + +Trusted Signings can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_trusted_signing_account.example /subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.CodeSigning/codeSigningAccounts/example-account +``` From 7c0315a18ff78b22d626962dd18bdacb360710d3 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:24:04 +0800 Subject: [PATCH 02/16] make generate --- .github/labeler-issue-triage.yml | 3 +++ .github/labeler-pull-request-triage.yml | 5 +++++ .teamcity/components/generated/services.kt | 1 + website/allowed-subcategories | 1 + 4 files changed, 10 insertions(+) diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index b63e12b40d7b..fb748c0e33c9 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -65,6 +65,9 @@ service/bots: service/cdn: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_cdn_((.|\n)*)###' +service/codesigning: + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_trusted_signing_account((.|\n)*)###' + service/cognitive-services: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(ai_services|cognitive_)((.|\n)*)###' diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index a3b481100fa2..dfd5b8a1ce19 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -108,6 +108,11 @@ service/cdn: - any-glob-to-any-file: - internal/services/cdn/**/* +service/codesigning: +- changed-files: + - any-glob-to-any-file: + - internal/services/codesigning/**/* + service/cognitive-services: - changed-files: - any-glob-to-any-file: diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index a84ce744aaa8..efd50718f84a 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -124,6 +124,7 @@ var services = mapOf( "synapse" to "Synapse", "systemcentervirtualmachinemanager" to "System Center Virtual Machine Manager", "trafficmanager" to "Traffic Manager", + "codesigning" to "Trusted Signing", "vmware" to "VMware", "voiceservices" to "Voice Services", "web" to "Web", diff --git a/website/allowed-subcategories b/website/allowed-subcategories index f2245db4b136..bb5a08eb17cc 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -105,6 +105,7 @@ Stream Analytics Synapse System Center Virtual Machine Manager Template +Trusted Signing Voice Services Web PubSub Workloads \ No newline at end of file From 041d9baf43ffea906ae71aa8353690f8c447b6d4 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:39:25 +0800 Subject: [PATCH 03/16] update per comments --- .../services/codesigning/client/client.go | 4 +- .../trusted_signing_account_resource.go | 68 ++++++------------- .../trusted_signing_account_resource_test.go | 18 ++--- .../r/trusted_signing_account.html.markdown | 7 +- 4 files changed, 35 insertions(+), 62 deletions(-) diff --git a/internal/services/codesigning/client/client.go b/internal/services/codesigning/client/client.go index 800d446eb98d..a5288d8ee7ff 100644 --- a/internal/services/codesigning/client/client.go +++ b/internal/services/codesigning/client/client.go @@ -10,7 +10,7 @@ import ( ) type Client struct { - V20240930previewClient codesigning_v2024_09_30_preview.Client + Client codesigning_v2024_09_30_preview.Client } func NewClient(o *common.ClientOptions) (*Client, error) { @@ -22,6 +22,6 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } return &Client{ - V20240930previewClient: *V20240930previewClient, + Client: *V20240930previewClient, }, nil } diff --git a/internal/services/codesigning/trusted_signing_account_resource.go b/internal/services/codesigning/trusted_signing_account_resource.go index 7fc9e9b88f62..b52b35c7c92f 100644 --- a/internal/services/codesigning/trusted_signing_account_resource.go +++ b/internal/services/codesigning/trusted_signing_account_resource.go @@ -23,14 +23,10 @@ type TruestedSigningAccountModel struct { Location string `tfschema:"location"` ResourceGroupName string `tfschema:"resource_group_name"` AccountUri string `tfschema:"account_uri"` - Sku []Sku `tfschema:"sku"` + SkuName string `tfschema:"sku_name"` Tags map[string]string `tfschema:"tags"` } -type Sku struct { - Name string `tfschema:"name"` -} - type TrustedSigningAccountResource struct{} var _ sdk.Resource = (*TrustedSigningAccountResource)(nil) @@ -54,21 +50,12 @@ func (m TrustedSigningAccountResource) Arguments() map[string]*pluginsdk.Schema "resource_group_name": commonschema.ResourceGroupName(), - "sku": { - Type: pluginsdk.TypeList, + "sku_name": { + Type: pluginsdk.TypeString, Required: true, - MaxItems: 1, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice( - codesigningaccounts.PossibleValuesForSkuName(), - false), - }, - }, - }, + ValidateFunc: validation.StringInSlice( + codesigningaccounts.PossibleValuesForSkuName(), + false), }, "tags": commonschema.Tags(), @@ -96,7 +83,7 @@ func (m TrustedSigningAccountResource) Create() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 30 * time.Minute, Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { - client := meta.Client.CodeSigning.V20240930previewClient.CodeSigningAccounts + client := meta.Client.CodeSigning.Client.CodeSigningAccounts var model TruestedSigningAccountModel if err := meta.Decode(&model); err != nil { @@ -117,22 +104,16 @@ func (m TrustedSigningAccountResource) Create() sdk.ResourceFunc { req.Name = &model.Name req.Location = model.Location req.Properties = pointer.To(codesigningaccounts.CodeSigningAccountProperties{}) - if len(model.Sku) > 0 { - ele := model.Sku[0] - req.Properties.Sku = pointer.To(codesigningaccounts.AccountSku{}) - req.Properties.Sku.Name = codesigningaccounts.SkuName(ele.Name) - } + req.Properties.Sku = pointer.To(codesigningaccounts.AccountSku{ + Name: codesigningaccounts.SkuName(model.SkuName), + }) req.Tags = &model.Tags - future, err := client.Create(ctx, id, req) + err = client.CreateThenPoll(ctx, id, req) if err != nil { return fmt.Errorf("creating %s: %v", id, err) } - if err := future.Poller.PollUntilDone(ctx); err != nil { - return fmt.Errorf("waiting for creation of %s: %v", id, err) - } - meta.SetID(id) return nil }, @@ -148,7 +129,7 @@ func (m TrustedSigningAccountResource) Read() sdk.ResourceFunc { return err } - client := meta.Client.CodeSigning.V20240930previewClient.CodeSigningAccounts + client := meta.Client.CodeSigning.Client.CodeSigningAccounts result, err := client.Get(ctx, *id) if err != nil { return err @@ -172,9 +153,7 @@ func (m TrustedSigningAccountResource) Read() sdk.ResourceFunc { output.AccountUri = pointer.From(itemProp.AccountUri) if ptrSku := itemProp.Sku; ptrSku != nil { itemSku := *ptrSku - var accountSku Sku - accountSku.Name = string(itemSku.Name) - output.Sku = append(output.Sku, accountSku) + output.SkuName = string(itemSku.Name) } } @@ -187,32 +166,29 @@ func (m TrustedSigningAccountResource) Update() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 10 * time.Minute, Func: func(ctx context.Context, meta sdk.ResourceMetaData) (err error) { - client := meta.Client.CodeSigning.V20240930previewClient.CodeSigningAccounts + client := meta.Client.CodeSigning.Client.CodeSigningAccounts id, err := codesigningaccounts.ParseCodeSigningAccountID(meta.ResourceData.Id()) if err != nil { return err } - var model TruestedSigningAccountModel if err = meta.Decode(&model); err != nil { return fmt.Errorf("decoding %s: %+v", id, err) } var upd codesigningaccounts.CodeSigningAccountPatch - - if meta.ResourceData.HasChange("sku") { - upd.Properties = pointer.To(codesigningaccounts.CodeSigningAccountPatchProperties{}) - if len(model.Sku) > 0 { - ele := model.Sku[0] - upd.Properties.Sku = pointer.To(codesigningaccounts.AccountSkuPatch{}) - upd.Properties.Sku.Name = pointer.To(codesigningaccounts.SkuName(ele.Name)) - } + if meta.ResourceData.HasChange("sku_name") { + upd.Properties = pointer.To(codesigningaccounts.CodeSigningAccountPatchProperties{ + Sku: pointer.To(codesigningaccounts.AccountSkuPatch{ + Name: pointer.To(codesigningaccounts.SkuName(model.SkuName)), + }), + }) } if meta.ResourceData.HasChange("tags") { upd.Tags = pointer.To(model.Tags) } - if _, err = client.Update(ctx, *id, upd); err != nil { + if err = client.UpdateThenPoll(ctx, *id, upd); err != nil { return fmt.Errorf("updating %s: %v", id, err) } @@ -231,7 +207,7 @@ func (m TrustedSigningAccountResource) Delete() sdk.ResourceFunc { } meta.Logger.Infof("deleting %s", id) - client := meta.Client.CodeSigning.V20240930previewClient.CodeSigningAccounts + client := meta.Client.CodeSigning.Client.CodeSigningAccounts if _, err = client.Delete(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %v", id, err) } diff --git a/internal/services/codesigning/trusted_signing_account_resource_test.go b/internal/services/codesigning/trusted_signing_account_resource_test.go index 2fd7c6ba0892..074c48d02c14 100644 --- a/internal/services/codesigning/trusted_signing_account_resource_test.go +++ b/internal/services/codesigning/trusted_signing_account_resource_test.go @@ -24,7 +24,7 @@ func (a TrustedSigningAccountResource) Exists(ctx context.Context, client *clien if err != nil { return nil, err } - resp, err := client.CodeSigning.V20240930previewClient.CodeSigningAccounts.Get(ctx, *id) + resp, err := client.CodeSigning.Client.CodeSigningAccounts.Get(ctx, *id) if err != nil { return nil, fmt.Errorf("retrieving TrustedSigningAccount %s: %+v", id, err) } @@ -63,6 +63,13 @@ func TestAccTrustedSigningAccount_update(t *testing.T) { ), }, data.ImportStep(), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), }) } @@ -88,9 +95,7 @@ resource "azurerm_trusted_signing_account" "test" { name = "acctest-%[2]s" location = "%[3]s" resource_group_name = azurerm_resource_group.test.name - sku { - name = "Basic" - } + sku_name = "Basic" } `, a.template(data), data.RandomString, data.Locations.Primary) } @@ -100,13 +105,10 @@ func (a TrustedSigningAccountResource) complete(data acceptance.TestData) string %s resource "azurerm_trusted_signing_account" "test" { - name = "acctest-%[2]s" location = "%[3]s" resource_group_name = azurerm_resource_group.test.name - sku { - name = "Premium" - } + sku_name = "Premium" tags = { key = "example" } diff --git a/website/docs/r/trusted_signing_account.html.markdown b/website/docs/r/trusted_signing_account.html.markdown index b40d473611b2..fe0a701b4cf3 100644 --- a/website/docs/r/trusted_signing_account.html.markdown +++ b/website/docs/r/trusted_signing_account.html.markdown @@ -37,17 +37,12 @@ The following arguments are supported: * `resource_group_name` - (Required) The name of the Resource Group where the Trusted Signing should exist. Changing this forces a new Trusted Signing to be created. -* `sku` - (Required) One `sku` blocks as defined below. +* `sku_name` - (Required) The sku name of this Trusted Signing Account. Possible values are `Basic` and `Premium`. --- * `tags` - (Optional) A mapping of tags which should be assigned to the Trusted Signing. ---- - -A `sku` block supports the following: - -* `name` - (Required) The sku name of this Trusted Signing Account. ## Attributes Reference From 0e244d06d1ee586caff87e5cc298eec19cafdabf Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:20:18 +0800 Subject: [PATCH 04/16] update per comments --- .github/labeler-issue-triage.yml | 6 +- .github/labeler-pull-request-triage.yml | 10 +-- internal/services/codesigning/registration.go | 2 +- .../trusted_signing_account_resource.go | 71 ++++++++++--------- .../trusted_signing_account_resource_test.go | 6 +- vendor/modules.txt | 3 + .../r/trusted_signing_account.html.markdown | 22 +++--- 7 files changed, 64 insertions(+), 56 deletions(-) diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index 758f1ed503ca..595fe1905991 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -65,9 +65,6 @@ service/bots: service/cdn: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_cdn_((.|\n)*)###' -service/codesigning: - - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_trusted_signing_account((.|\n)*)###' - service/cognitive-services: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(ai_services|cognitive_)((.|\n)*)###' @@ -335,6 +332,9 @@ service/systemcentervirtualmachinemanager: service/traffic-manager: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_traffic_manager_((.|\n)*)###' +service/trustedsigning: + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_trusted_signing_account((.|\n)*)###' + service/video-indexer: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_video_indexer_account((.|\n)*)###' diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index eee59d78cdd0..e41a1c7e9ed0 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -108,11 +108,6 @@ service/cdn: - any-glob-to-any-file: - internal/services/cdn/**/* -service/codesigning: -- changed-files: - - any-glob-to-any-file: - - internal/services/codesigning/**/* - service/cognitive-services: - changed-files: - any-glob-to-any-file: @@ -560,6 +555,11 @@ service/traffic-manager: - any-glob-to-any-file: - internal/services/trafficmanager/**/* +service/trustedsigning: +- changed-files: + - any-glob-to-any-file: + - internal/services/codesigning/**/* + service/video-indexer: - changed-files: - any-glob-to-any-file: diff --git a/internal/services/codesigning/registration.go b/internal/services/codesigning/registration.go index e92ca24471c5..cb815924eb16 100644 --- a/internal/services/codesigning/registration.go +++ b/internal/services/codesigning/registration.go @@ -12,7 +12,7 @@ type Registration struct{} var _ sdk.TypedServiceRegistration = Registration{} func (r Registration) AssociatedGitHubLabel() string { - return "service/codesigning" + return "service/trustedsigning" } // Name is the name of this Service diff --git a/internal/services/codesigning/trusted_signing_account_resource.go b/internal/services/codesigning/trusted_signing_account_resource.go index b52b35c7c92f..9fb7ac071089 100644 --- a/internal/services/codesigning/trusted_signing_account_resource.go +++ b/internal/services/codesigning/trusted_signing_account_resource.go @@ -87,7 +87,7 @@ func (m TrustedSigningAccountResource) Create() sdk.ResourceFunc { var model TruestedSigningAccountModel if err := meta.Decode(&model); err != nil { - return err + return fmt.Errorf("decoding: %+v", err) } subscriptionID := meta.Client.Account.SubscriptionId @@ -100,14 +100,16 @@ func (m TrustedSigningAccountResource) Create() sdk.ResourceFunc { return meta.ResourceRequiresImport(m.ResourceType(), id) } - req := codesigningaccounts.CodeSigningAccount{} - req.Name = &model.Name - req.Location = model.Location - req.Properties = pointer.To(codesigningaccounts.CodeSigningAccountProperties{}) - req.Properties.Sku = pointer.To(codesigningaccounts.AccountSku{ - Name: codesigningaccounts.SkuName(model.SkuName), - }) - req.Tags = &model.Tags + req := codesigningaccounts.CodeSigningAccount{ + Name: &model.Name, + Location: model.Location, + Tags: &model.Tags, + Properties: &codesigningaccounts.CodeSigningAccountProperties{ + Sku: &codesigningaccounts.AccountSku{ + Name: codesigningaccounts.SkuName(model.SkuName), + }, + }, + } err = client.CreateThenPoll(ctx, id, req) if err != nil { @@ -124,36 +126,38 @@ func (m TrustedSigningAccountResource) Read() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 5 * time.Minute, Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { + client := meta.Client.CodeSigning.Client.CodeSigningAccounts + id, err := codesigningaccounts.ParseCodeSigningAccountID(meta.ResourceData.Id()) if err != nil { - return err + return fmt.Errorf("parsing %q as an Trusted Signing Account ID: %+v", id, err) } - client := meta.Client.CodeSigning.Client.CodeSigningAccounts result, err := client.Get(ctx, *id) if err != nil { - return err + return fmt.Errorf("retrieving %s: %+v", id, err) } if result.Model == nil { return fmt.Errorf("retrieving %s got nil model", id) } - var output TruestedSigningAccountModel - output.Name = id.CodeSigningAccountName - output.ResourceGroupName = id.ResourceGroupName - if result.Model == nil { - return fmt.Errorf("Get response nil Model") - } - model := result.Model - output.Location = model.Location - output.Tags = pointer.From(model.Tags) - if ptrProp := model.Properties; ptrProp != nil { - itemProp := *ptrProp - output.AccountUri = pointer.From(itemProp.AccountUri) - if ptrSku := itemProp.Sku; ptrSku != nil { - itemSku := *ptrSku - output.SkuName = string(itemSku.Name) + output := TruestedSigningAccountModel{ + Name: id.CodeSigningAccountName, + ResourceGroupName: id.ResourceGroupName, + } + + if result.Model != nil { + model := *result.Model + output.Location = model.Location + output.Tags = pointer.From(model.Tags) + + if model.Properties != nil { + prop := *model.Properties + output.AccountUri = pointer.From(prop.AccountUri) + if sku := prop.Sku; sku != nil { + output.SkuName = string(sku.Name) + } } } @@ -173,22 +177,22 @@ func (m TrustedSigningAccountResource) Update() sdk.ResourceFunc { } var model TruestedSigningAccountModel if err = meta.Decode(&model); err != nil { - return fmt.Errorf("decoding %s: %+v", id, err) + return fmt.Errorf("decoding: %+v", err) } - var upd codesigningaccounts.CodeSigningAccountPatch + var patch codesigningaccounts.CodeSigningAccountPatch if meta.ResourceData.HasChange("sku_name") { - upd.Properties = pointer.To(codesigningaccounts.CodeSigningAccountPatchProperties{ + patch.Properties = pointer.To(codesigningaccounts.CodeSigningAccountPatchProperties{ Sku: pointer.To(codesigningaccounts.AccountSkuPatch{ Name: pointer.To(codesigningaccounts.SkuName(model.SkuName)), }), }) } if meta.ResourceData.HasChange("tags") { - upd.Tags = pointer.To(model.Tags) + patch.Tags = pointer.To(model.Tags) } - if err = client.UpdateThenPoll(ctx, *id, upd); err != nil { + if err = client.UpdateThenPoll(ctx, *id, patch); err != nil { return fmt.Errorf("updating %s: %v", id, err) } @@ -201,13 +205,14 @@ func (m TrustedSigningAccountResource) Delete() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 10 * time.Minute, Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { + client := meta.Client.CodeSigning.Client.CodeSigningAccounts id, err := codesigningaccounts.ParseCodeSigningAccountID(meta.ResourceData.Id()) if err != nil { return err } meta.Logger.Infof("deleting %s", id) - client := meta.Client.CodeSigning.Client.CodeSigningAccounts + if _, err = client.Delete(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %v", id, err) } diff --git a/internal/services/codesigning/trusted_signing_account_resource_test.go b/internal/services/codesigning/trusted_signing_account_resource_test.go index 074c48d02c14..d2cf7037dc63 100644 --- a/internal/services/codesigning/trusted_signing_account_resource_test.go +++ b/internal/services/codesigning/trusted_signing_account_resource_test.go @@ -8,13 +8,13 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/codesigning" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type TrustedSigningAccountResource struct{} @@ -26,9 +26,9 @@ func (a TrustedSigningAccountResource) Exists(ctx context.Context, client *clien } resp, err := client.CodeSigning.Client.CodeSigningAccounts.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("retrieving TrustedSigningAccount %s: %+v", id, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return utils.Bool(resp.Model != nil), nil + return pointer.To(resp.Model != nil), nil } func TestAccTrustedSigningAccount_basic(t *testing.T) { diff --git a/vendor/modules.txt b/vendor/modules.txt index f7ccc55e6779..ccf5bf115b74 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -315,6 +315,9 @@ github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01/capabi github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01/experiments github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01/targets github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01/targettypes +github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview +github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles +github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2023-05-01/cognitiveservicesaccounts github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2023-05-01/deployments github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/communicationservices diff --git a/website/docs/r/trusted_signing_account.html.markdown b/website/docs/r/trusted_signing_account.html.markdown index fe0a701b4cf3..3f86b25b90ae 100644 --- a/website/docs/r/trusted_signing_account.html.markdown +++ b/website/docs/r/trusted_signing_account.html.markdown @@ -31,39 +31,39 @@ resource "azurerm_trusted_signing_account" "example" { The following arguments are supported: -* `name` - (Required) The name which should be used for this Trusted Signing. Changing this forces a new Trusted Signing Account to be created. +* `name` - (Required) The name which should be used for this Trusted Signing Account. Changing this forces a new Trusted Signing Account to be created. -* `location` - (Required) The Azure Region where the Trusted Signing should exist. Changing this forces a new Trusted Signing Account to be created. +* `location` - (Required) The Azure Region where the Trusted Signing Account should exist. Changing this forces a new Trusted Signing Account to be created. -* `resource_group_name` - (Required) The name of the Resource Group where the Trusted Signing should exist. Changing this forces a new Trusted Signing to be created. +* `resource_group_name` - (Required) The name of the Resource Group where the Trusted Signing Account should exist. Changing this forces a new Trusted Signing Account to be created. * `sku_name` - (Required) The sku name of this Trusted Signing Account. Possible values are `Basic` and `Premium`. --- -* `tags` - (Optional) A mapping of tags which should be assigned to the Trusted Signing. +* `tags` - (Optional) A mapping of tags which should be assigned to the Trusted Signing Account. ## Attributes Reference In addition to the Arguments listed above - the following Attributes are exported: -* `id` - The ID of the Trusted Signing. +* `id` - The ID of the Trusted Signing Account. -* `account_uri` - The URI of the trusted signing account which is used during signing files. +* `account_uri` - The URI of the Trusted Signing Account which is used during signing files. ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: -* `create` - (Defaults to 30 minutes) Used when creating the Trusted Signing. -* `read` - (Defaults to 5 minutes) Used when retrieving the Trusted Signing. -* `update` - (Defaults to 10 minutes) Used when updating the Trusted Signing. -* `delete` - (Defaults to 10 minutes) Used when deleting the Trusted Signing. +* `create` - (Defaults to 30 minutes) Used when creating the Trusted Signing Account. +* `read` - (Defaults to 5 minutes) Used when retrieving the Trusted Signing Account. +* `update` - (Defaults to 10 minutes) Used when updating the Trusted Signing Account. +* `delete` - (Defaults to 10 minutes) Used when deleting the Trusted Signing Account. ## Import -Trusted Signings can be imported using the `resource id`, e.g. +Trusted Signing Accounts can be imported using the `resource id`, e.g. ```shell terraform import azurerm_trusted_signing_account.example /subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.CodeSigning/codeSigningAccounts/example-account From d8a5afcecf9a9922a3a627dab16c5a735b2dbb0e Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:30:38 +0800 Subject: [PATCH 05/16] update code --- .../codesigning/trusted_signing_account_resource.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/services/codesigning/trusted_signing_account_resource.go b/internal/services/codesigning/trusted_signing_account_resource.go index 9fb7ac071089..09311e26f45a 100644 --- a/internal/services/codesigning/trusted_signing_account_resource.go +++ b/internal/services/codesigning/trusted_signing_account_resource.go @@ -138,10 +138,6 @@ func (m TrustedSigningAccountResource) Read() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: %+v", id, err) } - if result.Model == nil { - return fmt.Errorf("retrieving %s got nil model", id) - } - output := TruestedSigningAccountModel{ Name: id.CodeSigningAccountName, ResourceGroupName: id.ResourceGroupName, @@ -173,7 +169,7 @@ func (m TrustedSigningAccountResource) Update() sdk.ResourceFunc { client := meta.Client.CodeSigning.Client.CodeSigningAccounts id, err := codesigningaccounts.ParseCodeSigningAccountID(meta.ResourceData.Id()) if err != nil { - return err + return fmt.Errorf("parsing %q as an Trusted Signing Account ID: %+v", meta.ResourceData.Id(), err) } var model TruestedSigningAccountModel if err = meta.Decode(&model); err != nil { @@ -206,9 +202,10 @@ func (m TrustedSigningAccountResource) Delete() sdk.ResourceFunc { Timeout: 10 * time.Minute, Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { client := meta.Client.CodeSigning.Client.CodeSigningAccounts + id, err := codesigningaccounts.ParseCodeSigningAccountID(meta.ResourceData.Id()) if err != nil { - return err + return fmt.Errorf("parsing %q as an Trusted Signing Account ID: %+v", meta.ResourceData.Id(), err) } meta.Logger.Infof("deleting %s", id) From 3343a0d2321c7e578bfcff87a15204ccfaaf7e06 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:57:05 +0800 Subject: [PATCH 06/16] update typo and code pattern --- .../trusted_signing_account_resource.go | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/internal/services/codesigning/trusted_signing_account_resource.go b/internal/services/codesigning/trusted_signing_account_resource.go index 09311e26f45a..f60796c27136 100644 --- a/internal/services/codesigning/trusted_signing_account_resource.go +++ b/internal/services/codesigning/trusted_signing_account_resource.go @@ -12,13 +12,14 @@ import ( "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/location" "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" ) -type TruestedSigningAccountModel struct { +type TrustedSigningAccountModel struct { Name string `tfschema:"name"` Location string `tfschema:"location"` ResourceGroupName string `tfschema:"resource_group_name"` @@ -72,7 +73,7 @@ func (m TrustedSigningAccountResource) Attributes() map[string]*pluginsdk.Schema } func (m TrustedSigningAccountResource) ModelObject() interface{} { - return &TruestedSigningAccountModel{} + return &TrustedSigningAccountModel{} } func (m TrustedSigningAccountResource) ResourceType() string { @@ -85,7 +86,7 @@ func (m TrustedSigningAccountResource) Create() sdk.ResourceFunc { Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { client := meta.Client.CodeSigning.Client.CodeSigningAccounts - var model TruestedSigningAccountModel + var model TrustedSigningAccountModel if err := meta.Decode(&model); err != nil { return fmt.Errorf("decoding: %+v", err) } @@ -130,7 +131,7 @@ func (m TrustedSigningAccountResource) Read() sdk.ResourceFunc { id, err := codesigningaccounts.ParseCodeSigningAccountID(meta.ResourceData.Id()) if err != nil { - return fmt.Errorf("parsing %q as an Trusted Signing Account ID: %+v", id, err) + return err } result, err := client.Get(ctx, *id) @@ -138,18 +139,16 @@ func (m TrustedSigningAccountResource) Read() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: %+v", id, err) } - output := TruestedSigningAccountModel{ + output := TrustedSigningAccountModel{ Name: id.CodeSigningAccountName, ResourceGroupName: id.ResourceGroupName, } - if result.Model != nil { - model := *result.Model - output.Location = model.Location + if model := result.Model; model != nil { + output.Location = location.Normalize(model.Location) output.Tags = pointer.From(model.Tags) - if model.Properties != nil { - prop := *model.Properties + if prop := model.Properties; prop != nil { output.AccountUri = pointer.From(prop.AccountUri) if sku := prop.Sku; sku != nil { output.SkuName = string(sku.Name) @@ -169,9 +168,9 @@ func (m TrustedSigningAccountResource) Update() sdk.ResourceFunc { client := meta.Client.CodeSigning.Client.CodeSigningAccounts id, err := codesigningaccounts.ParseCodeSigningAccountID(meta.ResourceData.Id()) if err != nil { - return fmt.Errorf("parsing %q as an Trusted Signing Account ID: %+v", meta.ResourceData.Id(), err) + return err } - var model TruestedSigningAccountModel + var model TrustedSigningAccountModel if err = meta.Decode(&model); err != nil { return fmt.Errorf("decoding: %+v", err) } @@ -205,7 +204,7 @@ func (m TrustedSigningAccountResource) Delete() sdk.ResourceFunc { id, err := codesigningaccounts.ParseCodeSigningAccountID(meta.ResourceData.Id()) if err != nil { - return fmt.Errorf("parsing %q as an Trusted Signing Account ID: %+v", meta.ResourceData.Id(), err) + return err } meta.Logger.Infof("deleting %s", id) From 5421d7c335f5804aaf9c3479f3f56169aceafe7d Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Thu, 31 Oct 2024 20:41:23 +0800 Subject: [PATCH 07/16] normalize location --- .../services/codesigning/trusted_signing_account_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/codesigning/trusted_signing_account_resource.go b/internal/services/codesigning/trusted_signing_account_resource.go index f60796c27136..bc44b3319890 100644 --- a/internal/services/codesigning/trusted_signing_account_resource.go +++ b/internal/services/codesigning/trusted_signing_account_resource.go @@ -103,7 +103,7 @@ func (m TrustedSigningAccountResource) Create() sdk.ResourceFunc { req := codesigningaccounts.CodeSigningAccount{ Name: &model.Name, - Location: model.Location, + Location: location.Normalize(model.Location), Tags: &model.Tags, Properties: &codesigningaccounts.CodeSigningAccountProperties{ Sku: &codesigningaccounts.AccountSku{ From 29126df47e035bfb8d2223926a1986a4c660ab4f Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 4 Nov 2024 14:35:57 +0800 Subject: [PATCH 08/16] `azurerm_trusted_signing_certificate_profile` - new profile support --- internal/services/codesigning/registration.go | 1 + ...ed_signing_certificate_profile_resource.go | 482 ++++++++++++++++++ ...gning_certificate_profile_resource_test.go | 205 ++++++++ ..._signing_certificate_profile.html.markdown | 129 +++++ 4 files changed, 817 insertions(+) create mode 100644 internal/services/codesigning/trusted_signing_certificate_profile_resource.go create mode 100644 internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go create mode 100644 website/docs/r/trusted_signing_certificate_profile.html.markdown diff --git a/internal/services/codesigning/registration.go b/internal/services/codesigning/registration.go index cb815924eb16..be6566a161ce 100644 --- a/internal/services/codesigning/registration.go +++ b/internal/services/codesigning/registration.go @@ -36,5 +36,6 @@ func (r Registration) DataSources() []sdk.DataSource { func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ TrustedSigningAccountResource{}, + TrustedSigningCertificateProfileResource{}, } } diff --git a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go new file mode 100644 index 000000000000..67786f107094 --- /dev/null +++ b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go @@ -0,0 +1,482 @@ +package codesigning + +import ( + "context" + "fmt" + "regexp" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type TrustedSigningCertificateProfileModel struct { + Name string `tfschema:"name"` + TrustedSigningAccountId string `tfschema:"trusted_signing_account_id"` + IdentityValidationId string `tfschema:"identity_validation_id"` + IncludeCity bool `tfschema:"include_city"` + IncludeCountry bool `tfschema:"include_country"` + IncludePostalCode bool `tfschema:"include_postal_code"` + IncludeState bool `tfschema:"include_state"` + IncludeStreetAddress bool `tfschema:"include_street_address"` + ProfileType certificateprofiles.ProfileType `tfschema:"profile_type"` + Certificates []CertificateModel `tfschema:"certificates"` + Status certificateprofiles.CertificateProfileStatus `tfschema:"status"` +} + +type CertificateModel struct { + CreatedDate string `tfschema:"created_date"` + EnhancedKeyUsage string `tfschema:"enhanced_key_usage"` + ExpiryDate string `tfschema:"expiry_date"` + Revocation []RevocationModel `tfschema:"revocation"` + SerialNumber string `tfschema:"serial_number"` + Status certificateprofiles.CertificateStatus `tfschema:"status"` + SubjectName string `tfschema:"subject_name"` + Thumbprint string `tfschema:"thumbprint"` +} + +type RevocationModel struct { + EffectiveAt string `tfschema:"effective_at"` + FailureReason string `tfschema:"failure_reason"` + Reason string `tfschema:"reason"` + Remarks string `tfschema:"remarks"` + RequestedAt string `tfschema:"requested_at"` + Status certificateprofiles.RevocationStatus `tfschema:"status"` +} + +type TrustedSigningCertificateProfileResource struct{} + +var _ sdk.ResourceWithUpdate = TrustedSigningCertificateProfileResource{} + +func (r TrustedSigningCertificateProfileResource) ResourceType() string { + return "azurerm_trusted_signing_certificate_profile" +} + +func (r TrustedSigningCertificateProfileResource) ModelObject() interface{} { + return &TrustedSigningCertificateProfileModel{} +} + +func (r TrustedSigningCertificateProfileResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return certificateprofiles.ValidateCertificateProfileID +} + +func (r TrustedSigningCertificateProfileResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.All( + validation.StringLenBetween(5, 100), + validation.StringMatch( + regexp.MustCompile("^[A-Za-z][A-Za-z0-9]*(?:-[A-Za-z0-9]+)*$"), + "A certificate profile's name must be between 3-24 alphanumeric characters. The name must begin with a letter, end with a letter or digit, and not contain consecutive hyphens.", + )), + }, + + "trusted_signing_account_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: codesigningaccounts.ValidateCodeSigningAccountID, + }, + + "identity_validation_id": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "profile_type": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(certificateprofiles.ProfileTypePublicTrust), + string(certificateprofiles.ProfileTypePrivateTrust), + string(certificateprofiles.ProfileTypePrivateTrustCIPolicy), + string(certificateprofiles.ProfileTypeVBSEnclave), + string(certificateprofiles.ProfileTypePublicTrustTest), + }, false), + }, + + "include_city": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "include_country": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "include_postal_code": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "include_state": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "include_street_address": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + } +} + +func (r TrustedSigningCertificateProfileResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "certificates": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "created_date": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "enhanced_key_usage": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "expiry_date": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "revocation": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "effective_at": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "failure_reason": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "reason": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "remarks": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "requested_at": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "status": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "serial_number": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "status": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "subject_name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "thumbprint": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "status": { + Type: pluginsdk.TypeString, + Computed: true, + }, + } +} + +func (r TrustedSigningCertificateProfileResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.CodeSigning.Client.CertificateProfiles + + var model TrustedSigningCertificateProfileModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + codeSigningAccountId, err := codesigningaccounts.ParseCodeSigningAccountID(model.TrustedSigningAccountId) + if err != nil { + return err + } + + id := certificateprofiles.NewCertificateProfileID(codeSigningAccountId.SubscriptionId, codeSigningAccountId.ResourceGroupName, codeSigningAccountId.CodeSigningAccountName, model.Name) + + existing, err := client.Get(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for existing %s: %+v", id, err) + } + + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + properties := &certificateprofiles.CertificateProfile{ + Properties: &certificateprofiles.CertificateProfileProperties{ + IdentityValidationId: model.IdentityValidationId, + IncludeCity: &model.IncludeCity, + IncludeCountry: &model.IncludeCountry, + IncludePostalCode: &model.IncludePostalCode, + IncludeState: &model.IncludeState, + IncludeStreetAddress: &model.IncludeStreetAddress, + ProfileType: model.ProfileType, + }, + } + + if err := client.CreateThenPoll(ctx, id, *properties); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r TrustedSigningCertificateProfileResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.CodeSigning.Client.CertificateProfiles + + id, err := certificateprofiles.ParseCertificateProfileID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model TrustedSigningCertificateProfileModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + resp, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + properties := resp.Model + if properties == nil { + return fmt.Errorf("retrieving %s: properties was nil", id) + } + + if metadata.ResourceData.HasChange("identity_validation_id") { + properties.Properties.IdentityValidationId = model.IdentityValidationId + } + + if metadata.ResourceData.HasChange("include_city") { + properties.Properties.IncludeCity = &model.IncludeCity + } + + if metadata.ResourceData.HasChange("include_country") { + properties.Properties.IncludeCountry = &model.IncludeCountry + } + + if metadata.ResourceData.HasChange("include_postal_code") { + properties.Properties.IncludePostalCode = &model.IncludePostalCode + } + + if metadata.ResourceData.HasChange("include_state") { + properties.Properties.IncludeState = &model.IncludeState + } + + if metadata.ResourceData.HasChange("include_street_address") { + properties.Properties.IncludeStreetAddress = &model.IncludeStreetAddress + } + + if metadata.ResourceData.HasChange("profile_type") { + properties.Properties.ProfileType = model.ProfileType + } + + if err := client.CreateThenPoll(ctx, *id, *properties); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r TrustedSigningCertificateProfileResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.CodeSigning.Client.CertificateProfiles + + id, err := certificateprofiles.ParseCertificateProfileID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + state := TrustedSigningCertificateProfileModel{ + Name: id.CertificateProfileName, + TrustedSigningAccountId: codesigningaccounts.NewCodeSigningAccountID(id.SubscriptionId, id.ResourceGroupName, id.CodeSigningAccountName).ID(), + } + + if model := resp.Model; model != nil { + if properties := model.Properties; properties != nil { + state.Certificates = flattenCertificateModelArray(properties.Certificates) + + state.IdentityValidationId = properties.IdentityValidationId + + state.IncludeCity = pointer.From(properties.IncludeCity) + state.IncludeCountry = pointer.From(properties.IncludeCountry) + state.IncludePostalCode = pointer.From(properties.IncludePostalCode) + state.IncludeState = pointer.From(properties.IncludeState) + state.IncludeStreetAddress = pointer.From(properties.IncludeStreetAddress) + + state.ProfileType = properties.ProfileType + + state.Status = pointer.From(properties.Status) + } + } + + return metadata.Encode(&state) + }, + } +} + +func (r TrustedSigningCertificateProfileResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.CodeSigning.Client.CertificateProfiles + + id, err := certificateprofiles.ParseCertificateProfileID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) + } + + return nil + }, + } +} + +func flattenCertificateModelArray(inputList *[]certificateprofiles.Certificate) []CertificateModel { + var outputList []CertificateModel + if inputList == nil { + return outputList + } + for _, input := range *inputList { + output := CertificateModel{ + Revocation: flattenRevocationModel(input.Revocation), + } + + if input.CreatedDate != nil { + output.CreatedDate = *input.CreatedDate + } + + if input.EnhancedKeyUsage != nil { + output.EnhancedKeyUsage = *input.EnhancedKeyUsage + } + + if input.ExpiryDate != nil { + output.ExpiryDate = *input.ExpiryDate + } + + if input.SerialNumber != nil { + output.SerialNumber = *input.SerialNumber + } + + if input.Status != nil { + output.Status = *input.Status + } + + if input.SubjectName != nil { + output.SubjectName = *input.SubjectName + } + + if input.Thumbprint != nil { + output.Thumbprint = *input.Thumbprint + } + outputList = append(outputList, output) + } + return outputList +} + +func flattenRevocationModel(input *certificateprofiles.Revocation) []RevocationModel { + var outputList []RevocationModel + if input == nil { + return outputList + } + output := RevocationModel{} + if input.EffectiveAt != nil { + output.EffectiveAt = *input.EffectiveAt + } + + if input.FailureReason != nil { + output.FailureReason = *input.FailureReason + } + + if input.Reason != nil { + output.Reason = *input.Reason + } + + if input.Remarks != nil { + output.Remarks = *input.Remarks + } + + if input.RequestedAt != nil { + output.RequestedAt = *input.RequestedAt + } + + if input.Status != nil { + output.Status = *input.Status + } + + return append(outputList, output) +} diff --git a/internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go b/internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go new file mode 100644 index 000000000000..aadf098c240e --- /dev/null +++ b/internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go @@ -0,0 +1,205 @@ +package codesigning_test + +import ( + "context" + "fmt" + "os" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type TrustedSigningCertificateProfileResource struct{} + +func TestAccTrustedSigningCertificateProfile_basic(t *testing.T) { + if os.Getenv("ARM_TEST_TRUSTED_SIGNING_IDENTITY_ID") == "" { + t.Skip("Skipping as ARM_TEST_TRUSTED_SIGNING_IDENTITY_ID is not specified") + return + } + data := acceptance.BuildTestData(t, "azurerm_trusted_signing_certificate_profile", "test") + r := TrustedSigningCertificateProfileResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccTrustedSigningCertificateProfile_requiresImport(t *testing.T) { + if os.Getenv("ARM_TEST_TRUSTED_SIGNING_IDENTITY_ID") == "" { + t.Skip("Skipping as ARM_TEST_TRUSTED_SIGNING_IDENTITY_ID is not specified") + return + } + data := acceptance.BuildTestData(t, "azurerm_trusted_signing_certificate_profile", "test") + r := TrustedSigningCertificateProfileResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAcccodesigningCertificateProfile_complete(t *testing.T) { + if os.Getenv("ARM_TEST_TRUSTED_SIGNING_IDENTITY_ID") == "" { + t.Skip("Skipping as ARM_TEST_TRUSTED_SIGNING_IDENTITY_ID is not specified") + return + } + data := acceptance.BuildTestData(t, "azurerm_trusted_signing_certificate_profile", "test") + r := TrustedSigningCertificateProfileResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccTrustedSigningCertificateProfile_update(t *testing.T) { + if os.Getenv("ARM_TEST_TRUSTED_SIGNING_IDENTITY_ID") == "" { + t.Skip("Skipping as ARM_TEST_TRUSTED_SIGNING_IDENTITY_ID is not specified") + return + } + data := acceptance.BuildTestData(t, "azurerm_trusted_signing_certificate_profile", "test") + r := TrustedSigningCertificateProfileResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func (r TrustedSigningCertificateProfileResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := certificateprofiles.ParseCertificateProfileID(state.ID) + if err != nil { + return nil, err + } + + client := clients.CodeSigning.Client.CertificateProfiles + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retrieving %s: %+v", id, err) + } + return utils.Bool(resp.Model != nil), nil +} + +func (r TrustedSigningCertificateProfileResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctest-rg-%[1]d" + location = "%[2]s" +} +resource "azurerm_trusted_signing_account" "test" { + name = "acctest-%[3]s" + location = "%[2]s" + resource_group_name = azurerm_resource_group.test.name + sku_name = "Basic" +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString) +} + +func (r TrustedSigningCertificateProfileResource) basic(data acceptance.TestData) string { + template := r.template(data) + identityId := os.Getenv("ARM_TEST_TRUSTED_SIGNING_IDENTITY_ID") + return fmt.Sprintf(` + %s + +resource "azurerm_trusted_signing_certificate_profile" "test" { + name = "acctest-ccp-%d" + trusted_signing_account_id = azurerm_trusted_signing_account.test.id + identity_validation_id = "%s" + profile_type = "PrivateTrust" +} +`, template, data.RandomInteger, identityId) +} + +func (r TrustedSigningCertificateProfileResource) requiresImport(data acceptance.TestData) string { + config := r.basic(data) + return fmt.Sprintf(` + %s + +resource "azurerm_trusted_signing_certificate_profile" "import" { + name = azurerm_trusted_signing_certificate_profile.test.name + trusted_signing_account_id = azurerm_trusted_signing_certificate_profile.test.trusted_signing_account_id + identity_validation_id = azurerm_trusted_signing_certificate_profile.test.identity_validation_id + profile_type = azurerm_trusted_signing_certificate_profile.test.profile_type +} +`, config) +} + +func (r TrustedSigningCertificateProfileResource) complete(data acceptance.TestData) string { + template := r.template(data) + identityId := os.Getenv("ARM_TEST_TRUSTED_SIGNING_IDENTITY_ID") + return fmt.Sprintf(` + %s + +resource "azurerm_trusted_signing_certificate_profile" "test" { + name = "acctest-ccp-%d" + trusted_signing_account_id = azurerm_trusted_signing_account.test.id + identity_validation_id = "%s" + include_city = true + include_country = true + include_postal_code = true + include_state = true + include_street_address = true + profile_type = "PrivateTrust" + +} +`, template, data.RandomInteger, identityId) +} + +func (r TrustedSigningCertificateProfileResource) update(data acceptance.TestData) string { + template := r.template(data) + identityId := os.Getenv("ARM_TEST_TRUSTED_SIGNING_IDENTITY_ID") + return fmt.Sprintf(` + %s + +resource "azurerm_trusted_signing_certificate_profile" "test" { + name = "acctest-ccp-%d" + trusted_signing_account_id = azurerm_trusted_signing_account.test.id + identity_validation_id = "%s" + include_city = false + include_country = false + include_postal_code = false + include_state = false + include_street_address = false + profile_type = "PrivateTrust" + +} +`, template, data.RandomInteger, identityId) +} diff --git a/website/docs/r/trusted_signing_certificate_profile.html.markdown b/website/docs/r/trusted_signing_certificate_profile.html.markdown new file mode 100644 index 000000000000..c0643f15aae7 --- /dev/null +++ b/website/docs/r/trusted_signing_certificate_profile.html.markdown @@ -0,0 +1,129 @@ +--- +subcategory: "Trusted Signing" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_trusted_signing_certificate_profile" +description: |- + Manages a Trusted Signing Certificate Profile. +--- + +# azurerm_trusted_signing_certificate_profile + +Manages a Trusted Signing Certificate Profile. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_trusted_signing_account" "example" { + name = "example-account" + location = "West Europe" + resource_group_name = azurerm_resource_group.test.name + sku_name = "Basic" +} +resource "azurerm_codesigning_certificate_profile" "example" { + name = "example-ccp" + resource_group_name = azurerm_resource_group.example.name +} + +resource "azurerm_codesigning_certificate_profile" "example" { + name = "example-ccp" + codesigning_code_signing_account_id = azurerm_codesigning_code_signing_account.test.id + identity_validation_id = "" + include_city = false + include_country = false + include_postal_code = false + include_state = false + include_street_address = false + profile_type = "" + +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name which should be used for this Codesigning Certificate Profile. Changing this forces a new Codesigning Certificate Profile to be created. + +* `codesigning_code_signing_account_id` - (Required) Specifies the ID of the Codesigning Certificate Profile. Changing this forces a new Codesigning Certificate Profile to be created. + +* `identity_validation_id` - (Required) Identity validation id used for the certificate subject name. + +* `profile_type` - (Required) Profile type of the certificate. + +* `include_city` - (Optional) Whether to include L in the certificate subject name. Applicable only for private trust, private trust ci profile types. + +* `include_country` - (Optional) Whether to include C in the certificate subject name. Applicable only for private trust, private trust ci profile types. + +* `include_postal_code` - (Optional) Whether to include PC in the certificate subject name. + +* `include_state` - (Optional) Whether to include S in the certificate subject name. Applicable only for private trust, private trust ci profile types. + +* `include_street_address` - (Optional) Whether to include STREET in the certificate subject name. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Codesigning Certificate Profile. + +* `certificates` - A `certificates` block as defined below. + +* `status` - Status of the certificate profile. + +--- + +A `certificates` block exports the following: + +* `created_date` - Certificate created date. + +* `enhanced_key_usage` - Enhanced key usage of the certificate. + +* `expiry_date` - Certificate expiry date. + +* `revocation` - A `revocation` block as defined below. + +* `serial_number` - Serial number of the certificate. + +* `status` - Status of the certificate. + +* `subject_name` - Subject name of the certificate. + +* `thumbprint` - Thumbprint of the certificate. + +--- + +A `revocation` block exports the following: + +* `effective_at` - The timestamp when the revocation is effective. + +* `failure_reason` - Reason for the revocation failure. + +* `reason` - Reason for revocation. + +* `remarks` - Remarks for the revocation. + +* `requested_at` - The timestamp when the revocation is requested. + +* `status` - Status of the revocation. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Codesigning Certificate Profile. +* `read` - (Defaults to 5 minutes) Used when retrieving the Codesigning Certificate Profile. + +* `delete` - (Defaults to 30 minutes) Used when deleting the Codesigning Certificate Profile. + +## Import + +Codesigning Certificate Profile can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_codesigning_certificate_profile.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.CodeSigning/codeSigningAccounts/account1/certificateProfiles/profile1 +``` From 00ed482e52d235de40b7055282d520b79d88ac64 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:17:39 +1100 Subject: [PATCH 09/16] update document and polish code --- ...ed_signing_certificate_profile_resource.go | 6 +-- ...gning_certificate_profile_resource_test.go | 46 +++++++++++++++++-- ..._signing_certificate_profile.html.markdown | 41 ++++++++--------- 3 files changed, 63 insertions(+), 30 deletions(-) diff --git a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go index 67786f107094..8ebf4f7021ee 100644 --- a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go +++ b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go @@ -298,7 +298,7 @@ func (r TrustedSigningCertificateProfileResource) Update() sdk.ResourceFunc { properties := resp.Model if properties == nil { - return fmt.Errorf("retrieving %s: properties was nil", id) + return fmt.Errorf("retrieving %s: `model` was nil", id) } if metadata.ResourceData.HasChange("identity_validation_id") { @@ -366,17 +366,13 @@ func (r TrustedSigningCertificateProfileResource) Read() sdk.ResourceFunc { if model := resp.Model; model != nil { if properties := model.Properties; properties != nil { state.Certificates = flattenCertificateModelArray(properties.Certificates) - state.IdentityValidationId = properties.IdentityValidationId - state.IncludeCity = pointer.From(properties.IncludeCity) state.IncludeCountry = pointer.From(properties.IncludeCountry) state.IncludePostalCode = pointer.From(properties.IncludePostalCode) state.IncludeState = pointer.From(properties.IncludeState) state.IncludeStreetAddress = pointer.From(properties.IncludeStreetAddress) - state.ProfileType = properties.ProfileType - state.Status = pointer.From(properties.Status) } } diff --git a/internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go b/internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go index aadf098c240e..86fc079700d9 100644 --- a/internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go +++ b/internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go @@ -8,12 +8,12 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type TrustedSigningCertificateProfileResource struct{} @@ -30,6 +30,14 @@ func TestAccTrustedSigningCertificateProfile_basic(t *testing.T) { Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("certificates.0.created_date").Exists(), + check.That(data.ResourceName).Key("certificates.0.enhanced_key_usage").Exists(), + check.That(data.ResourceName).Key("certificates.0.expiry_date").Exists(), + check.That(data.ResourceName).Key("certificates.0.serial_number").Exists(), + check.That(data.ResourceName).Key("certificates.0.status").Exists(), + check.That(data.ResourceName).Key("certificates.0.subject_name").Exists(), + check.That(data.ResourceName).Key("certificates.0.thumbprint").Exists(), + check.That(data.ResourceName).Key("status").Exists(), ), }, data.ImportStep(), @@ -48,6 +56,14 @@ func TestAccTrustedSigningCertificateProfile_requiresImport(t *testing.T) { Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("certificates.0.created_date").Exists(), + check.That(data.ResourceName).Key("certificates.0.enhanced_key_usage").Exists(), + check.That(data.ResourceName).Key("certificates.0.expiry_date").Exists(), + check.That(data.ResourceName).Key("certificates.0.serial_number").Exists(), + check.That(data.ResourceName).Key("certificates.0.status").Exists(), + check.That(data.ResourceName).Key("certificates.0.subject_name").Exists(), + check.That(data.ResourceName).Key("certificates.0.thumbprint").Exists(), + check.That(data.ResourceName).Key("status").Exists(), ), }, data.RequiresImportErrorStep(r.requiresImport), @@ -66,6 +82,14 @@ func TestAcccodesigningCertificateProfile_complete(t *testing.T) { Config: r.complete(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("certificates.0.created_date").Exists(), + check.That(data.ResourceName).Key("certificates.0.enhanced_key_usage").Exists(), + check.That(data.ResourceName).Key("certificates.0.expiry_date").Exists(), + check.That(data.ResourceName).Key("certificates.0.serial_number").Exists(), + check.That(data.ResourceName).Key("certificates.0.status").Exists(), + check.That(data.ResourceName).Key("certificates.0.subject_name").Exists(), + check.That(data.ResourceName).Key("certificates.0.thumbprint").Exists(), + check.That(data.ResourceName).Key("status").Exists(), ), }, data.ImportStep(), @@ -84,6 +108,14 @@ func TestAccTrustedSigningCertificateProfile_update(t *testing.T) { Config: r.complete(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("certificates.0.created_date").Exists(), + check.That(data.ResourceName).Key("certificates.0.enhanced_key_usage").Exists(), + check.That(data.ResourceName).Key("certificates.0.expiry_date").Exists(), + check.That(data.ResourceName).Key("certificates.0.serial_number").Exists(), + check.That(data.ResourceName).Key("certificates.0.status").Exists(), + check.That(data.ResourceName).Key("certificates.0.subject_name").Exists(), + check.That(data.ResourceName).Key("certificates.0.thumbprint").Exists(), + check.That(data.ResourceName).Key("status").Exists(), ), }, data.ImportStep(), @@ -91,6 +123,14 @@ func TestAccTrustedSigningCertificateProfile_update(t *testing.T) { Config: r.update(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("certificates.0.created_date").Exists(), + check.That(data.ResourceName).Key("certificates.0.enhanced_key_usage").Exists(), + check.That(data.ResourceName).Key("certificates.0.expiry_date").Exists(), + check.That(data.ResourceName).Key("certificates.0.serial_number").Exists(), + check.That(data.ResourceName).Key("certificates.0.status").Exists(), + check.That(data.ResourceName).Key("certificates.0.subject_name").Exists(), + check.That(data.ResourceName).Key("certificates.0.thumbprint").Exists(), + check.That(data.ResourceName).Key("status").Exists(), ), }, data.ImportStep(), @@ -107,11 +147,11 @@ func (r TrustedSigningCertificateProfileResource) Exists(ctx context.Context, cl resp, err := client.Get(ctx, *id) if err != nil { if response.WasNotFound(resp.HttpResponse) { - return utils.Bool(false), nil + return pointer.To(false), nil } return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return utils.Bool(resp.Model != nil), nil + return pointer.To(resp.Model != nil), nil } func (r TrustedSigningCertificateProfileResource) template(data acceptance.TestData) string { diff --git a/website/docs/r/trusted_signing_certificate_profile.html.markdown b/website/docs/r/trusted_signing_certificate_profile.html.markdown index c0643f15aae7..71648ac130df 100644 --- a/website/docs/r/trusted_signing_certificate_profile.html.markdown +++ b/website/docs/r/trusted_signing_certificate_profile.html.markdown @@ -24,21 +24,18 @@ resource "azurerm_trusted_signing_account" "example" { resource_group_name = azurerm_resource_group.test.name sku_name = "Basic" } -resource "azurerm_codesigning_certificate_profile" "example" { - name = "example-ccp" - resource_group_name = azurerm_resource_group.example.name -} -resource "azurerm_codesigning_certificate_profile" "example" { - name = "example-ccp" - codesigning_code_signing_account_id = azurerm_codesigning_code_signing_account.test.id - identity_validation_id = "" - include_city = false - include_country = false - include_postal_code = false - include_state = false - include_street_address = false - profile_type = "" + +resource "azurerm_trusted_signing_certificate_profile" "example" { + name = "example-ccp" + trusted_signing_account_id = azurerm_trusted_signing_account.example.id + identity_validation_id = "00000000-1111-2222-3333-444444444444" + include_city = false + include_country = false + include_postal_code = false + include_state = false + include_street_address = false + profile_type = "PublicTrust" } ``` @@ -47,9 +44,9 @@ resource "azurerm_codesigning_certificate_profile" "example" { The following arguments are supported: -* `name` - (Required) Specifies the name which should be used for this Codesigning Certificate Profile. Changing this forces a new Codesigning Certificate Profile to be created. +* `name` - (Required) Specifies the name which should be used for this Trusted Signing Certificate Profile. Changing this forces a new Trusted Signing Certificate Profile to be created. -* `codesigning_code_signing_account_id` - (Required) Specifies the ID of the Codesigning Certificate Profile. Changing this forces a new Codesigning Certificate Profile to be created. +* `trusted_signing_account_id ` - (Required) Specifies the ID of the Trusted Signing Account. Changing this forces a new Trusted Signing Certificate Profile to be created. * `identity_validation_id` - (Required) Identity validation id used for the certificate subject name. @@ -69,7 +66,7 @@ The following arguments are supported: In addition to the Arguments listed above - the following Attributes are exported: -* `id` - The ID of the Codesigning Certificate Profile. +* `id` - The ID of the Trusted Signing Certificate Profile. * `certificates` - A `certificates` block as defined below. @@ -115,15 +112,15 @@ A `revocation` block exports the following: The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: -* `create` - (Defaults to 30 minutes) Used when creating the Codesigning Certificate Profile. -* `read` - (Defaults to 5 minutes) Used when retrieving the Codesigning Certificate Profile. +* `create` - (Defaults to 30 minutes) Used when creating the Trusted Signing Certificate Profile. +* `read` - (Defaults to 5 minutes) Used when retrieving the Trusted Signing Certificate Profile. -* `delete` - (Defaults to 30 minutes) Used when deleting the Codesigning Certificate Profile. +* `delete` - (Defaults to 30 minutes) Used when deleting the Trusted Signing Certificate Profile. ## Import -Codesigning Certificate Profile can be imported using the `resource id`, e.g. +Trusted Signing Certificate Profile can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_codesigning_certificate_profile.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.CodeSigning/codeSigningAccounts/account1/certificateProfiles/profile1 +terraform import azurerm_trusted_signing_certificate_profile.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.CodeSigning/codeSigningAccounts/account1/certificateProfiles/profile1 ``` From 526aa10c1a8969ccfb1f8c66901acef04ef619c6 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:36:54 +1100 Subject: [PATCH 10/16] lint & make generate --- .github/labeler-issue-triage.yml | 2 +- .../codesigning/trusted_signing_certificate_profile_resource.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index ba97f5f93250..4477736e2d6f 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -339,7 +339,7 @@ service/traffic-manager: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_traffic_manager_((.|\n)*)###' service/trustedsigning: - - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_trusted_signing_account((.|\n)*)###' + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_trusted_signing_((.|\n)*)###' service/video-indexer: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_video_indexer_account((.|\n)*)###' diff --git a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go index 8ebf4f7021ee..d46c971555ec 100644 --- a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go +++ b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go @@ -403,7 +403,7 @@ func (r TrustedSigningCertificateProfileResource) Delete() sdk.ResourceFunc { } func flattenCertificateModelArray(inputList *[]certificateprofiles.Certificate) []CertificateModel { - var outputList []CertificateModel + outputList := make([]CertificateModel, 0) if inputList == nil { return outputList } From 80fb2ce43aee5570b523b6e1e4c7315eecab55b7 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Fri, 6 Dec 2024 16:54:22 +1100 Subject: [PATCH 11/16] update per comments --- ...ed_signing_certificate_profile_resource.go | 55 +++++++------------ ..._signing_certificate_profile.html.markdown | 21 +++---- 2 files changed, 28 insertions(+), 48 deletions(-) diff --git a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go index d46c971555ec..d529a885e4c2 100644 --- a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go +++ b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go @@ -89,12 +89,14 @@ func (r TrustedSigningCertificateProfileResource) Arguments() map[string]*plugin "identity_validation_id": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: validation.StringIsNotEmpty, + ForceNew: true, + ValidateFunc: validation.IsUUID, }, "profile_type": { Type: pluginsdk.TypeString, Required: true, + ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ string(certificateprofiles.ProfileTypePublicTrust), string(certificateprofiles.ProfileTypePrivateTrust), @@ -197,8 +199,9 @@ func (r TrustedSigningCertificateProfileResource) Attributes() map[string]*plugi }, "serial_number": { - Type: pluginsdk.TypeString, - Computed: true, + Type: pluginsdk.TypeString, + Sensitive: true, + Computed: true, }, "status": { @@ -207,13 +210,15 @@ func (r TrustedSigningCertificateProfileResource) Attributes() map[string]*plugi }, "subject_name": { - Type: pluginsdk.TypeString, - Computed: true, + Type: pluginsdk.TypeString, + Sensitive: true, + Computed: true, }, "thumbprint": { - Type: pluginsdk.TypeString, - Computed: true, + Type: pluginsdk.TypeString, + Sensitive: true, + Computed: true, }, }, }, @@ -409,36 +414,16 @@ func flattenCertificateModelArray(inputList *[]certificateprofiles.Certificate) } for _, input := range *inputList { output := CertificateModel{ - Revocation: flattenRevocationModel(input.Revocation), + Revocation: flattenRevocationModel(input.Revocation), + CreatedDate: pointer.From(input.CreatedDate), + EnhancedKeyUsage: pointer.From(input.EnhancedKeyUsage), + ExpiryDate: pointer.From(input.ExpiryDate), + SerialNumber: pointer.From(input.SerialNumber), + Status: pointer.From(input.Status), + SubjectName: pointer.From(input.SubjectName), + Thumbprint: pointer.From(input.Thumbprint), } - if input.CreatedDate != nil { - output.CreatedDate = *input.CreatedDate - } - - if input.EnhancedKeyUsage != nil { - output.EnhancedKeyUsage = *input.EnhancedKeyUsage - } - - if input.ExpiryDate != nil { - output.ExpiryDate = *input.ExpiryDate - } - - if input.SerialNumber != nil { - output.SerialNumber = *input.SerialNumber - } - - if input.Status != nil { - output.Status = *input.Status - } - - if input.SubjectName != nil { - output.SubjectName = *input.SubjectName - } - - if input.Thumbprint != nil { - output.Thumbprint = *input.Thumbprint - } outputList = append(outputList, output) } return outputList diff --git a/website/docs/r/trusted_signing_certificate_profile.html.markdown b/website/docs/r/trusted_signing_certificate_profile.html.markdown index 71648ac130df..b775999c6855 100644 --- a/website/docs/r/trusted_signing_certificate_profile.html.markdown +++ b/website/docs/r/trusted_signing_certificate_profile.html.markdown @@ -30,11 +30,6 @@ resource "azurerm_trusted_signing_certificate_profile" "example" { name = "example-ccp" trusted_signing_account_id = azurerm_trusted_signing_account.example.id identity_validation_id = "00000000-1111-2222-3333-444444444444" - include_city = false - include_country = false - include_postal_code = false - include_state = false - include_street_address = false profile_type = "PublicTrust" } @@ -48,19 +43,19 @@ The following arguments are supported: * `trusted_signing_account_id ` - (Required) Specifies the ID of the Trusted Signing Account. Changing this forces a new Trusted Signing Certificate Profile to be created. -* `identity_validation_id` - (Required) Identity validation id used for the certificate subject name. +* `identity_validation_id` - (Required) Identity validation id used for the certificate subject name. Changing this forces a new Trusted Signing Certificate Profile to be created. -* `profile_type` - (Required) Profile type of the certificate. +* `profile_type` - (Required) Profile type of the certificate. Possible values are `PrivateTrust`, `PrivateTrustCIPolicy`, `PublicTrust`, `PublicTrustTest` and `VBSEnclave`. Changing this forces a new Trusted Signing Certificate Profile to be created. -* `include_city` - (Optional) Whether to include L in the certificate subject name. Applicable only for private trust, private trust ci profile types. +* `include_city` - (Optional) Whether to include L in the certificate subject name? Applicable only for `PrivateTrust` and `PrivateTrustCIPolicy` profile types. -* `include_country` - (Optional) Whether to include C in the certificate subject name. Applicable only for private trust, private trust ci profile types. +* `include_country` - (Optional) Whether to include C in the certificate subject name? Applicable only for `PrivateTrust` and `PrivateTrustCIPolicy` profile types. -* `include_postal_code` - (Optional) Whether to include PC in the certificate subject name. +* `include_postal_code` - (Optional) Whether to include PC in the certificate subject name? -* `include_state` - (Optional) Whether to include S in the certificate subject name. Applicable only for private trust, private trust ci profile types. +* `include_state` - (Optional) Whether to include S in the certificate subject name? Applicable only for `PrivateTrust` and `PrivateTrustCIPolicy` profile types. -* `include_street_address` - (Optional) Whether to include STREET in the certificate subject name. +* `include_street_address` - (Optional) Whether to include STREET in the certificate subject name? ## Attributes Reference @@ -114,7 +109,7 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d * `create` - (Defaults to 30 minutes) Used when creating the Trusted Signing Certificate Profile. * `read` - (Defaults to 5 minutes) Used when retrieving the Trusted Signing Certificate Profile. - +* `update` - (Defaults to 30 minutes) Used when updating the Trusted Signing Certificate Profile. * `delete` - (Defaults to 30 minutes) Used when deleting the Trusted Signing Certificate Profile. ## Import From fd67ba9792ee4e8a7439111bfae78e8ea93341c3 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:33:38 +1100 Subject: [PATCH 12/16] update regexp --- .../trusted_signing_certificate_profile_resource.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go index d529a885e4c2..dd734e58cafe 100644 --- a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go +++ b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go @@ -72,9 +72,9 @@ func (r TrustedSigningCertificateProfileResource) Arguments() map[string]*plugin Required: true, ForceNew: true, ValidateFunc: validation.All( - validation.StringLenBetween(5, 100), + validation.StringLenBetween(3, 24), validation.StringMatch( - regexp.MustCompile("^[A-Za-z][A-Za-z0-9]*(?:-[A-Za-z0-9]+)*$"), + regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*(?:-[a-zA-Z0-9]+)*[a-zA-Z0-9]$"), "A certificate profile's name must be between 3-24 alphanumeric characters. The name must begin with a letter, end with a letter or digit, and not contain consecutive hyphens.", )), }, From 7ee1475ac0e201064ff81b0cfd1972dad7b79868 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:53:25 +1100 Subject: [PATCH 13/16] remove useless attributes --- ...ed_signing_certificate_profile_resource.go | 136 +++--------------- 1 file changed, 21 insertions(+), 115 deletions(-) diff --git a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go index dd734e58cafe..46c20751fe89 100644 --- a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go +++ b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go @@ -16,37 +16,33 @@ import ( ) type TrustedSigningCertificateProfileModel struct { - Name string `tfschema:"name"` - TrustedSigningAccountId string `tfschema:"trusted_signing_account_id"` - IdentityValidationId string `tfschema:"identity_validation_id"` - IncludeCity bool `tfschema:"include_city"` - IncludeCountry bool `tfschema:"include_country"` - IncludePostalCode bool `tfschema:"include_postal_code"` - IncludeState bool `tfschema:"include_state"` - IncludeStreetAddress bool `tfschema:"include_street_address"` - ProfileType certificateprofiles.ProfileType `tfschema:"profile_type"` - Certificates []CertificateModel `tfschema:"certificates"` - Status certificateprofiles.CertificateProfileStatus `tfschema:"status"` + Name string `tfschema:"name"` + TrustedSigningAccountId string `tfschema:"trusted_signing_account_id"` + IdentityValidationId string `tfschema:"identity_validation_id"` + IncludeCity bool `tfschema:"include_city"` + IncludeCountry bool `tfschema:"include_country"` + IncludePostalCode bool `tfschema:"include_postal_code"` + IncludeState bool `tfschema:"include_state"` + IncludeStreetAddress bool `tfschema:"include_street_address"` + ProfileType certificateprofiles.ProfileType `tfschema:"profile_type"` + Certificates []CertificateModel `tfschema:"certificates"` } type CertificateModel struct { - CreatedDate string `tfschema:"created_date"` - EnhancedKeyUsage string `tfschema:"enhanced_key_usage"` - ExpiryDate string `tfschema:"expiry_date"` - Revocation []RevocationModel `tfschema:"revocation"` - SerialNumber string `tfschema:"serial_number"` - Status certificateprofiles.CertificateStatus `tfschema:"status"` - SubjectName string `tfschema:"subject_name"` - Thumbprint string `tfschema:"thumbprint"` + EnhancedKeyUsage string `tfschema:"enhanced_key_usage"` + ExpiryDate string `tfschema:"expiry_date"` + Revocation []RevocationModel `tfschema:"revocation"` + SerialNumber string `tfschema:"serial_number"` + SubjectName string `tfschema:"subject_name"` + Thumbprint string `tfschema:"thumbprint"` } type RevocationModel struct { - EffectiveAt string `tfschema:"effective_at"` - FailureReason string `tfschema:"failure_reason"` - Reason string `tfschema:"reason"` - Remarks string `tfschema:"remarks"` - RequestedAt string `tfschema:"requested_at"` - Status certificateprofiles.RevocationStatus `tfschema:"status"` + EffectiveAt string `tfschema:"effective_at"` + FailureReason string `tfschema:"failure_reason"` + Reason string `tfschema:"reason"` + Remarks string `tfschema:"remarks"` + RequestedAt string `tfschema:"requested_at"` } type TrustedSigningCertificateProfileResource struct{} @@ -145,11 +141,6 @@ func (r TrustedSigningCertificateProfileResource) Attributes() map[string]*plugi Computed: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "created_date": { - Type: pluginsdk.TypeString, - Computed: true, - }, - "enhanced_key_usage": { Type: pluginsdk.TypeString, Computed: true, @@ -160,55 +151,12 @@ func (r TrustedSigningCertificateProfileResource) Attributes() map[string]*plugi Computed: true, }, - "revocation": { - Type: pluginsdk.TypeList, - Computed: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "effective_at": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "failure_reason": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "reason": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "remarks": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "requested_at": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "status": { - Type: pluginsdk.TypeString, - Computed: true, - }, - }, - }, - }, - "serial_number": { Type: pluginsdk.TypeString, Sensitive: true, Computed: true, }, - "status": { - Type: pluginsdk.TypeString, - Computed: true, - }, - "subject_name": { Type: pluginsdk.TypeString, Sensitive: true, @@ -223,11 +171,6 @@ func (r TrustedSigningCertificateProfileResource) Attributes() map[string]*plugi }, }, }, - - "status": { - Type: pluginsdk.TypeString, - Computed: true, - }, } } @@ -378,7 +321,6 @@ func (r TrustedSigningCertificateProfileResource) Read() sdk.ResourceFunc { state.IncludeState = pointer.From(properties.IncludeState) state.IncludeStreetAddress = pointer.From(properties.IncludeStreetAddress) state.ProfileType = properties.ProfileType - state.Status = pointer.From(properties.Status) } } @@ -414,12 +356,9 @@ func flattenCertificateModelArray(inputList *[]certificateprofiles.Certificate) } for _, input := range *inputList { output := CertificateModel{ - Revocation: flattenRevocationModel(input.Revocation), - CreatedDate: pointer.From(input.CreatedDate), EnhancedKeyUsage: pointer.From(input.EnhancedKeyUsage), ExpiryDate: pointer.From(input.ExpiryDate), SerialNumber: pointer.From(input.SerialNumber), - Status: pointer.From(input.Status), SubjectName: pointer.From(input.SubjectName), Thumbprint: pointer.From(input.Thumbprint), } @@ -428,36 +367,3 @@ func flattenCertificateModelArray(inputList *[]certificateprofiles.Certificate) } return outputList } - -func flattenRevocationModel(input *certificateprofiles.Revocation) []RevocationModel { - var outputList []RevocationModel - if input == nil { - return outputList - } - output := RevocationModel{} - if input.EffectiveAt != nil { - output.EffectiveAt = *input.EffectiveAt - } - - if input.FailureReason != nil { - output.FailureReason = *input.FailureReason - } - - if input.Reason != nil { - output.Reason = *input.Reason - } - - if input.Remarks != nil { - output.Remarks = *input.Remarks - } - - if input.RequestedAt != nil { - output.RequestedAt = *input.RequestedAt - } - - if input.Status != nil { - output.Status = *input.Status - } - - return append(outputList, output) -} From 89a9ca80e99c740b7e42fd664ade59fe3a9f009e Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:09:58 +1100 Subject: [PATCH 14/16] remove useless attributes --- ...ed_signing_certificate_profile_resource.go | 24 +++----------- ...gning_certificate_profile_resource_test.go | 32 ++++--------------- 2 files changed, 10 insertions(+), 46 deletions(-) diff --git a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go index 46c20751fe89..390b1a35f400 100644 --- a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go +++ b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go @@ -29,20 +29,10 @@ type TrustedSigningCertificateProfileModel struct { } type CertificateModel struct { - EnhancedKeyUsage string `tfschema:"enhanced_key_usage"` - ExpiryDate string `tfschema:"expiry_date"` - Revocation []RevocationModel `tfschema:"revocation"` - SerialNumber string `tfschema:"serial_number"` - SubjectName string `tfschema:"subject_name"` - Thumbprint string `tfschema:"thumbprint"` -} - -type RevocationModel struct { - EffectiveAt string `tfschema:"effective_at"` - FailureReason string `tfschema:"failure_reason"` - Reason string `tfschema:"reason"` - Remarks string `tfschema:"remarks"` - RequestedAt string `tfschema:"requested_at"` + EnhancedKeyUsage string `tfschema:"enhanced_key_usage"` + SerialNumber string `tfschema:"serial_number"` + SubjectName string `tfschema:"subject_name"` + Thumbprint string `tfschema:"thumbprint"` } type TrustedSigningCertificateProfileResource struct{} @@ -146,11 +136,6 @@ func (r TrustedSigningCertificateProfileResource) Attributes() map[string]*plugi Computed: true, }, - "expiry_date": { - Type: pluginsdk.TypeString, - Computed: true, - }, - "serial_number": { Type: pluginsdk.TypeString, Sensitive: true, @@ -357,7 +342,6 @@ func flattenCertificateModelArray(inputList *[]certificateprofiles.Certificate) for _, input := range *inputList { output := CertificateModel{ EnhancedKeyUsage: pointer.From(input.EnhancedKeyUsage), - ExpiryDate: pointer.From(input.ExpiryDate), SerialNumber: pointer.From(input.SerialNumber), SubjectName: pointer.From(input.SubjectName), Thumbprint: pointer.From(input.Thumbprint), diff --git a/internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go b/internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go index 86fc079700d9..7b7f2eeaa2b2 100644 --- a/internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go +++ b/internal/services/codesigning/trusted_signing_certificate_profile_resource_test.go @@ -30,14 +30,10 @@ func TestAccTrustedSigningCertificateProfile_basic(t *testing.T) { Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("certificates.0.created_date").Exists(), check.That(data.ResourceName).Key("certificates.0.enhanced_key_usage").Exists(), - check.That(data.ResourceName).Key("certificates.0.expiry_date").Exists(), check.That(data.ResourceName).Key("certificates.0.serial_number").Exists(), - check.That(data.ResourceName).Key("certificates.0.status").Exists(), check.That(data.ResourceName).Key("certificates.0.subject_name").Exists(), check.That(data.ResourceName).Key("certificates.0.thumbprint").Exists(), - check.That(data.ResourceName).Key("status").Exists(), ), }, data.ImportStep(), @@ -56,14 +52,10 @@ func TestAccTrustedSigningCertificateProfile_requiresImport(t *testing.T) { Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("certificates.0.created_date").Exists(), check.That(data.ResourceName).Key("certificates.0.enhanced_key_usage").Exists(), - check.That(data.ResourceName).Key("certificates.0.expiry_date").Exists(), check.That(data.ResourceName).Key("certificates.0.serial_number").Exists(), - check.That(data.ResourceName).Key("certificates.0.status").Exists(), check.That(data.ResourceName).Key("certificates.0.subject_name").Exists(), check.That(data.ResourceName).Key("certificates.0.thumbprint").Exists(), - check.That(data.ResourceName).Key("status").Exists(), ), }, data.RequiresImportErrorStep(r.requiresImport), @@ -82,14 +74,10 @@ func TestAcccodesigningCertificateProfile_complete(t *testing.T) { Config: r.complete(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("certificates.0.created_date").Exists(), check.That(data.ResourceName).Key("certificates.0.enhanced_key_usage").Exists(), - check.That(data.ResourceName).Key("certificates.0.expiry_date").Exists(), check.That(data.ResourceName).Key("certificates.0.serial_number").Exists(), - check.That(data.ResourceName).Key("certificates.0.status").Exists(), check.That(data.ResourceName).Key("certificates.0.subject_name").Exists(), check.That(data.ResourceName).Key("certificates.0.thumbprint").Exists(), - check.That(data.ResourceName).Key("status").Exists(), ), }, data.ImportStep(), @@ -108,14 +96,10 @@ func TestAccTrustedSigningCertificateProfile_update(t *testing.T) { Config: r.complete(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("certificates.0.created_date").Exists(), check.That(data.ResourceName).Key("certificates.0.enhanced_key_usage").Exists(), - check.That(data.ResourceName).Key("certificates.0.expiry_date").Exists(), check.That(data.ResourceName).Key("certificates.0.serial_number").Exists(), - check.That(data.ResourceName).Key("certificates.0.status").Exists(), check.That(data.ResourceName).Key("certificates.0.subject_name").Exists(), check.That(data.ResourceName).Key("certificates.0.thumbprint").Exists(), - check.That(data.ResourceName).Key("status").Exists(), ), }, data.ImportStep(), @@ -123,14 +107,10 @@ func TestAccTrustedSigningCertificateProfile_update(t *testing.T) { Config: r.update(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("certificates.0.created_date").Exists(), check.That(data.ResourceName).Key("certificates.0.enhanced_key_usage").Exists(), - check.That(data.ResourceName).Key("certificates.0.expiry_date").Exists(), check.That(data.ResourceName).Key("certificates.0.serial_number").Exists(), - check.That(data.ResourceName).Key("certificates.0.status").Exists(), check.That(data.ResourceName).Key("certificates.0.subject_name").Exists(), check.That(data.ResourceName).Key("certificates.0.thumbprint").Exists(), - check.That(data.ResourceName).Key("status").Exists(), ), }, data.ImportStep(), @@ -180,12 +160,12 @@ func (r TrustedSigningCertificateProfileResource) basic(data acceptance.TestData %s resource "azurerm_trusted_signing_certificate_profile" "test" { - name = "acctest-ccp-%d" + name = "acctest-%s" trusted_signing_account_id = azurerm_trusted_signing_account.test.id identity_validation_id = "%s" profile_type = "PrivateTrust" } -`, template, data.RandomInteger, identityId) +`, template, data.RandomString, identityId) } func (r TrustedSigningCertificateProfileResource) requiresImport(data acceptance.TestData) string { @@ -209,7 +189,7 @@ func (r TrustedSigningCertificateProfileResource) complete(data acceptance.TestD %s resource "azurerm_trusted_signing_certificate_profile" "test" { - name = "acctest-ccp-%d" + name = "acctest-%s" trusted_signing_account_id = azurerm_trusted_signing_account.test.id identity_validation_id = "%s" include_city = true @@ -220,7 +200,7 @@ resource "azurerm_trusted_signing_certificate_profile" "test" { profile_type = "PrivateTrust" } -`, template, data.RandomInteger, identityId) +`, template, data.RandomString, identityId) } func (r TrustedSigningCertificateProfileResource) update(data acceptance.TestData) string { @@ -230,7 +210,7 @@ func (r TrustedSigningCertificateProfileResource) update(data acceptance.TestDat %s resource "azurerm_trusted_signing_certificate_profile" "test" { - name = "acctest-ccp-%d" + name = "acctest-%s" trusted_signing_account_id = azurerm_trusted_signing_account.test.id identity_validation_id = "%s" include_city = false @@ -241,5 +221,5 @@ resource "azurerm_trusted_signing_certificate_profile" "test" { profile_type = "PrivateTrust" } -`, template, data.RandomInteger, identityId) +`, template, data.RandomString, identityId) } From f96875b0eed3dd91b7a4fdb64729b094ab788c14 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Tue, 10 Dec 2024 20:25:27 +1100 Subject: [PATCH 15/16] update regex --- .../codesigning/trusted_signing_certificate_profile_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go index 390b1a35f400..f296ebf017b7 100644 --- a/internal/services/codesigning/trusted_signing_certificate_profile_resource.go +++ b/internal/services/codesigning/trusted_signing_certificate_profile_resource.go @@ -60,7 +60,7 @@ func (r TrustedSigningCertificateProfileResource) Arguments() map[string]*plugin ValidateFunc: validation.All( validation.StringLenBetween(3, 24), validation.StringMatch( - regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*(?:-[a-zA-Z0-9]+)*[a-zA-Z0-9]$"), + regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*(?:-[a-zA-Z0-9]+)*$"), "A certificate profile's name must be between 3-24 alphanumeric characters. The name must begin with a letter, end with a letter or digit, and not contain consecutive hyphens.", )), }, From 9dfd51662942888a23c161f8c22895cf79afabf9 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:24:11 +1100 Subject: [PATCH 16/16] update regex --- .../services/codesigning/trusted_signing_account_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/codesigning/trusted_signing_account_resource.go b/internal/services/codesigning/trusted_signing_account_resource.go index bc44b3319890..1fe3094701cf 100644 --- a/internal/services/codesigning/trusted_signing_account_resource.go +++ b/internal/services/codesigning/trusted_signing_account_resource.go @@ -41,7 +41,7 @@ func (m TrustedSigningAccountResource) Arguments() map[string]*pluginsdk.Schema ValidateFunc: validation.All( validation.StringLenBetween(3, 24), validation.StringMatch( - regexp.MustCompile("^[A-Za-z][A-Za-z0-9]*(?:-[A-Za-z0-9]+)*$"), + regexp.MustCompile("^[A-Za-z][A-Za-z0-9]*(-[A-Za-z0-9]+)*$"), "An account's name must be between 3-24 alphanumeric characters. The name must begin with a letter, end with a letter or digit, and not contain consecutive hyphens.", ), ),