Skip to content

Commit e5f1535

Browse files
Merge pull request #1143 from nimrodshn/add_image_digest_mirrors
Add ImageDigestMirrors field to ClusterRegistryConfig
2 parents 7c35ea1 + 3ae1581 commit e5f1535

File tree

5 files changed

+105
-18
lines changed

5 files changed

+105
-18
lines changed

clientapi/arohcp/v1alpha1/cluster_registry_config_builder.go

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ type ClusterRegistryConfigBuilder struct {
4040
fieldSet_ []bool
4141
additionalTrustedCa map[string]string
4242
allowedRegistriesForImport []*RegistryLocationBuilder
43+
imageDigestMirrors []*ImageMirrorBuilder
4344
platformAllowlist *RegistryAllowlistBuilder
4445
registrySources *RegistrySourcesBuilder
4546
}
4647

4748
// NewClusterRegistryConfig creates a new builder of 'cluster_registry_config' objects.
4849
func NewClusterRegistryConfig() *ClusterRegistryConfigBuilder {
4950
return &ClusterRegistryConfigBuilder{
50-
fieldSet_: make([]bool, 4),
51+
fieldSet_: make([]bool, 5),
5152
}
5253
}
5354

@@ -67,7 +68,7 @@ func (b *ClusterRegistryConfigBuilder) Empty() bool {
6768
// AdditionalTrustedCa sets the value of the 'additional_trusted_ca' attribute to the given value.
6869
func (b *ClusterRegistryConfigBuilder) AdditionalTrustedCa(value map[string]string) *ClusterRegistryConfigBuilder {
6970
if len(b.fieldSet_) == 0 {
70-
b.fieldSet_ = make([]bool, 4)
71+
b.fieldSet_ = make([]bool, 5)
7172
}
7273
b.additionalTrustedCa = value
7374
if value != nil {
@@ -81,26 +82,37 @@ func (b *ClusterRegistryConfigBuilder) AdditionalTrustedCa(value map[string]stri
8182
// AllowedRegistriesForImport sets the value of the 'allowed_registries_for_import' attribute to the given values.
8283
func (b *ClusterRegistryConfigBuilder) AllowedRegistriesForImport(values ...*RegistryLocationBuilder) *ClusterRegistryConfigBuilder {
8384
if len(b.fieldSet_) == 0 {
84-
b.fieldSet_ = make([]bool, 4)
85+
b.fieldSet_ = make([]bool, 5)
8586
}
8687
b.allowedRegistriesForImport = make([]*RegistryLocationBuilder, len(values))
8788
copy(b.allowedRegistriesForImport, values)
8889
b.fieldSet_[1] = true
8990
return b
9091
}
9192

93+
// ImageDigestMirrors sets the value of the 'image_digest_mirrors' attribute to the given values.
94+
func (b *ClusterRegistryConfigBuilder) ImageDigestMirrors(values ...*ImageMirrorBuilder) *ClusterRegistryConfigBuilder {
95+
if len(b.fieldSet_) == 0 {
96+
b.fieldSet_ = make([]bool, 5)
97+
}
98+
b.imageDigestMirrors = make([]*ImageMirrorBuilder, len(values))
99+
copy(b.imageDigestMirrors, values)
100+
b.fieldSet_[2] = true
101+
return b
102+
}
103+
92104
// PlatformAllowlist sets the value of the 'platform_allowlist' attribute to the given value.
93105
//
94106
// RegistryAllowlist represents a single registry allowlist.
95107
func (b *ClusterRegistryConfigBuilder) PlatformAllowlist(value *RegistryAllowlistBuilder) *ClusterRegistryConfigBuilder {
96108
if len(b.fieldSet_) == 0 {
97-
b.fieldSet_ = make([]bool, 4)
109+
b.fieldSet_ = make([]bool, 5)
98110
}
99111
b.platformAllowlist = value
100112
if value != nil {
101-
b.fieldSet_[2] = true
113+
b.fieldSet_[3] = true
102114
} else {
103-
b.fieldSet_[2] = false
115+
b.fieldSet_[3] = false
104116
}
105117
return b
106118
}
@@ -112,13 +124,13 @@ func (b *ClusterRegistryConfigBuilder) PlatformAllowlist(value *RegistryAllowlis
112124
// It does not contain configuration for the internal cluster registry.
113125
func (b *ClusterRegistryConfigBuilder) RegistrySources(value *RegistrySourcesBuilder) *ClusterRegistryConfigBuilder {
114126
if len(b.fieldSet_) == 0 {
115-
b.fieldSet_ = make([]bool, 4)
127+
b.fieldSet_ = make([]bool, 5)
116128
}
117129
b.registrySources = value
118130
if value != nil {
119-
b.fieldSet_[3] = true
131+
b.fieldSet_[4] = true
120132
} else {
121-
b.fieldSet_[3] = false
133+
b.fieldSet_[4] = false
122134
}
123135
return b
124136
}
@@ -148,6 +160,14 @@ func (b *ClusterRegistryConfigBuilder) Copy(object *ClusterRegistryConfig) *Clus
148160
} else {
149161
b.allowedRegistriesForImport = nil
150162
}
163+
if object.imageDigestMirrors != nil {
164+
b.imageDigestMirrors = make([]*ImageMirrorBuilder, len(object.imageDigestMirrors))
165+
for i, v := range object.imageDigestMirrors {
166+
b.imageDigestMirrors[i] = NewImageMirror().Copy(v)
167+
}
168+
} else {
169+
b.imageDigestMirrors = nil
170+
}
151171
if object.platformAllowlist != nil {
152172
b.platformAllowlist = NewRegistryAllowlist().Copy(object.platformAllowlist)
153173
} else {
@@ -183,6 +203,15 @@ func (b *ClusterRegistryConfigBuilder) Build() (object *ClusterRegistryConfig, e
183203
}
184204
}
185205
}
206+
if b.imageDigestMirrors != nil {
207+
object.imageDigestMirrors = make([]*ImageMirror, len(b.imageDigestMirrors))
208+
for i, v := range b.imageDigestMirrors {
209+
object.imageDigestMirrors[i], err = v.Build()
210+
if err != nil {
211+
return
212+
}
213+
}
214+
}
186215
if b.platformAllowlist != nil {
187216
object.platformAllowlist, err = b.platformAllowlist.Build()
188217
if err != nil {

clientapi/arohcp/v1alpha1/cluster_registry_config_type.go

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type ClusterRegistryConfig struct {
4242
fieldSet_ []bool
4343
additionalTrustedCa map[string]string
4444
allowedRegistriesForImport []*RegistryLocation
45+
imageDigestMirrors []*ImageMirror
4546
platformAllowlist *RegistryAllowlist
4647
registrySources *RegistrySources
4748
}
@@ -117,14 +118,45 @@ func (o *ClusterRegistryConfig) GetAllowedRegistriesForImport() (value []*Regist
117118
return
118119
}
119120

121+
// ImageDigestMirrors returns the value of the 'image_digest_mirrors' attribute, or
122+
// the zero value of the type if the attribute doesn't have a value.
123+
//
124+
// ImageDigestMirrors contains the configuration for the image mirroring based on digest.
125+
// This field is optional and mutable. The default value is nil. The maximum number of image mirror entries is 252.
126+
// This fields contents is used to create the ImageDigestMirrorSet on the cluster nodes by Hypershift.
127+
// Each image mirror specified here is propogated to the entries in the ImageDigestMirrorSet by Hypershift.
128+
// See for more information: https://docs.redhat.com/en/documentation/openshift_container_platform/4.21/html/config_apis/imagedigestmirrorset-config-openshift-io-v1#imagedigestmirrorset-config-openshift-io-v1.
129+
func (o *ClusterRegistryConfig) ImageDigestMirrors() []*ImageMirror {
130+
if o != nil && len(o.fieldSet_) > 2 && o.fieldSet_[2] {
131+
return o.imageDigestMirrors
132+
}
133+
return nil
134+
}
135+
136+
// GetImageDigestMirrors returns the value of the 'image_digest_mirrors' attribute and
137+
// a flag indicating if the attribute has a value.
138+
//
139+
// ImageDigestMirrors contains the configuration for the image mirroring based on digest.
140+
// This field is optional and mutable. The default value is nil. The maximum number of image mirror entries is 252.
141+
// This fields contents is used to create the ImageDigestMirrorSet on the cluster nodes by Hypershift.
142+
// Each image mirror specified here is propogated to the entries in the ImageDigestMirrorSet by Hypershift.
143+
// See for more information: https://docs.redhat.com/en/documentation/openshift_container_platform/4.21/html/config_apis/imagedigestmirrorset-config-openshift-io-v1#imagedigestmirrorset-config-openshift-io-v1.
144+
func (o *ClusterRegistryConfig) GetImageDigestMirrors() (value []*ImageMirror, ok bool) {
145+
ok = o != nil && len(o.fieldSet_) > 2 && o.fieldSet_[2]
146+
if ok {
147+
value = o.imageDigestMirrors
148+
}
149+
return
150+
}
151+
120152
// PlatformAllowlist returns the value of the 'platform_allowlist' attribute, or
121153
// the zero value of the type if the attribute doesn't have a value.
122154
//
123155
// PlatformAllowlist contains a reference to a RegistryAllowlist which is a list of internal registries
124156
// which needs to be whitelisted for the platform to work. It can be omitted at creation and
125157
// updating and its lifecycle can be managed separately if needed.
126158
func (o *ClusterRegistryConfig) PlatformAllowlist() *RegistryAllowlist {
127-
if o != nil && len(o.fieldSet_) > 2 && o.fieldSet_[2] {
159+
if o != nil && len(o.fieldSet_) > 3 && o.fieldSet_[3] {
128160
return o.platformAllowlist
129161
}
130162
return nil
@@ -137,7 +169,7 @@ func (o *ClusterRegistryConfig) PlatformAllowlist() *RegistryAllowlist {
137169
// which needs to be whitelisted for the platform to work. It can be omitted at creation and
138170
// updating and its lifecycle can be managed separately if needed.
139171
func (o *ClusterRegistryConfig) GetPlatformAllowlist() (value *RegistryAllowlist, ok bool) {
140-
ok = o != nil && len(o.fieldSet_) > 2 && o.fieldSet_[2]
172+
ok = o != nil && len(o.fieldSet_) > 3 && o.fieldSet_[3]
141173
if ok {
142174
value = o.platformAllowlist
143175
}
@@ -152,7 +184,7 @@ func (o *ClusterRegistryConfig) GetPlatformAllowlist() (value *RegistryAllowlist
152184
// whether or not to allow insecure access). It does not contain configuration for the
153185
// internal cluster registry.
154186
func (o *ClusterRegistryConfig) RegistrySources() *RegistrySources {
155-
if o != nil && len(o.fieldSet_) > 3 && o.fieldSet_[3] {
187+
if o != nil && len(o.fieldSet_) > 4 && o.fieldSet_[4] {
156188
return o.registrySources
157189
}
158190
return nil
@@ -166,7 +198,7 @@ func (o *ClusterRegistryConfig) RegistrySources() *RegistrySources {
166198
// whether or not to allow insecure access). It does not contain configuration for the
167199
// internal cluster registry.
168200
func (o *ClusterRegistryConfig) GetRegistrySources() (value *RegistrySources, ok bool) {
169-
ok = o != nil && len(o.fieldSet_) > 3 && o.fieldSet_[3]
201+
ok = o != nil && len(o.fieldSet_) > 4 && o.fieldSet_[4]
170202
if ok {
171203
value = o.registrySources
172204
}

clientapi/arohcp/v1alpha1/cluster_registry_config_type_json.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,16 @@ func WriteClusterRegistryConfig(object *ClusterRegistryConfig, stream *jsoniter.
8181
WriteRegistryLocationList(object.allowedRegistriesForImport, stream)
8282
count++
8383
}
84-
present_ = len(object.fieldSet_) > 2 && object.fieldSet_[2] && object.platformAllowlist != nil
84+
present_ = len(object.fieldSet_) > 2 && object.fieldSet_[2] && object.imageDigestMirrors != nil
85+
if present_ {
86+
if count > 0 {
87+
stream.WriteMore()
88+
}
89+
stream.WriteObjectField("image_digest_mirrors")
90+
WriteImageMirrorList(object.imageDigestMirrors, stream)
91+
count++
92+
}
93+
present_ = len(object.fieldSet_) > 3 && object.fieldSet_[3] && object.platformAllowlist != nil
8594
if present_ {
8695
if count > 0 {
8796
stream.WriteMore()
@@ -90,7 +99,7 @@ func WriteClusterRegistryConfig(object *ClusterRegistryConfig, stream *jsoniter.
9099
WriteRegistryAllowlist(object.platformAllowlist, stream)
91100
count++
92101
}
93-
present_ = len(object.fieldSet_) > 3 && object.fieldSet_[3] && object.registrySources != nil
102+
present_ = len(object.fieldSet_) > 4 && object.fieldSet_[4] && object.registrySources != nil
94103
if present_ {
95104
if count > 0 {
96105
stream.WriteMore()
@@ -116,7 +125,7 @@ func UnmarshalClusterRegistryConfig(source interface{}) (object *ClusterRegistry
116125
// ReadClusterRegistryConfig reads a value of the 'cluster_registry_config' type from the given iterator.
117126
func ReadClusterRegistryConfig(iterator *jsoniter.Iterator) *ClusterRegistryConfig {
118127
object := &ClusterRegistryConfig{
119-
fieldSet_: make([]bool, 4),
128+
fieldSet_: make([]bool, 5),
120129
}
121130
for {
122131
field := iterator.ReadObject()
@@ -140,14 +149,18 @@ func ReadClusterRegistryConfig(iterator *jsoniter.Iterator) *ClusterRegistryConf
140149
value := ReadRegistryLocationList(iterator)
141150
object.allowedRegistriesForImport = value
142151
object.fieldSet_[1] = true
152+
case "image_digest_mirrors":
153+
value := ReadImageMirrorList(iterator)
154+
object.imageDigestMirrors = value
155+
object.fieldSet_[2] = true
143156
case "platform_allowlist":
144157
value := ReadRegistryAllowlist(iterator)
145158
object.platformAllowlist = value
146-
object.fieldSet_[2] = true
159+
object.fieldSet_[3] = true
147160
case "registry_sources":
148161
value := ReadRegistrySources(iterator)
149162
object.registrySources = value
150-
object.fieldSet_[3] = true
163+
object.fieldSet_[4] = true
151164
default:
152165
iterator.ReadAny()
153166
}

model/aro_hcp/v1alpha1/cluster_registry_config_type.model

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ struct ClusterRegistryConfig {
5050
// whether or not to allow insecure access). It does not contain configuration for the
5151
// internal cluster registry.
5252
RegistrySources RegistrySources
53+
// ImageDigestMirrors contains the configuration for the image mirroring based on digest.
54+
// This field is optional and mutable. The default value is nil. The maximum number of image mirror entries is 252.
55+
// This fields contents is used to create the ImageDigestMirrorSet on the cluster nodes by Hypershift.
56+
// Each image mirror specified here is propogated to the entries in the ImageDigestMirrorSet by Hypershift.
57+
// See for more information: https://docs.redhat.com/en/documentation/openshift_container_platform/4.21/html/config_apis/imagedigestmirrorset-config-openshift-io-v1#imagedigestmirrorset-config-openshift-io-v1.
58+
ImageDigestMirrors []ImageMirror
5359
}
5460

5561
// RegistrySources contains configuration that determines how the container runtime should treat individual

openapi/aro_hcp/v1alpha1/openapi.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5314,6 +5314,13 @@
53145314
"$ref": "#/components/schemas/RegistryLocation"
53155315
}
53165316
},
5317+
"image_digest_mirrors": {
5318+
"description": "ImageDigestMirrors contains the configuration for the image mirroring based on digest.\nThis field is optional and mutable. The default value is nil. The maximum number of image mirror entries is 252.\nThis fields contents is used to create the ImageDigestMirrorSet on the cluster nodes by Hypershift.\nEach image mirror specified here is propogated to the entries in the ImageDigestMirrorSet by Hypershift.\nSee for more information: https://docs.redhat.com/en/documentation/openshift_container_platform/4.21/html/config_apis/imagedigestmirrorset-config-openshift-io-v1#imagedigestmirrorset-config-openshift-io-v1.",
5319+
"type": "array",
5320+
"items": {
5321+
"$ref": "#/components/schemas/ImageMirror"
5322+
}
5323+
},
53175324
"platform_allowlist": {
53185325
"description": "PlatformAllowlist contains a reference to a RegistryAllowlist which is a list of internal registries\nwhich needs to be whitelisted for the platform to work. It can be omitted at creation and \nupdating and its lifecycle can be managed separately if needed.",
53195326
"$ref": "#/components/schemas/RegistryAllowlist"

0 commit comments

Comments
 (0)