fix: refactor sqlserver handle optional encryption (#27)
All checks were successful
Publish / Check GoReleaser config (push) Successful in 12s
Publish / Publish provider (push) Successful in 17m14s

## Description

<!-- **Please link some issue here describing what you are trying to achieve.**

In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->

relates to #1234

## Checklist

- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] Acceptance tests got implemented or updated (see e.g. [here](f5f99d1709/stackit/internal/services/dns/dns_acc_test.go))
- [x] Unit tests are passing: `make test` (will be checked by CI)
- [x] No linter issues: `make lint` (will be checked by CI)

Reviewed-on: #27
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-committed-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
This commit is contained in:
Marcel_Henselin 2026-02-02 10:52:21 +00:00 committed by Marcel_Henselin
parent a5a388f238
commit 3dbf79c95f
Signed by: tf-provider.git.onstackit.cloud
GPG key ID: 6D7E8A1ED8955A9C
2 changed files with 20 additions and 11 deletions

View file

@ -175,12 +175,18 @@ func toCreatePayload(
storagePayload.Size = conversion.Int64ValueToPointer(storage.Size) storagePayload.Size = conversion.Int64ValueToPointer(storage.Size)
} }
encryptionPayload := &sqlserverflex.CreateInstanceRequestPayloadGetEncryptionArgType{} var encryptionPayload *sqlserverflex.CreateInstanceRequestPayloadGetEncryptionArgType
if encryption != nil { if encryption != nil &&
encryptionPayload.KekKeyId = conversion.StringValueToPointer(encryption.KeyId) !encryption.KeyId.IsNull() && !encryption.KeyId.IsUnknown() &&
encryptionPayload.KekKeyVersion = conversion.StringValueToPointer(encryption.KeyVersion) !encryption.KeyRingId.IsNull() && !encryption.KeyRingId.IsUnknown() &&
encryptionPayload.KekKeyRingId = conversion.StringValueToPointer(encryption.KeyRingId) !encryption.KeyVersion.IsNull() && !encryption.KeyVersion.IsUnknown() &&
encryptionPayload.ServiceAccount = conversion.StringValueToPointer(encryption.ServiceAccount) !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 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" sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
) )
// READY, PENDING, PROGRESSING, FAILURE, UNKNOWN,
const ( const (
InstanceStateEmpty = "" InstanceStateEmpty = ""
InstanceStateProcessing = "Progressing" InstanceStateSuccess = "READY"
InstanceStateUnknown = "Unknown" InstanceStatePending = "PENDING"
InstanceStateSuccess = "Ready" InstanceStateProcessing = "PROGRESSING"
InstanceStateFailed = "Failed" InstanceStateFailed = "FAILURE"
InstanceStateUnknown = "UNKNOWN"
InstanceStateTerminating = "TERMINATING"
) )
// APIClientInstanceInterface Interface needed for tests // APIClientInstanceInterface Interface needed for tests