Skip to content

Commit

Permalink
feat (ocean/aks-np): Changed Tags and Labels fields to map type (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chandra1-n authored Feb 28, 2023
1 parent 8af2741 commit 4ffd37b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 83 deletions.
14 changes: 8 additions & 6 deletions examples/service/ocean/providers/azure_np/create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ func main() {
SpotPercentage: spotinst.Int(100),
FallbackToOD: spotinst.Bool(true),
},
Tags: &azure_np.Tag{
Key: spotinst.String("creator"),
Value: spotinst.String("test"),
Tags: &map[string]string{
"key1": "creator",
"test": "ocean",
"test3": "ocean-aks",
},

Labels: &azure_np.Label{
Key: spotinst.String("test"),
Value: spotinst.String("aks"),
Labels: &map[string]string{
"creator": "automation",
"test": "aks",
"test1": "aks1",
},

Taints: []*azure_np.Taint{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ func main() {
Name: spotinst.String("foo"),
AvailabilityZones: []string{"1",
"2"},
Labels: []*azure_np.Label{
{
Key: spotinst.String("label-key"),
Value: spotinst.String("label-value"),
},
Labels: &map[string]string{
"Key": "label-key",
"Value": "label-value",
},
Taints: []*azure_np.Taint{
{
Expand Down
8 changes: 4 additions & 4 deletions service/ocean/providers/azure_np/cluster_np.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ type VirtualNodeGroupTemplate struct {
NodePoolProperties *NodePoolProperties `json:"nodePoolProperties,omitempty"`
NodeCountLimits *NodeCountLimits `json:"nodeCountLimits,omitempty"`
Strategy *Strategy `json:"strategy,omitempty"`
Labels *Label `json:"labels,omitempty"`
Tags *Tag `json:"tags,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
Tags *map[string]string `json:"tags,omitempty"`
Taints []*Taint `json:"taints,omitempty"`

forceSendFields []string
Expand Down Expand Up @@ -618,7 +618,7 @@ func (o *VirtualNodeGroupTemplate) SetStrategy(v *Strategy) *VirtualNodeGroupTem
return o
}

func (o *VirtualNodeGroupTemplate) SetLabels(v *Label) *VirtualNodeGroupTemplate {
func (o *VirtualNodeGroupTemplate) SetLabels(v *map[string]string) *VirtualNodeGroupTemplate {
if o.Labels = v; o.Labels == nil {
o.nullFields = append(o.nullFields, "Labels")
}
Expand All @@ -632,7 +632,7 @@ func (o *VirtualNodeGroupTemplate) SetTaints(v []*Taint) *VirtualNodeGroupTempla
return o
}

func (o *VirtualNodeGroupTemplate) SetTags(v *Tag) *VirtualNodeGroupTemplate {
func (o *VirtualNodeGroupTemplate) SetTags(v *map[string]string) *VirtualNodeGroupTemplate {
if o.Tags = v; o.Tags == nil {
o.nullFields = append(o.nullFields, "Tags")
}
Expand Down
64 changes: 0 additions & 64 deletions service/ocean/providers/azure_np/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,70 +119,6 @@ func (o *Strategy) SetFallbackToOD(v *bool) *Strategy {

// endregion

// region Tag

type Tag struct {
Key *string `json:"tagKey,omitempty"`
Value *string `json:"tagValue,omitempty"`

forceSendFields []string
nullFields []string
}

func (o Tag) MarshalJSON() ([]byte, error) {
type noMethod Tag
raw := noMethod(o)
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
}

func (o *Tag) SetKey(v *string) *Tag {
if o.Key = v; o.Key == nil {
o.nullFields = append(o.nullFields, "Key")
}
return o
}

func (o *Tag) SetValue(v *string) *Tag {
if o.Value = v; o.Value == nil {
o.nullFields = append(o.nullFields, "Value")
}
return o
}

// endregion

// region Label

type Label struct {
Key *string `json:"key,omitempty"`
Value *string `json:"value,omitempty"`

forceSendFields []string
nullFields []string
}

func (o Label) MarshalJSON() ([]byte, error) {
type noMethod Label
raw := noMethod(o)
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
}

func (o *Label) SetKey(v *string) *Label {
if o.Key = v; o.Key == nil {
o.nullFields = append(o.nullFields, "Key")
}
return o
}

func (o *Label) SetValue(v *string) *Label {
if o.Value = v; o.Value == nil {
o.nullFields = append(o.nullFields, "Value")
}
return o
}

// endregion

// region Taint

type Taint struct {
Expand Down
8 changes: 4 additions & 4 deletions service/ocean/providers/azure_np/nodegroup_np.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type VirtualNodeGroup struct {
ID *string `json:"id,omitempty"`
OceanID *string `json:"oceanId,omitempty"`
Name *string `json:"name,omitempty"`
Labels []*Label `json:"labels,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
Taints []*Taint `json:"taints,omitempty"`
Tags []*Tag `json:"tags,omitempty"`
Tags *map[string]string `json:"tags,omitempty"`
Strategy *Strategy `json:"strategy,omitempty"`
AvailabilityZones []string `json:"availabilityZones,omitempty"`
NodePoolProperties *NodePoolProperties `json:"nodePoolProperties,omitempty"`
Expand Down Expand Up @@ -258,7 +258,7 @@ func (o *VirtualNodeGroup) SetName(v *string) *VirtualNodeGroup {
return o
}

func (o *VirtualNodeGroup) SetLabels(v []*Label) *VirtualNodeGroup {
func (o *VirtualNodeGroup) SetLabels(v *map[string]string) *VirtualNodeGroup {
if o.Labels = v; o.Labels == nil {
o.nullFields = append(o.nullFields, "Labels")
}
Expand Down Expand Up @@ -300,7 +300,7 @@ func (o *VirtualNodeGroup) SetNodeCountLimits(v *NodeCountLimits) *VirtualNodeGr
return o
}

func (o *VirtualNodeGroup) SetTags(v []*Tag) *VirtualNodeGroup {
func (o *VirtualNodeGroup) SetTags(v *map[string]string) *VirtualNodeGroup {
if o.Tags = v; o.Tags == nil {
o.nullFields = append(o.nullFields, "Tags")
}
Expand Down

0 comments on commit 4ffd37b

Please sign in to comment.