Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCM-10871: Expose hcp_namespace field for Hypershift Model #992

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions clustersmgmt/v1/hypershift_config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package v1 // github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1
// Hypershift configuration.
type HypershiftConfigBuilder struct {
bitmap_ uint32
hcpNamespace string
managementCluster string
enabled bool
}
Expand All @@ -38,17 +39,24 @@ func (b *HypershiftConfigBuilder) Empty() bool {
return b == nil || b.bitmap_ == 0
}

// HCPNamespace sets the value of the 'HCP_namespace' attribute to the given value.
func (b *HypershiftConfigBuilder) HCPNamespace(value string) *HypershiftConfigBuilder {
b.hcpNamespace = value
b.bitmap_ |= 1
return b
}

// Enabled sets the value of the 'enabled' attribute to the given value.
func (b *HypershiftConfigBuilder) Enabled(value bool) *HypershiftConfigBuilder {
b.enabled = value
b.bitmap_ |= 1
b.bitmap_ |= 2
return b
}

// ManagementCluster sets the value of the 'management_cluster' attribute to the given value.
func (b *HypershiftConfigBuilder) ManagementCluster(value string) *HypershiftConfigBuilder {
b.managementCluster = value
b.bitmap_ |= 2
b.bitmap_ |= 4
return b
}

Expand All @@ -58,6 +66,7 @@ func (b *HypershiftConfigBuilder) Copy(object *HypershiftConfig) *HypershiftConf
return b
}
b.bitmap_ = object.bitmap_
b.hcpNamespace = object.hcpNamespace
b.enabled = object.enabled
b.managementCluster = object.managementCluster
return b
Expand All @@ -67,6 +76,7 @@ func (b *HypershiftConfigBuilder) Copy(object *HypershiftConfig) *HypershiftConf
func (b *HypershiftConfigBuilder) Build() (object *HypershiftConfig, err error) {
object = new(HypershiftConfig)
object.bitmap_ = b.bitmap_
object.hcpNamespace = b.hcpNamespace
object.enabled = b.enabled
object.managementCluster = b.managementCluster
return
Expand Down
34 changes: 30 additions & 4 deletions clustersmgmt/v1/hypershift_config_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package v1 // github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1
// Hypershift configuration.
type HypershiftConfig struct {
bitmap_ uint32
hcpNamespace string
managementCluster string
enabled bool
}
Expand All @@ -33,6 +34,31 @@ func (o *HypershiftConfig) Empty() bool {
return o == nil || o.bitmap_ == 0
}

// HCPNamespace returns the value of the 'HCP_namespace' attribute, or
// the zero value of the type if the attribute doesn't have a value.
//
// Contains the name of the hcp namespace for this Hypershift cluster.
// Empty for non Hypershift clusters.
func (o *HypershiftConfig) HCPNamespace() string {
if o != nil && o.bitmap_&1 != 0 {
return o.hcpNamespace
}
return ""
}

// GetHCPNamespace returns the value of the 'HCP_namespace' attribute and
// a flag indicating if the attribute has a value.
//
// Contains the name of the hcp namespace for this Hypershift cluster.
// Empty for non Hypershift clusters.
func (o *HypershiftConfig) GetHCPNamespace() (value string, ok bool) {
ok = o != nil && o.bitmap_&1 != 0
if ok {
value = o.hcpNamespace
}
return
}

// Enabled returns the value of the 'enabled' attribute, or
// the zero value of the type if the attribute doesn't have a value.
//
Expand All @@ -43,7 +69,7 @@ func (o *HypershiftConfig) Empty() bool {
// To enable it the cluster needs to be ROSA cluster and the organization of the user needs
// to have the `hypershift` capability enabled.
func (o *HypershiftConfig) Enabled() bool {
if o != nil && o.bitmap_&1 != 0 {
if o != nil && o.bitmap_&2 != 0 {
return o.enabled
}
return false
Expand All @@ -59,7 +85,7 @@ func (o *HypershiftConfig) Enabled() bool {
// To enable it the cluster needs to be ROSA cluster and the organization of the user needs
// to have the `hypershift` capability enabled.
func (o *HypershiftConfig) GetEnabled() (value bool, ok bool) {
ok = o != nil && o.bitmap_&1 != 0
ok = o != nil && o.bitmap_&2 != 0
if ok {
value = o.enabled
}
Expand All @@ -72,7 +98,7 @@ func (o *HypershiftConfig) GetEnabled() (value bool, ok bool) {
// Contains the name of the current management cluster for this Hypershift cluster.
// Empty for non Hypershift clusters.
func (o *HypershiftConfig) ManagementCluster() string {
if o != nil && o.bitmap_&2 != 0 {
if o != nil && o.bitmap_&4 != 0 {
return o.managementCluster
}
return ""
Expand All @@ -84,7 +110,7 @@ func (o *HypershiftConfig) ManagementCluster() string {
// Contains the name of the current management cluster for this Hypershift cluster.
// Empty for non Hypershift clusters.
func (o *HypershiftConfig) GetManagementCluster() (value string, ok bool) {
ok = o != nil && o.bitmap_&2 != 0
ok = o != nil && o.bitmap_&4 != 0
if ok {
value = o.managementCluster
}
Expand Down
19 changes: 16 additions & 3 deletions clustersmgmt/v1/hypershift_config_type_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ func writeHypershiftConfig(object *HypershiftConfig, stream *jsoniter.Stream) {
stream.WriteObjectStart()
var present_ bool
present_ = object.bitmap_&1 != 0
if present_ {
if count > 0 {
stream.WriteMore()
}
stream.WriteObjectField("hcp_namespace")
stream.WriteString(object.hcpNamespace)
count++
}
present_ = object.bitmap_&2 != 0
if present_ {
if count > 0 {
stream.WriteMore()
Expand All @@ -51,7 +60,7 @@ func writeHypershiftConfig(object *HypershiftConfig, stream *jsoniter.Stream) {
stream.WriteBool(object.enabled)
count++
}
present_ = object.bitmap_&2 != 0
present_ = object.bitmap_&4 != 0
if present_ {
if count > 0 {
stream.WriteMore()
Expand Down Expand Up @@ -83,14 +92,18 @@ func readHypershiftConfig(iterator *jsoniter.Iterator) *HypershiftConfig {
break
}
switch field {
case "hcp_namespace":
value := iterator.ReadString()
object.hcpNamespace = value
object.bitmap_ |= 1
case "enabled":
value := iterator.ReadBool()
object.enabled = value
object.bitmap_ |= 1
object.bitmap_ |= 2
case "management_cluster":
value := iterator.ReadString()
object.managementCluster = value
object.bitmap_ |= 2
object.bitmap_ |= 4
default:
iterator.ReadAny()
}
Expand Down
Loading