Skip to content

Commit

Permalink
Merge pull request #949 from gdbranco/feat/ocm-6715
Browse files Browse the repository at this point in the history
OCM-6715 | feat: classic machine pool aws tags
  • Loading branch information
gdbranco committed Apr 25, 2024
2 parents 3a3ac93 + 9fced33 commit 1f49224
Show file tree
Hide file tree
Showing 9 changed files with 11,121 additions and 10,923 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
This document describes the relevant changes between releases of the OCM API
SDK.

## 0.1.418
- Update model version v0.0.371
- Add Tags to the AWSMachinePool model to support custom AWS tags for day 2 creation of machine pools

## 0.1.417
- Add RolePolicyBindings to the AWS resource model to support STS Arbitrary Policies feature.

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export PATH := $(LOCAL_BIN_PATH):$(PATH)
export CGO_ENABLED=0

# Details of the model to use:
model_version:=v0.0.370
model_version:=v0.0.371
model_url:=https://github.com/openshift-online/ocm-api-model.git

# Details of the metamodel to use:
Expand Down
26 changes: 26 additions & 0 deletions clustersmgmt/v1/aws_machine_pool_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type AWSMachinePoolBuilder struct {
availabilityZoneTypes map[string]string
spotMarketOptions *AWSSpotMarketOptionsBuilder
subnetOutposts map[string]string
tags map[string]string
}

// NewAWSMachinePool creates a new builder of 'AWS_machine_pool' objects.
Expand Down Expand Up @@ -105,6 +106,17 @@ func (b *AWSMachinePoolBuilder) SubnetOutposts(value map[string]string) *AWSMach
return b
}

// Tags sets the value of the 'tags' attribute to the given value.
func (b *AWSMachinePoolBuilder) Tags(value map[string]string) *AWSMachinePoolBuilder {
b.tags = value
if value != nil {
b.bitmap_ |= 128
} else {
b.bitmap_ &^= 128
}
return b
}

// Copy copies the attributes of the given object into this builder, discarding any previous values.
func (b *AWSMachinePoolBuilder) Copy(object *AWSMachinePool) *AWSMachinePoolBuilder {
if object == nil {
Expand Down Expand Up @@ -140,6 +152,14 @@ func (b *AWSMachinePoolBuilder) Copy(object *AWSMachinePool) *AWSMachinePoolBuil
} else {
b.subnetOutposts = nil
}
if len(object.tags) > 0 {
b.tags = map[string]string{}
for k, v := range object.tags {
b.tags[k] = v
}
} else {
b.tags = nil
}
return b
}

Expand Down Expand Up @@ -171,5 +191,11 @@ func (b *AWSMachinePoolBuilder) Build() (object *AWSMachinePool, err error) {
object.subnetOutposts[k] = v
}
}
if b.tags != nil {
object.tags = make(map[string]string)
for k, v := range b.tags {
object.tags[k] = v
}
}
return
}
38 changes: 38 additions & 0 deletions clustersmgmt/v1/aws_machine_pool_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type AWSMachinePool struct {
availabilityZoneTypes map[string]string
spotMarketOptions *AWSSpotMarketOptions
subnetOutposts map[string]string
tags map[string]string
}

// Kind returns the name of the type of the object.
Expand Down Expand Up @@ -193,6 +194,43 @@ func (o *AWSMachinePool) GetSubnetOutposts() (value map[string]string, ok bool)
return
}

// Tags returns the value of the 'tags' attribute, or
// the zero value of the type if the attribute doesn't have a value.
//
// Optional keys and values that the machine pool provisioner will add as AWS tags to all AWS resources it creates.
//
// AWS tags must conform to the following standards:
// - Each resource may have a maximum of 25 tags
// - Tags beginning with "aws:" are reserved for system use and may not be set
// - Tag keys may be between 1 and 128 characters in length
// - Tag values may be between 0 and 256 characters in length
// - Tags may only contain letters, numbers, spaces, and the following characters: [_ . : / = + - @]
func (o *AWSMachinePool) Tags() map[string]string {
if o != nil && o.bitmap_&128 != 0 {
return o.tags
}
return nil
}

// GetTags returns the value of the 'tags' attribute and
// a flag indicating if the attribute has a value.
//
// Optional keys and values that the machine pool provisioner will add as AWS tags to all AWS resources it creates.
//
// AWS tags must conform to the following standards:
// - Each resource may have a maximum of 25 tags
// - Tags beginning with "aws:" are reserved for system use and may not be set
// - Tag keys may be between 1 and 128 characters in length
// - Tag values may be between 0 and 256 characters in length
// - Tags may only contain letters, numbers, spaces, and the following characters: [_ . : / = + - @]
func (o *AWSMachinePool) GetTags() (value map[string]string, ok bool) {
ok = o != nil && o.bitmap_&128 != 0
if ok {
value = o.tags
}
return
}

// AWSMachinePoolListKind is the name of the type used to represent list of objects of
// type 'AWS_machine_pool'.
const AWSMachinePoolListKind = "AWSMachinePoolList"
Expand Down
41 changes: 41 additions & 0 deletions clustersmgmt/v1/aws_machine_pool_type_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,35 @@ func writeAWSMachinePool(object *AWSMachinePool, stream *jsoniter.Stream) {
} else {
stream.WriteNil()
}
count++
}
present_ = object.bitmap_&128 != 0 && object.tags != nil
if present_ {
if count > 0 {
stream.WriteMore()
}
stream.WriteObjectField("tags")
if object.tags != nil {
stream.WriteObjectStart()
keys := make([]string, len(object.tags))
i := 0
for key := range object.tags {
keys[i] = key
i++
}
sort.Strings(keys)
for i, key := range keys {
if i > 0 {
stream.WriteMore()
}
item := object.tags[key]
stream.WriteObjectField(key)
stream.WriteString(item)
}
stream.WriteObjectEnd()
} else {
stream.WriteNil()
}
}
stream.WriteObjectEnd()
}
Expand Down Expand Up @@ -208,6 +237,18 @@ func readAWSMachinePool(iterator *jsoniter.Iterator) *AWSMachinePool {
}
object.subnetOutposts = value
object.bitmap_ |= 64
case "tags":
value := map[string]string{}
for {
key := iterator.ReadObject()
if key == "" {
break
}
item := iterator.ReadString()
value[key] = item
}
object.tags = value
object.bitmap_ |= 128
default:
iterator.ReadAny()
}
Expand Down
14 changes: 14 additions & 0 deletions clustersmgmt/v1/aws_node_pool_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ func (o *AWSNodePool) GetSubnetOutposts() (value map[string]string, ok bool) {
// the zero value of the type if the attribute doesn't have a value.
//
// Optional keys and values that the installer will add as tags to all AWS resources it creates.
//
// AWS tags must conform to the following standards:
// - Each resource may have a maximum of 25 tags
// - Tags beginning with "aws:" are reserved for system use and may not be set
// - Tag keys may be between 1 and 128 characters in length
// - Tag values may be between 0 and 256 characters in length
// - Tags may only contain letters, numbers, spaces, and the following characters: [_ . : / = + - @]
func (o *AWSNodePool) Tags() map[string]string {
if o != nil && o.bitmap_&256 != 0 {
return o.tags
Expand All @@ -233,6 +240,13 @@ func (o *AWSNodePool) Tags() map[string]string {
// a flag indicating if the attribute has a value.
//
// Optional keys and values that the installer will add as tags to all AWS resources it creates.
//
// AWS tags must conform to the following standards:
// - Each resource may have a maximum of 25 tags
// - Tags beginning with "aws:" are reserved for system use and may not be set
// - Tag keys may be between 1 and 128 characters in length
// - Tag values may be between 0 and 256 characters in length
// - Tags may only contain letters, numbers, spaces, and the following characters: [_ . : / = + - @]
func (o *AWSNodePool) GetTags() (value map[string]string, ok bool) {
ok = o != nil && o.bitmap_&256 != 0
if ok {
Expand Down
Loading

0 comments on commit 1f49224

Please sign in to comment.