fix: refactor sqlserver handle optional encryption
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 4s
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 16m22s
CI Workflow / CI (pull_request) Failing after 20m8s
CI Workflow / Code coverage report (pull_request) Has been skipped

This commit is contained in:
Marcel_Henselin 2026-02-02 11:51:56 +01:00
parent a5a388f238
commit 11573835dc
2 changed files with 20 additions and 11 deletions

View file

@ -175,12 +175,18 @@ func toCreatePayload(
storagePayload.Size = conversion.Int64ValueToPointer(storage.Size)
}
encryptionPayload := &sqlserverflex.CreateInstanceRequestPayloadGetEncryptionArgType{}
if encryption != nil {
encryptionPayload.KekKeyId = conversion.StringValueToPointer(encryption.KeyId)
encryptionPayload.KekKeyVersion = conversion.StringValueToPointer(encryption.KeyVersion)
encryptionPayload.KekKeyRingId = conversion.StringValueToPointer(encryption.KeyRingId)
encryptionPayload.ServiceAccount = conversion.StringValueToPointer(encryption.ServiceAccount)
var encryptionPayload *sqlserverflex.CreateInstanceRequestPayloadGetEncryptionArgType
if encryption != nil &&
!encryption.KeyId.IsNull() && !encryption.KeyId.IsUnknown() &&
!encryption.KeyRingId.IsNull() && !encryption.KeyRingId.IsUnknown() &&
!encryption.KeyVersion.IsNull() && !encryption.KeyVersion.IsUnknown() &&
!encryption.ServiceAccount.IsNull() && !encryption.ServiceAccount.IsUnknown() {
encryptionPayload = &sqlserverflex.CreateInstanceRequestPayloadGetEncryptionArgType{
KekKeyId: conversion.StringValueToPointer(encryption.KeyId),
KekKeyRingId: conversion.StringValueToPointer(encryption.KeyVersion),
KekKeyVersion: conversion.StringValueToPointer(encryption.KeyRingId),
ServiceAccount: conversion.StringValueToPointer(encryption.ServiceAccount),
}
}
var aclElements []string

View file

@ -16,12 +16,15 @@ import (
sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
)
// READY, PENDING, PROGRESSING, FAILURE, UNKNOWN,
const (
InstanceStateEmpty = ""
InstanceStateProcessing = "Progressing"
InstanceStateUnknown = "Unknown"
InstanceStateSuccess = "Ready"
InstanceStateFailed = "Failed"
InstanceStateEmpty = ""
InstanceStateSuccess = "READY"
InstanceStatePending = "PENDING"
InstanceStateProcessing = "PROGRESSING"
InstanceStateFailed = "FAILURE"
InstanceStateUnknown = "UNKNOWN"
InstanceStateTerminating = "TERMINATING"
)
// APIClientInstanceInterface Interface needed for tests