From 7031d70facde59335c101aea9473f0f26475ed53 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 12 Mar 2024 18:34:42 +0800 Subject: [PATCH] rename fields --- ...d_hardware_security_module_key_resource.go | 38 +++++++++---------- ...dware_security_module_key_resource_test.go | 2 +- ...hardware_security_module_key.html.markdown | 8 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/internal/services/managedhsm/key_vault_managed_hardware_security_module_key_resource.go b/internal/services/managedhsm/key_vault_managed_hardware_security_module_key_resource.go index b0e8f582ad41..648ca252f25e 100644 --- a/internal/services/managedhsm/key_vault_managed_hardware_security_module_key_resource.go +++ b/internal/services/managedhsm/key_vault_managed_hardware_security_module_key_resource.go @@ -41,8 +41,8 @@ import ( ) type AutomaticModel struct { - TimeAfterCreation string `tfschema:"time_after_creation"` - TimeBeforeExpiry string `tfschema:"time_before_expiry"` + DurationAfterCreation string `tfschema:"duration_after_creation"` + TimeBeforeExpiry string `tfschema:"time_before_expiry"` } type RotationPolicyModel struct { Automatic []AutomaticModel `tfschema:"automatic"` @@ -53,13 +53,13 @@ type KeyVaultManagedHardwareSecurityModuleKeyModel struct { Curve string `tfschema:"curve"` E string `tfschema:"e"` ExpirationDate string `tfschema:"expiration_date"` - KeyOpts []string `tfschema:"key_opts"` + KeyOptions []string `tfschema:"key_options"` KeySize int `tfschema:"key_size"` KeyType string `tfschema:"key_type"` ManagedHsmId string `tfschema:"managed_hsm_id"` N string `tfschema:"n"` Name string `tfschema:"name"` - NotBeforeDate string `tfschema:"not_before_date"` + NotUsableBeforeDate string `tfschema:"not_usable_before_date"` PublicKeyOpenssh string `tfschema:"public_key_openssh"` PublicKeyPem string `tfschema:"public_key_pem"` ResourceId string `tfschema:"resource_id"` @@ -152,7 +152,7 @@ func (KeyVaultManagedHardwareSecurityModuleKeyResouece) Arguments() map[string]* ConflictsWith: []string{"curve"}, }, - "key_opts": { + "key_options": { // API Response order not stable Type: pluginsdk.TypeSet, Set: pluginsdk.HashString, @@ -197,7 +197,7 @@ func (KeyVaultManagedHardwareSecurityModuleKeyResouece) Arguments() map[string]* ConflictsWith: []string{"key_size"}, }, - "not_before_date": { + "not_usable_before_date": { Type: pluginsdk.TypeString, Optional: true, ValidateFunc: validation.IsRFC3339Time, @@ -234,12 +234,12 @@ func (KeyVaultManagedHardwareSecurityModuleKeyResouece) Arguments() map[string]* MaxItems: 1, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "time_after_creation": { + "duration_after_creation": { Type: pluginsdk.TypeString, Optional: true, ValidateFunc: validate.ISO8601Duration, AtLeastOneOf: []string{ - "rotation_policy.0.automatic.0.time_after_creation", + "rotation_policy.0.automatic.0.duration_after_creation", "rotation_policy.0.automatic.0.time_before_expiry", }, }, @@ -248,7 +248,7 @@ func (KeyVaultManagedHardwareSecurityModuleKeyResouece) Arguments() map[string]* Optional: true, ValidateFunc: validate.ISO8601Duration, AtLeastOneOf: []string{ - "rotation_policy.0.automatic.0.time_after_creation", + "rotation_policy.0.automatic.0.duration_after_creation", "rotation_policy.0.automatic.0.time_before_expiry", }, }, @@ -385,7 +385,7 @@ func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) Create() sdk.ResourceF parameters.KeySize = utils.Int32(int32(model.KeySize)) } - if v := model.NotBeforeDate; v != "" { + if v := model.NotUsableBeforeDate; v != "" { notBeforeDate, _ := time.Parse(time.RFC3339, v) // validated by schema notBeforeUnixTime := date.UnixTime(notBeforeDate) parameters.KeyAttributes.NotBefore = ¬BeforeUnixTime @@ -494,7 +494,7 @@ func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) Read() sdk.ResourceFun if key := resp.Key; key != nil { model.KeyType = string(key.Kty) - model.KeyOpts = pointer.From(key.KeyOps) + model.KeyOptions = pointer.From(key.KeyOps) model.N = pointer.From(key.N) model.E = pointer.From(key.N) @@ -513,7 +513,7 @@ func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) Read() sdk.ResourceFun if attributes := resp.Attributes; attributes != nil { if v := attributes.NotBefore; v != nil { - model.NotBeforeDate = time.Time(*v).Format(time.RFC3339) + model.NotUsableBeforeDate = time.Time(*v).Format(time.RFC3339) } if v := attributes.Expires; v != nil { @@ -629,7 +629,7 @@ func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) Update() sdk.ResourceF parameters := keyvault.KeyUpdateParameters{} - if meta.ResourceData.HasChange("key_opts") { + if meta.ResourceData.HasChange("key_options") { keyOptions := k.expandManagedHSMKeyOptions(&model) parameters.KeyOps = keyOptions } @@ -638,11 +638,11 @@ func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) Update() sdk.ResourceF parameters.Tags = expandTags(model.Tags) } - if meta.ResourceData.HasChanges("not_before_date", "expiration_date") { + if meta.ResourceData.HasChanges("not_usable_before_date", "expiration_date") { parameters.KeyAttributes = &keyvault.KeyAttributes{ Enabled: pointer.To(true), } - if v := model.NotBeforeDate; v != "" { + if v := model.NotUsableBeforeDate; v != "" { notBeforeDate, _ := time.Parse(time.RFC3339, v) // validated by schema notBeforeUnixTime := date.UnixTime(notBeforeDate) parameters.KeyAttributes.NotBefore = ¬BeforeUnixTime @@ -733,7 +733,7 @@ var _ sdk.ResourceWithCustomizeDiff = KeyVaultManagedHardwareSecurityModuleKeyRe func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) expandManagedHSMKeyOptions(d *KeyVaultManagedHardwareSecurityModuleKeyModel) *[]keyvault.JSONWebKeyOperation { results := make([]keyvault.JSONWebKeyOperation, 0) - for _, option := range d.KeyOpts { + for _, option := range d.KeyOptions { results = append(results, keyvault.JSONWebKeyOperation(option)) } @@ -763,8 +763,8 @@ func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) expandKeyVaultKeyRotat } autoRotationRaw := policy.Automatic[0] - if autoRotationRaw.TimeAfterCreation != "" { - lifetimeActionRotate.Trigger.TimeAfterCreate = &autoRotationRaw.TimeAfterCreation + if autoRotationRaw.DurationAfterCreation != "" { + lifetimeActionRotate.Trigger.TimeAfterCreate = &autoRotationRaw.DurationAfterCreation } if autoRotationRaw.TimeBeforeExpiry != "" { @@ -800,7 +800,7 @@ func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) flattenKeyVaultKeyRota if action != nil && trigger != nil { if strings.EqualFold(string(action.Type), string(keyvault.ActionTypeRotate)) { var autoRotation AutomaticModel - autoRotation.TimeAfterCreation = pointer.From(trigger.TimeAfterCreate) + autoRotation.DurationAfterCreation = pointer.From(trigger.TimeAfterCreate) autoRotation.TimeBeforeExpiry = pointer.From(trigger.TimeBeforeExpiry) policy.Automatic = append(policy.Automatic, autoRotation) } diff --git a/internal/services/managedhsm/key_vault_managed_hardware_security_module_key_resource_test.go b/internal/services/managedhsm/key_vault_managed_hardware_security_module_key_resource_test.go index 7a6fbd3505ea..9b3d55f0398d 100644 --- a/internal/services/managedhsm/key_vault_managed_hardware_security_module_key_resource_test.go +++ b/internal/services/managedhsm/key_vault_managed_hardware_security_module_key_resource_test.go @@ -162,7 +162,7 @@ resource "azurerm_key_vault_managed_hardware_security_module_key" "test" { managed_hsm_id = azurerm_key_vault_managed_hardware_security_module.test.id key_type = "EC-HSM" - key_opts = [ + key_options = [ "sign", "verify", ] diff --git a/website/docs/r/key_vault_managed_hardware_security_module_key.html.markdown b/website/docs/r/key_vault_managed_hardware_security_module_key.html.markdown index 5f96a3863142..5441f03b71c2 100644 --- a/website/docs/r/key_vault_managed_hardware_security_module_key.html.markdown +++ b/website/docs/r/key_vault_managed_hardware_security_module_key.html.markdown @@ -187,13 +187,13 @@ The following arguments are supported: * `key_type` - (Required) Specifies the Key Type to use for this Managed Hardware Security Module Key. Possible values are `EC-HSM`, `RSA-HSM` and `oct-HSM`. Changing this forces a new resource to be created. -* `key_size` - (Optional) Specifies the Size of the RSA key to create in bytes. For example, 1024 or 2048. *Note*: This field is required if `key_type` is `RSA-HSM`. Changing this forces a new resource to be created. +* `key_size` - (Optional) Specifies the Size of the RSA key to create in bytes. For example, `1024` or `2048`. *Note*: This field is required if `key_type` is `RSA-HSM`. Changing this forces a new resource to be created. * `curve` - (Optional) Specifies the curve to use when creating an `EC` key. Possible values are `P-256`, `P-256K`, `P-384`, and `P-521`. This field will be required in a future release if `key_type` is `EC-HSM`. The API will default to `P-256` if nothing is specified. Changing this forces a new resource to be created. -* `key_opts` - (Required) A list of JSON web key operations. Possible values are `decrypt`, `encrypt`, `import`, `export`, `sign`, `unwrapKey`, `verify` and `wrapKey`. Please note these values are case sensitive. +* `key_options` - (Required) A list of JSON web key operations. Possible values are `decrypt`, `encrypt`, `import`, `export`, `sign`, `unwrapKey`, `verify` and `wrapKey`. Please note these values are case sensitive. -* `not_before_date` - (Optional) Key not usable before the provided UTC datetime (Y-m-d'T'H:M:S'Z'). +* `not_usable_before_date` - (Optional) Key not usable before the provided UTC datetime (Y-m-d'T'H:M:S'Z'). * `expiration_date` - (Optional) Expiration UTC datetime (Y-m-d'T'H:M:S'Z'). @@ -213,7 +213,7 @@ A `rotation_policy` block supports the following: An `automatic` block supports the following: -* `time_after_creation` - (Optional) Rotate automatically at a duration after create as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations). +* `duration_after_creation` - (Optional) Rotate automatically at a duration after create as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations). * `time_before_expiry` - (Optional) Rotate automatically at a duration before expiry as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations).