Skip to content

Commit

Permalink
add new HSM Key feature option
Browse files Browse the repository at this point in the history
  • Loading branch information
jackofallops committed May 24, 2024
1 parent 4479488 commit 881f636
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
6 changes: 6 additions & 0 deletions internal/provider/framework/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ func (p *ProviderConfig) Load(ctx context.Context, data *ProviderModel, tfVersio
f.KeyVault.PurgeSoftDeletedHSMsOnDestroy = feature[0].PurgeSoftDeletedHardwareSecurityModulesOnDestroy.ValueBool()
}

f.KeyVault.PurgeSoftDeletedHSMKeysOnDestroy = true
if !feature[0].PurgeSoftDeletedHardwareSecurityModulesKeysOnDestroy.IsNull() && !feature[0].PurgeSoftDeletedHardwareSecurityModulesKeysOnDestroy.IsUnknown() {
f.KeyVault.PurgeSoftDeletedHSMKeysOnDestroy = feature[0].PurgeSoftDeletedHardwareSecurityModulesKeysOnDestroy.ValueBool()
}

f.KeyVault.RecoverSoftDeletedCerts = true
if !feature[0].RecoverSoftDeletedCertificates.IsNull() && !feature[0].RecoverSoftDeletedCertificates.IsUnknown() {
f.KeyVault.RecoverSoftDeletedCerts = feature[0].RecoverSoftDeletedCertificates.ValueBool()
Expand All @@ -410,6 +415,7 @@ func (p *ProviderConfig) Load(ctx context.Context, data *ProviderModel, tfVersio
f.KeyVault.PurgeSoftDeletedKeysOnDestroy = true
f.KeyVault.PurgeSoftDeletedSecretsOnDestroy = true
f.KeyVault.PurgeSoftDeletedHSMsOnDestroy = true
f.KeyVault.PurgeSoftDeletedHSMKeysOnDestroy = true
f.KeyVault.RecoverSoftDeletedCerts = true
f.KeyVault.RecoverSoftDeletedKeyVaults = true
f.KeyVault.RecoverSoftDeletedKeys = true
Expand Down
4 changes: 4 additions & 0 deletions internal/provider/framework/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ func TestProviderConfig_LoadDefault(t *testing.T) {
t.Errorf("expected key_vault.purge_soft_deleted_hardware_security_modules_on_destroy to be true")
}

if !features.KeyVault.PurgeSoftDeletedHSMKeysOnDestroy {
t.Errorf("expected key_vault.purge_soft_deleted_hardware_security_module_keys_on_destroy to be true")
}

if !features.KeyVault.RecoverSoftDeletedCerts {
t.Errorf("expected key_vault.recover_soft_deleted_certificates to be true")
}
Expand Down
38 changes: 20 additions & 18 deletions internal/provider/framework/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,29 @@ var CognitiveAccountAttributes = map[string]attr.Type{
}

type KeyVault struct {
PurgeSoftDeleteOnDestroy types.Bool `tfsdk:"purge_soft_delete_on_destroy"`
PurgeSoftDeletedCertificatesOnDestroy types.Bool `tfsdk:"purge_soft_deleted_certificates_on_destroy"`
PurgeSoftDeletedKeysOnDestroy types.Bool `tfsdk:"purge_soft_deleted_keys_on_destroy"`
PurgeSoftDeletedSecretsOnDestroy types.Bool `tfsdk:"purge_soft_deleted_secrets_on_destroy"`
PurgeSoftDeletedHardwareSecurityModulesOnDestroy types.Bool `tfsdk:"purge_soft_deleted_hardware_security_modules_on_destroy"`
RecoverSoftDeletedCertificates types.Bool `tfsdk:"recover_soft_deleted_certificates"`
RecoverSoftDeletedKeyVaults types.Bool `tfsdk:"recover_soft_deleted_key_vaults"`
RecoverSoftDeletedKeys types.Bool `tfsdk:"recover_soft_deleted_keys"`
RecoverSoftDeletedSecrets types.Bool `tfsdk:"recover_soft_deleted_secrets"`
PurgeSoftDeleteOnDestroy types.Bool `tfsdk:"purge_soft_delete_on_destroy"`
PurgeSoftDeletedCertificatesOnDestroy types.Bool `tfsdk:"purge_soft_deleted_certificates_on_destroy"`
PurgeSoftDeletedKeysOnDestroy types.Bool `tfsdk:"purge_soft_deleted_keys_on_destroy"`
PurgeSoftDeletedSecretsOnDestroy types.Bool `tfsdk:"purge_soft_deleted_secrets_on_destroy"`
PurgeSoftDeletedHardwareSecurityModulesOnDestroy types.Bool `tfsdk:"purge_soft_deleted_hardware_security_modules_on_destroy"`
PurgeSoftDeletedHardwareSecurityModulesKeysOnDestroy types.Bool `tfsdk:"purge_soft_deleted_hardware_security_module_keys_on_destroy"`
RecoverSoftDeletedCertificates types.Bool `tfsdk:"recover_soft_deleted_certificates"`
RecoverSoftDeletedKeyVaults types.Bool `tfsdk:"recover_soft_deleted_key_vaults"`
RecoverSoftDeletedKeys types.Bool `tfsdk:"recover_soft_deleted_keys"`
RecoverSoftDeletedSecrets types.Bool `tfsdk:"recover_soft_deleted_secrets"`
}

var KeyVaultAttributes = map[string]attr.Type{
"purge_soft_delete_on_destroy": types.BoolType,
"purge_soft_deleted_certificates_on_destroy": types.BoolType,
"purge_soft_deleted_keys_on_destroy": types.BoolType,
"purge_soft_deleted_secrets_on_destroy": types.BoolType,
"purge_soft_deleted_hardware_security_modules_on_destroy": types.BoolType,
"recover_soft_deleted_certificates": types.BoolType,
"recover_soft_deleted_key_vaults": types.BoolType,
"recover_soft_deleted_keys": types.BoolType,
"recover_soft_deleted_secrets": types.BoolType,
"purge_soft_delete_on_destroy": types.BoolType,
"purge_soft_deleted_certificates_on_destroy": types.BoolType,
"purge_soft_deleted_keys_on_destroy": types.BoolType,
"purge_soft_deleted_secrets_on_destroy": types.BoolType,
"purge_soft_deleted_hardware_security_modules_on_destroy": types.BoolType,
"purge_soft_deleted_hardware_security_module_keys_on_destroy": types.BoolType,
"recover_soft_deleted_certificates": types.BoolType,
"recover_soft_deleted_key_vaults": types.BoolType,
"recover_soft_deleted_keys": types.BoolType,
"recover_soft_deleted_secrets": types.BoolType,
}

type LogAnalyticsWorkspace struct {
Expand Down

0 comments on commit 881f636

Please sign in to comment.