Skip to content

Commit 371df00

Browse files
authored
Merge pull request #1149 from zgalor/ARO-24796/add-kms-visibility-field
ARO-24796 | feat: add visibility field to AzureKmsEncryption type
2 parents 6aa7131 + 23cae94 commit 371df00

File tree

8 files changed

+211
-7
lines changed

8 files changed

+211
-7
lines changed

clientapi/arohcp/v1alpha1/azure_kms_encryption_builder.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ package v1alpha1 // github.com/openshift-online/ocm-api-model/clientapi/arohcp/v
2121

2222
// Contains the necessary attributes to support KMS encryption for Azure based clusters.
2323
type AzureKmsEncryptionBuilder struct {
24-
fieldSet_ []bool
25-
activeKey *AzureKmsKeyBuilder
24+
fieldSet_ []bool
25+
activeKey *AzureKmsKeyBuilder
26+
visibility AzureKmsEncryptionVisibility
2627
}
2728

2829
// NewAzureKmsEncryption creates a new builder of 'azure_kms_encryption' objects.
2930
func NewAzureKmsEncryption() *AzureKmsEncryptionBuilder {
3031
return &AzureKmsEncryptionBuilder{
31-
fieldSet_: make([]bool, 1),
32+
fieldSet_: make([]bool, 2),
3233
}
3334
}
3435

@@ -50,7 +51,7 @@ func (b *AzureKmsEncryptionBuilder) Empty() bool {
5051
// Contains the necessary attributes to support KMS encryption key for Azure based clusters
5152
func (b *AzureKmsEncryptionBuilder) ActiveKey(value *AzureKmsKeyBuilder) *AzureKmsEncryptionBuilder {
5253
if len(b.fieldSet_) == 0 {
53-
b.fieldSet_ = make([]bool, 1)
54+
b.fieldSet_ = make([]bool, 2)
5455
}
5556
b.activeKey = value
5657
if value != nil {
@@ -61,6 +62,18 @@ func (b *AzureKmsEncryptionBuilder) ActiveKey(value *AzureKmsKeyBuilder) *AzureK
6162
return b
6263
}
6364

65+
// Visibility sets the value of the 'visibility' attribute to the given value.
66+
//
67+
// AzureKmsEncryptionVisibility defines the visibility of the Azure KMS key vault.
68+
func (b *AzureKmsEncryptionBuilder) Visibility(value AzureKmsEncryptionVisibility) *AzureKmsEncryptionBuilder {
69+
if len(b.fieldSet_) == 0 {
70+
b.fieldSet_ = make([]bool, 2)
71+
}
72+
b.visibility = value
73+
b.fieldSet_[1] = true
74+
return b
75+
}
76+
6477
// Copy copies the attributes of the given object into this builder, discarding any previous values.
6578
func (b *AzureKmsEncryptionBuilder) Copy(object *AzureKmsEncryption) *AzureKmsEncryptionBuilder {
6679
if object == nil {
@@ -75,6 +88,7 @@ func (b *AzureKmsEncryptionBuilder) Copy(object *AzureKmsEncryption) *AzureKmsEn
7588
} else {
7689
b.activeKey = nil
7790
}
91+
b.visibility = object.visibility
7892
return b
7993
}
8094

@@ -91,5 +105,6 @@ func (b *AzureKmsEncryptionBuilder) Build() (object *AzureKmsEncryption, err err
91105
return
92106
}
93107
}
108+
object.visibility = b.visibility
94109
return
95110
}

clientapi/arohcp/v1alpha1/azure_kms_encryption_type.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ package v1alpha1 // github.com/openshift-online/ocm-api-model/clientapi/arohcp/v
2323
//
2424
// Contains the necessary attributes to support KMS encryption for Azure based clusters.
2525
type AzureKmsEncryption struct {
26-
fieldSet_ []bool
27-
activeKey *AzureKmsKey
26+
fieldSet_ []bool
27+
activeKey *AzureKmsKey
28+
visibility AzureKmsEncryptionVisibility
2829
}
2930

3031
// Empty returns true if the object is empty, i.e. no attribute has a value.
@@ -65,6 +66,33 @@ func (o *AzureKmsEncryption) GetActiveKey() (value *AzureKmsKey, ok bool) {
6566
return
6667
}
6768

69+
// Visibility returns the value of the 'visibility' attribute, or
70+
// the zero value of the type if the attribute doesn't have a value.
71+
//
72+
// visibility defines the visibility of the Azure Key Vault.
73+
// Accepted values are `public` and `private`.
74+
// Defaults to `public` if not set.
75+
func (o *AzureKmsEncryption) Visibility() AzureKmsEncryptionVisibility {
76+
if o != nil && len(o.fieldSet_) > 1 && o.fieldSet_[1] {
77+
return o.visibility
78+
}
79+
return AzureKmsEncryptionVisibility("")
80+
}
81+
82+
// GetVisibility returns the value of the 'visibility' attribute and
83+
// a flag indicating if the attribute has a value.
84+
//
85+
// visibility defines the visibility of the Azure Key Vault.
86+
// Accepted values are `public` and `private`.
87+
// Defaults to `public` if not set.
88+
func (o *AzureKmsEncryption) GetVisibility() (value AzureKmsEncryptionVisibility, ok bool) {
89+
ok = o != nil && len(o.fieldSet_) > 1 && o.fieldSet_[1]
90+
if ok {
91+
value = o.visibility
92+
}
93+
return
94+
}
95+
6896
// AzureKmsEncryptionListKind is the name of the type used to represent list of objects of
6997
// type 'azure_kms_encryption'.
7098
const AzureKmsEncryptionListKind = "AzureKmsEncryptionList"

clientapi/arohcp/v1alpha1/azure_kms_encryption_type_json.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ func WriteAzureKmsEncryption(object *AzureKmsEncryption, stream *jsoniter.Stream
4949
}
5050
stream.WriteObjectField("active_key")
5151
WriteAzureKmsKey(object.activeKey, stream)
52+
count++
53+
}
54+
present_ = len(object.fieldSet_) > 1 && object.fieldSet_[1]
55+
if present_ {
56+
if count > 0 {
57+
stream.WriteMore()
58+
}
59+
stream.WriteObjectField("visibility")
60+
stream.WriteString(string(object.visibility))
5261
}
5362
stream.WriteObjectEnd()
5463
}
@@ -68,7 +77,7 @@ func UnmarshalAzureKmsEncryption(source interface{}) (object *AzureKmsEncryption
6877
// ReadAzureKmsEncryption reads a value of the 'azure_kms_encryption' type from the given iterator.
6978
func ReadAzureKmsEncryption(iterator *jsoniter.Iterator) *AzureKmsEncryption {
7079
object := &AzureKmsEncryption{
71-
fieldSet_: make([]bool, 1),
80+
fieldSet_: make([]bool, 2),
7281
}
7382
for {
7483
field := iterator.ReadObject()
@@ -80,6 +89,11 @@ func ReadAzureKmsEncryption(iterator *jsoniter.Iterator) *AzureKmsEncryption {
8089
value := ReadAzureKmsKey(iterator)
8190
object.activeKey = value
8291
object.fieldSet_[0] = true
92+
case "visibility":
93+
text := iterator.ReadString()
94+
value := AzureKmsEncryptionVisibility(text)
95+
object.visibility = value
96+
object.fieldSet_[1] = true
8397
default:
8498
iterator.ReadAny()
8599
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
Copyright (c) 2020 Red Hat, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// IMPORTANT: This file has been generated automatically, refrain from modifying it manually as all
18+
// your changes will be lost when the file is generated again.
19+
20+
package v1alpha1 // github.com/openshift-online/ocm-api-model/clientapi/arohcp/v1alpha1
21+
22+
import (
23+
"io"
24+
25+
jsoniter "github.com/json-iterator/go"
26+
"github.com/openshift-online/ocm-api-model/clientapi/helpers"
27+
)
28+
29+
// MarshalAzureKmsEncryptionVisibilityList writes a list of values of the 'azure_kms_encryption_visibility' type to
30+
// the given writer.
31+
func MarshalAzureKmsEncryptionVisibilityList(list []AzureKmsEncryptionVisibility, writer io.Writer) error {
32+
stream := helpers.NewStream(writer)
33+
WriteAzureKmsEncryptionVisibilityList(list, stream)
34+
err := stream.Flush()
35+
if err != nil {
36+
return err
37+
}
38+
return stream.Error
39+
}
40+
41+
// WriteAzureKmsEncryptionVisibilityList writes a list of value of the 'azure_kms_encryption_visibility' type to
42+
// the given stream.
43+
func WriteAzureKmsEncryptionVisibilityList(list []AzureKmsEncryptionVisibility, stream *jsoniter.Stream) {
44+
stream.WriteArrayStart()
45+
for i, value := range list {
46+
if i > 0 {
47+
stream.WriteMore()
48+
}
49+
stream.WriteString(string(value))
50+
}
51+
stream.WriteArrayEnd()
52+
}
53+
54+
// UnmarshalAzureKmsEncryptionVisibilityList reads a list of values of the 'azure_kms_encryption_visibility' type
55+
// from the given source, which can be a slice of bytes, a string or a reader.
56+
func UnmarshalAzureKmsEncryptionVisibilityList(source interface{}) (items []AzureKmsEncryptionVisibility, err error) {
57+
iterator, err := helpers.NewIterator(source)
58+
if err != nil {
59+
return
60+
}
61+
items = ReadAzureKmsEncryptionVisibilityList(iterator)
62+
err = iterator.Error
63+
return
64+
}
65+
66+
// ReadAzureKmsEncryptionVisibilityList reads list of values of the ”azure_kms_encryption_visibility' type from
67+
// the given iterator.
68+
func ReadAzureKmsEncryptionVisibilityList(iterator *jsoniter.Iterator) []AzureKmsEncryptionVisibility {
69+
list := []AzureKmsEncryptionVisibility{}
70+
for iterator.ReadArray() {
71+
text := iterator.ReadString()
72+
item := AzureKmsEncryptionVisibility(text)
73+
list = append(list, item)
74+
}
75+
return list
76+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
Copyright (c) 2020 Red Hat, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// IMPORTANT: This file has been generated automatically, refrain from modifying it manually as all
18+
// your changes will be lost when the file is generated again.
19+
20+
package v1alpha1 // github.com/openshift-online/ocm-api-model/clientapi/arohcp/v1alpha1
21+
22+
// AzureKmsEncryptionVisibility represents the values of the 'azure_kms_encryption_visibility' enumerated type.
23+
type AzureKmsEncryptionVisibility string
24+
25+
const (
26+
// The key vault is privately accessible.
27+
AzureKmsEncryptionVisibilityPrivate AzureKmsEncryptionVisibility = "private"
28+
// The key vault is publicly accessible.
29+
AzureKmsEncryptionVisibilityPublic AzureKmsEncryptionVisibility = "public"
30+
)

model/aro_hcp/v1alpha1/azure_kms_encryption_type.model

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ struct AzureKmsEncryption {
1919
// The details of the active key
2020
// Required during creation.
2121
ActiveKey AzureKmsKey
22+
23+
// visibility defines the visibility of the Azure Key Vault.
24+
// Accepted values are `public` and `private`.
25+
// Defaults to `public` if not set.
26+
Visibility AzureKmsEncryptionVisibility
2227
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright (c) 2025 Red Hat, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// AzureKmsEncryptionVisibility defines the visibility of the Azure KMS key vault.
18+
enum AzureKmsEncryptionVisibility {
19+
// The key vault is publicly accessible.
20+
Public
21+
22+
// The key vault is privately accessible.
23+
Private
24+
}

openapi/aro_hcp/v1alpha1/openapi.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4143,9 +4143,21 @@
41434143
"active_key": {
41444144
"description": "The details of the active key\nRequired during creation.",
41454145
"$ref": "#/components/schemas/AzureKmsKey"
4146+
},
4147+
"visibility": {
4148+
"description": "visibility defines the visibility of the Azure Key Vault.\nAccepted values are `public` and `private`.\nDefaults to `public` if not set.",
4149+
"$ref": "#/components/schemas/AzureKmsEncryptionVisibility"
41464150
}
41474151
}
41484152
},
4153+
"AzureKmsEncryptionVisibility": {
4154+
"description": "AzureKmsEncryptionVisibility defines the visibility of the Azure KMS key vault.",
4155+
"type": "string",
4156+
"enum": [
4157+
"private",
4158+
"public"
4159+
]
4160+
},
41494161
"AzureKmsKey": {
41504162
"description": "Contains the necessary attributes to support KMS encryption key for Azure based clusters",
41514163
"properties": {

0 commit comments

Comments
 (0)