Skip to content

Commit 9705d53

Browse files
committed
Add STACKIT KMS support
Add encryption/decryption support using STACKIT KMS (Key Management Service). This follows the same pattern as existing KMS providers (AWS, GCP, Azure, HuaweiCloud). New files: - stackitkms/keysource.go: MasterKey implementation using STACKIT SDK - stackitkms/keysource_test.go: Unit tests - keyservice/stackitkms.go: StackitKmsKey protobuf-compatible types Modified files: - cmd/sops/main.go: --stackit-kms, --add-stackit-kms, --rm-stackit-kms flags - config/config.go: stackit_kms support in .sops.yaml - keyservice/keyservice.proto: StackitKmsKey message - keyservice/keyservice.go: KeyFromMasterKey conversion - keyservice/server.go: encrypt/decrypt handlers - stores/stores.go: serialization in encrypted file metadata - go.mod: STACKIT SDK dependency Key format: projects/<projectId>/regions/<regionId>/keyRings/<keyRingId>/keys/<keyId>/versions/<versionNumber> Signed-off-by: Stanislav Kopp <stanislav.kopp@digits.schwarz>
1 parent 2622fc1 commit 9705d53

11 files changed

Lines changed: 738 additions & 38 deletions

File tree

cmd/sops/main.go

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"github.com/getsops/sops/v3/gcpkms"
3737
"github.com/getsops/sops/v3/hckms"
3838
"github.com/getsops/sops/v3/hcvault"
39+
"github.com/getsops/sops/v3/stackitkms"
3940
"github.com/getsops/sops/v3/keys"
4041
"github.com/getsops/sops/v3/keyservice"
4142
"github.com/getsops/sops/v3/kms"
@@ -91,14 +92,14 @@ func main() {
9192
},
9293
}
9394
app.Name = "sops"
94-
app.Usage = "sops - encrypted file editor with AWS KMS, GCP KMS, HuaweiCloud KMS, Azure Key Vault, age, and GPG support"
95+
app.Usage = "sops - encrypted file editor with AWS KMS, GCP KMS, HuaweiCloud KMS, STACKIT KMS, Azure Key Vault, age, and GPG support"
9596
app.ArgsUsage = "sops [options] file"
9697
app.Version = version.Version
9798
app.Authors = []cli.Author{
9899
{Name: "CNCF Maintainers"},
99100
}
100-
app.UsageText = `sops is an editor of encrypted files that supports AWS KMS, GCP, HuaweiCloud KMS, AZKV,
101-
PGP, and Age
101+
app.UsageText = `sops is an editor of encrypted files that supports AWS KMS, GCP, HuaweiCloud KMS, STACKIT KMS,
102+
AZKV, PGP, and Age
102103
103104
To encrypt or decrypt a document with AWS KMS, specify the KMS ARN
104105
in the -k flag or in the SOPS_KMS_ARN environment variable.
@@ -117,6 +118,12 @@ func main() {
117118
HUAWEICLOUD_SDK_AK, HUAWEICLOUD_SDK_SK, HUAWEICLOUD_SDK_PROJECT_ID, or
118119
use credentials file at ~/.huaweicloud/credentials)
119120
121+
To encrypt or decrypt a document with STACKIT KMS, specify the
122+
STACKIT KMS resource ID in the --stackit-kms flag or in the
123+
SOPS_STACKIT_KMS_IDS environment variable.
124+
(Authentication is handled by the STACKIT SDK via environment variables,
125+
service account key files, or credentials file at ~/.stackit/credentials.json)
126+
120127
To encrypt or decrypt a document with HashiCorp Vault's Transit Secret
121128
Engine, specify the Vault key URI name in the --hc-vault-transit flag
122129
or in the SOPS_VAULT_URIS environment variable (for example
@@ -142,12 +149,12 @@ func main() {
142149
To use multiple KMS or PGP keys, separate them by commas. For example:
143150
$ sops -p "10F2...0A, 85D...B3F21" file.yaml
144151
145-
The -p, -k, --gcp-kms, --hckms, --hc-vault-transit, and --azure-kv flags are only
152+
The -p, -k, --gcp-kms, --hckms, --stackit-kms, --hc-vault-transit, and --azure-kv flags are only
146153
used to encrypt new documents. Editing or decrypting existing documents
147154
can be done with "sops file" or "sops decrypt file" respectively. The KMS and
148155
PGP keys listed in the encrypted documents are used then. To manage master
149-
keys in existing documents, use the "add-{kms,pgp,gcp-kms,hckms,azure-kv,hc-vault-transit}"
150-
and "rm-{kms,pgp,gcp-kms,hckms,azure-kv,hc-vault-transit}" flags with --rotate
156+
keys in existing documents, use the "add-{kms,pgp,gcp-kms,hckms,stackit-kms,azure-kv,hc-vault-transit}"
157+
and "rm-{kms,pgp,gcp-kms,hckms,stackit-kms,azure-kv,hc-vault-transit}" flags with --rotate
151158
or the updatekeys command.
152159
153160
To use a different GPG binary than the one in your PATH, set SOPS_GPG_EXEC.
@@ -582,6 +589,10 @@ func main() {
582589
Name: "hckms",
583590
Usage: "the HuaweiCloud KMS key ID (format: region:key-uuid) the new group should contain. Can be specified more than once",
584591
},
592+
cli.StringSliceFlag{
593+
Name: "stackit-kms",
594+
Usage: "the STACKIT KMS resource ID the new group should contain. Can be specified more than once",
595+
},
585596
cli.StringSliceFlag{
586597
Name: "azure-kv",
587598
Usage: "the Azure Key Vault key URL the new group should contain. Can be specified more than once",
@@ -635,6 +646,15 @@ func main() {
635646
}
636647
group = append(group, k)
637648
}
649+
stackitKmsIds := c.StringSlice("stackit-kms")
650+
for _, resID := range stackitKmsIds {
651+
k, err := stackitkms.NewMasterKey(resID)
652+
if err != nil {
653+
log.WithError(err).Error("Failed to add key")
654+
continue
655+
}
656+
group = append(group, k)
657+
}
638658
for _, url := range azkvs {
639659
k, err := azkv.NewMasterKeyFromURL(url)
640660
if err != nil {
@@ -950,6 +970,11 @@ func main() {
950970
Usage: "comma separated list of HuaweiCloud KMS key IDs (format: region:key-uuid)",
951971
EnvVar: "SOPS_HUAWEICLOUD_KMS_IDS",
952972
},
973+
cli.StringFlag{
974+
Name: "stackit-kms",
975+
Usage: "comma separated list of STACKIT KMS resource IDs",
976+
EnvVar: "SOPS_STACKIT_KMS_IDS",
977+
},
953978
cli.StringFlag{
954979
Name: "azure-kv",
955980
Usage: "comma separated list of Azure Key Vault URLs",
@@ -1143,6 +1168,14 @@ func main() {
11431168
Name: "rm-hckms",
11441169
Usage: "remove the provided comma-separated list of HuaweiCloud KMS key IDs (format: region:key-uuid) from the list of master keys on the given file",
11451170
},
1171+
cli.StringFlag{
1172+
Name: "add-stackit-kms",
1173+
Usage: "add the provided comma-separated list of STACKIT KMS resource IDs to the list of master keys on the given file",
1174+
},
1175+
cli.StringFlag{
1176+
Name: "rm-stackit-kms",
1177+
Usage: "remove the provided comma-separated list of STACKIT KMS resource IDs from the list of master keys on the given file",
1178+
},
11461179
cli.StringFlag{
11471180
Name: "add-azure-kv",
11481181
Usage: "add the provided comma-separated list of Azure Key Vault key URLs to the list of master keys on the given file",
@@ -1209,8 +1242,8 @@ func main() {
12091242
return toExitError(err)
12101243
}
12111244
if _, err := os.Stat(fileName); os.IsNotExist(err) {
1212-
if c.String("add-kms") != "" || c.String("add-pgp") != "" || c.String("add-gcp-kms") != "" || c.String("add-hckms") != "" || c.String("add-hc-vault-transit") != "" || c.String("add-azure-kv") != "" || c.String("add-age") != "" ||
1213-
c.String("rm-kms") != "" || c.String("rm-pgp") != "" || c.String("rm-gcp-kms") != "" || c.String("rm-hckms") != "" || c.String("rm-hc-vault-transit") != "" || c.String("rm-azure-kv") != "" || c.String("rm-age") != "" {
1245+
if c.String("add-kms") != "" || c.String("add-pgp") != "" || c.String("add-gcp-kms") != "" || c.String("add-hckms") != "" || c.String("add-stackit-kms") != "" || c.String("add-hc-vault-transit") != "" || c.String("add-azure-kv") != "" || c.String("add-age") != "" ||
1246+
c.String("rm-kms") != "" || c.String("rm-pgp") != "" || c.String("rm-gcp-kms") != "" || c.String("rm-hckms") != "" || c.String("rm-stackit-kms") != "" || c.String("rm-hc-vault-transit") != "" || c.String("rm-azure-kv") != "" || c.String("rm-age") != "" {
12141247
return common.NewExitError(fmt.Sprintf("Error: cannot add or remove keys on non-existent file %q, use the `edit` subcommand instead.", fileName), codes.CannotChangeKeysFromNonExistentFile)
12151248
}
12161249
}
@@ -1301,6 +1334,11 @@ func main() {
13011334
Usage: "comma separated list of HuaweiCloud KMS key IDs (format: region:key-uuid)",
13021335
EnvVar: "SOPS_HUAWEICLOUD_KMS_IDS",
13031336
},
1337+
cli.StringFlag{
1338+
Name: "stackit-kms",
1339+
Usage: "comma separated list of STACKIT KMS resource IDs",
1340+
EnvVar: "SOPS_STACKIT_KMS_IDS",
1341+
},
13041342
cli.StringFlag{
13051343
Name: "azure-kv",
13061344
Usage: "comma separated list of Azure Key Vault URLs",
@@ -1714,6 +1752,11 @@ func main() {
17141752
Usage: "comma separated list of HuaweiCloud KMS key IDs (format: region:key-uuid)",
17151753
EnvVar: "SOPS_HUAWEICLOUD_KMS_IDS",
17161754
},
1755+
cli.StringFlag{
1756+
Name: "stackit-kms",
1757+
Usage: "comma separated list of STACKIT KMS resource IDs",
1758+
EnvVar: "SOPS_STACKIT_KMS_IDS",
1759+
},
17171760
cli.StringFlag{
17181761
Name: "azure-kv",
17191762
Usage: "comma separated list of Azure Key Vault URLs",
@@ -1770,6 +1813,14 @@ func main() {
17701813
Name: "rm-hckms",
17711814
Usage: "remove the provided comma-separated list of HuaweiCloud KMS key IDs (format: region:key-uuid) from the list of master keys on the given file",
17721815
},
1816+
cli.StringFlag{
1817+
Name: "add-stackit-kms",
1818+
Usage: "add the provided comma-separated list of STACKIT KMS resource IDs to the list of master keys on the given file",
1819+
},
1820+
cli.StringFlag{
1821+
Name: "rm-stackit-kms",
1822+
Usage: "remove the provided comma-separated list of STACKIT KMS resource IDs from the list of master keys on the given file",
1823+
},
17731824
cli.StringFlag{
17741825
Name: "add-azure-kv",
17751826
Usage: "add the provided comma-separated list of Azure Key Vault key URLs to the list of master keys on the given file",
@@ -2235,7 +2286,7 @@ func getEncryptConfig(c *cli.Context, fileName string, inputStore common.Store,
22352286
}, nil
22362287
}
22372288

2238-
func getMasterKeys(c *cli.Context, kmsEncryptionContext map[string]*string, kmsOptionName string, pgpOptionName string, gcpKmsOptionName string, hckmsOptionName string, azureKvOptionName string, hcVaultTransitOptionName string, ageOptionName string) ([]keys.MasterKey, error) {
2289+
func getMasterKeys(c *cli.Context, kmsEncryptionContext map[string]*string, kmsOptionName string, pgpOptionName string, gcpKmsOptionName string, hckmsOptionName string, stackitKmsOptionName string, azureKvOptionName string, hcVaultTransitOptionName string, ageOptionName string) ([]keys.MasterKey, error) {
22392290
var masterKeys []keys.MasterKey
22402291
for _, k := range kms.MasterKeysFromArnString(c.String(kmsOptionName), kmsEncryptionContext, c.String("aws-profile")) {
22412292
masterKeys = append(masterKeys, k)
@@ -2253,6 +2304,13 @@ func getMasterKeys(c *cli.Context, kmsEncryptionContext map[string]*string, kmsO
22532304
for _, k := range hckmsKeys {
22542305
masterKeys = append(masterKeys, k)
22552306
}
2307+
stackitKmsKeys, err := stackitkms.NewMasterKeyFromResourceIDString(c.String(stackitKmsOptionName))
2308+
if err != nil {
2309+
return nil, err
2310+
}
2311+
for _, k := range stackitKmsKeys {
2312+
masterKeys = append(masterKeys, k)
2313+
}
22562314
azureKeys, err := azkv.MasterKeysFromURLs(c.String(azureKvOptionName))
22572315
if err != nil {
22582316
return nil, err
@@ -2279,11 +2337,11 @@ func getMasterKeys(c *cli.Context, kmsEncryptionContext map[string]*string, kmsO
22792337

22802338
func getRotateOpts(c *cli.Context, fileName string, inputStore common.Store, outputStore common.Store, svcs []keyservice.KeyServiceClient, decryptionOrder []string) (rotateOpts, error) {
22812339
kmsEncryptionContext := kms.ParseKMSContext(c.String("encryption-context"))
2282-
addMasterKeys, err := getMasterKeys(c, kmsEncryptionContext, "add-kms", "add-pgp", "add-gcp-kms", "add-hckms", "add-azure-kv", "add-hc-vault-transit", "add-age")
2340+
addMasterKeys, err := getMasterKeys(c, kmsEncryptionContext, "add-kms", "add-pgp", "add-gcp-kms", "add-hckms", "add-stackit-kms", "add-azure-kv", "add-hc-vault-transit", "add-age")
22832341
if err != nil {
22842342
return rotateOpts{}, err
22852343
}
2286-
rmMasterKeys, err := getMasterKeys(c, kmsEncryptionContext, "rm-kms", "rm-pgp", "rm-gcp-kms", "rm-hckms", "rm-azure-kv", "rm-hc-vault-transit", "rm-age")
2344+
rmMasterKeys, err := getMasterKeys(c, kmsEncryptionContext, "rm-kms", "rm-pgp", "rm-gcp-kms", "rm-hckms", "rm-stackit-kms", "rm-azure-kv", "rm-hc-vault-transit", "rm-age")
22872345
if err != nil {
22882346
return rotateOpts{}, err
22892347
}
@@ -2432,6 +2490,7 @@ func keyGroups(c *cli.Context, file string, optionalConfig *config.Config) ([]so
24322490
var azkvKeys []keys.MasterKey
24332491
var hcVaultMkKeys []keys.MasterKey
24342492
var hckmsMkKeys []keys.MasterKey
2493+
var stackitKmsMkKeys []keys.MasterKey
24352494
var ageMasterKeys []keys.MasterKey
24362495
kmsEncryptionContext := kms.ParseKMSContext(c.String("encryption-context"))
24372496
if c.String("encryption-context") != "" && kmsEncryptionContext == nil {
@@ -2456,6 +2515,15 @@ func keyGroups(c *cli.Context, file string, optionalConfig *config.Config) ([]so
24562515
hckmsMkKeys = append(hckmsMkKeys, k)
24572516
}
24582517
}
2518+
if c.String("stackit-kms") != "" {
2519+
stackitKmsKeys, err := stackitkms.NewMasterKeyFromResourceIDString(c.String("stackit-kms"))
2520+
if err != nil {
2521+
return nil, err
2522+
}
2523+
for _, k := range stackitKmsKeys {
2524+
stackitKmsMkKeys = append(stackitKmsMkKeys, k)
2525+
}
2526+
}
24592527
if c.String("azure-kv") != "" {
24602528
azureKeys, err := azkv.MasterKeysFromURLs(c.String("azure-kv"))
24612529
if err != nil {
@@ -2488,7 +2556,7 @@ func keyGroups(c *cli.Context, file string, optionalConfig *config.Config) ([]so
24882556
ageMasterKeys = append(ageMasterKeys, k)
24892557
}
24902558
}
2491-
if c.String("kms") == "" && c.String("pgp") == "" && c.String("gcp-kms") == "" && c.String("hckms") == "" && c.String("azure-kv") == "" && c.String("hc-vault-transit") == "" && c.String("age") == "" {
2559+
if c.String("kms") == "" && c.String("pgp") == "" && c.String("gcp-kms") == "" && c.String("hckms") == "" && c.String("stackit-kms") == "" && c.String("azure-kv") == "" && c.String("hc-vault-transit") == "" && c.String("age") == "" {
24922560
conf := optionalConfig
24932561
var err error
24942562
if conf == nil {
@@ -2508,6 +2576,7 @@ func keyGroups(c *cli.Context, file string, optionalConfig *config.Config) ([]so
25082576
group = append(group, kmsKeys...)
25092577
group = append(group, cloudKmsKeys...)
25102578
group = append(group, hckmsMkKeys...)
2579+
group = append(group, stackitKmsMkKeys...)
25112580
group = append(group, azkvKeys...)
25122581
group = append(group, pgpKeys...)
25132582
group = append(group, hcVaultMkKeys...)

config/config.go

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/getsops/sops/v3/hcvault"
2020
"github.com/getsops/sops/v3/kms"
2121
"github.com/getsops/sops/v3/pgp"
22+
"github.com/getsops/sops/v3/stackitkms"
2223
"github.com/getsops/sops/v3/publish"
2324
"go.yaml.in/yaml/v3"
2425
)
@@ -130,14 +131,15 @@ type configFile struct {
130131
}
131132

132133
type keyGroup struct {
133-
Merge []keyGroup `yaml:"merge"`
134-
KMS []kmsKey `yaml:"kms"`
135-
GCPKMS []gcpKmsKey `yaml:"gcp_kms"`
136-
HCKms []hckmsKey `yaml:"hckms"`
137-
AzureKV []azureKVKey `yaml:"azure_keyvault"`
138-
Vault []string `yaml:"hc_vault"`
139-
Age []string `yaml:"age"`
140-
PGP []string `yaml:"pgp"`
134+
Merge []keyGroup `yaml:"merge"`
135+
KMS []kmsKey `yaml:"kms"`
136+
GCPKMS []gcpKmsKey `yaml:"gcp_kms"`
137+
HCKms []hckmsKey `yaml:"hckms"`
138+
StackitKms []stackitKmsKey `yaml:"stackit_kms"`
139+
AzureKV []azureKVKey `yaml:"azure_keyvault"`
140+
Vault []string `yaml:"hc_vault"`
141+
Age []string `yaml:"age"`
142+
PGP []string `yaml:"pgp"`
141143
}
142144

143145
type gcpKmsKey struct {
@@ -161,6 +163,10 @@ type hckmsKey struct {
161163
KeyID string `yaml:"key_id"`
162164
}
163165

166+
type stackitKmsKey struct {
167+
ResourceID string `yaml:"resource_id"`
168+
}
169+
164170
type destinationRule struct {
165171
PathRegex string `yaml:"path_regex"`
166172
S3Bucket string `yaml:"s3_bucket"`
@@ -183,6 +189,7 @@ type creationRule struct {
183189
PGP interface{} `yaml:"pgp"` // string or []string
184190
GCPKMS interface{} `yaml:"gcp_kms"` // string or []string
185191
HCKms []string `yaml:"hckms"`
192+
StackitKms interface{} `yaml:"stackit_kms"` // string or []string
186193
AzureKeyVault interface{} `yaml:"azure_keyvault"` // string or []string
187194
VaultURI interface{} `yaml:"hc_vault_transit_uri"` // string or []string
188195
KeyGroups []keyGroup `yaml:"key_groups"`
@@ -213,6 +220,10 @@ func (c *creationRule) GetGCPKMSKeys() ([]string, error) {
213220
return parseKeyField(c.GCPKMS, "gcp_kms")
214221
}
215222

223+
func (c *creationRule) GetStackitKmsKeys() ([]string, error) {
224+
return parseKeyField(c.StackitKms, "stackit_kms")
225+
}
226+
216227
func (c *creationRule) GetAzureKeyVaultKeys() ([]string, error) {
217228
return parseKeyField(c.AzureKeyVault, "azure_keyvault")
218229
}
@@ -343,6 +354,13 @@ func extractMasterKeys(group keyGroup) (sops.KeyGroup, error) {
343354
}
344355
keyGroup = append(keyGroup, key)
345356
}
357+
for _, k := range group.StackitKms {
358+
key, err := stackitkms.NewMasterKey(k.ResourceID)
359+
if err != nil {
360+
return nil, err
361+
}
362+
keyGroup = append(keyGroup, key)
363+
}
346364
for _, k := range group.AzureKV {
347365
if key, err := azkv.NewMasterKeyWithOptionalVersion(k.VaultURL, k.Key, k.Version); err == nil {
348366
keyGroup = append(keyGroup, key)
@@ -423,6 +441,17 @@ func getKeyGroupsFromCreationRule(cRule *creationRule, kmsEncryptionContext map[
423441
for _, k := range hckmsMasterKeys {
424442
keyGroup = append(keyGroup, k)
425443
}
444+
stackitKmsKeys, err := getKeysWithValidation(cRule.GetStackitKmsKeys, "stackit_kms")
445+
if err != nil {
446+
return nil, err
447+
}
448+
stackitKmsMasterKeys, err := stackitkms.NewMasterKeyFromResourceIDString(strings.Join(stackitKmsKeys, ","))
449+
if err != nil {
450+
return nil, err
451+
}
452+
for _, k := range stackitKmsMasterKeys {
453+
keyGroup = append(keyGroup, k)
454+
}
426455
azKeys, err := getKeysWithValidation(cRule.GetAzureKeyVaultKeys, "azure_keyvault")
427456
if err != nil {
428457
return nil, err

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ require (
3232
github.com/ory/dockertest/v3 v3.12.0
3333
github.com/pkg/errors v0.9.1
3434
github.com/sirupsen/logrus v1.9.4
35+
github.com/stackitcloud/stackit-sdk-go/core v0.22.0
36+
github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2
3537
github.com/stretchr/testify v1.11.1
3638
github.com/urfave/cli v1.22.17
3739
go.yaml.in/yaml/v3 v3.0.4
@@ -102,7 +104,7 @@ require (
102104
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
103105
github.com/goccy/go-yaml v1.9.8 // indirect
104106
github.com/gogo/protobuf v1.3.2 // indirect
105-
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
107+
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
106108
github.com/google/s2a-go v0.1.9 // indirect
107109
github.com/google/uuid v1.6.0 // indirect
108110
github.com/googleapis/enterprise-certificate-proxy v0.3.11 // indirect

go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ github.com/goccy/go-yaml v1.9.8 h1:5gMyLUeU1/6zl+WFfR1hN7D2kf+1/eRGa7DFtToiBvQ=
182182
github.com/goccy/go-yaml v1.9.8/go.mod h1:JubOolP3gh0HpiBc4BLRD4YmjEjHAmIIB2aaXKkTfoE=
183183
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
184184
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
185-
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
186-
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
185+
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
186+
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
187187
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
188188
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
189189
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -314,6 +314,10 @@ github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w
314314
github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g=
315315
github.com/spiffe/go-spiffe/v2 v2.6.0 h1:l+DolpxNWYgruGQVV0xsfeya3CsC7m8iBzDnMpsbLuo=
316316
github.com/spiffe/go-spiffe/v2 v2.6.0/go.mod h1:gm2SeUoMZEtpnzPNs2Csc0D/gX33k1xIx7lEzqblHEs=
317+
github.com/stackitcloud/stackit-sdk-go/core v0.22.0 h1:6rViz7GnNwXSh51Lur5xuDzO8EWSZfN9J0HvEkBKq6c=
318+
github.com/stackitcloud/stackit-sdk-go/core v0.22.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI=
319+
github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2 h1:2ulSL2IkIAKND59eAjbEhVkOoBMyvm48ojwz1a3t0U0=
320+
github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2/go.mod h1:cuIaMMiHeHQsbvy7BOFMutoV3QtN+ZBx7Tg3GmYUw7s=
317321
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
318322
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
319323
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=

keyservice/keyservice.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/getsops/sops/v3/keys"
1616
"github.com/getsops/sops/v3/kms"
1717
"github.com/getsops/sops/v3/pgp"
18+
"github.com/getsops/sops/v3/stackitkms"
1819
)
1920

2021
// KeyFromMasterKey converts a SOPS internal MasterKey to an RPC Key that can be serialized with Protocol Buffers
@@ -87,6 +88,14 @@ func KeyFromMasterKey(mk keys.MasterKey) Key {
8788
},
8889
},
8990
}
91+
case *stackitkms.MasterKey:
92+
return Key{
93+
KeyType: &Key_StackitKmsKey{
94+
StackitKmsKey: &StackitKmsKey{
95+
ResourceId: mk.ResourceID,
96+
},
97+
},
98+
}
9099
default:
91100
panic(fmt.Sprintf("Tried to convert unknown MasterKey type %T to keyservice.Key", mk))
92101
}

0 commit comments

Comments
 (0)