Skip to content

Commit

Permalink
Revert TagList in vNet/Subnet API
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-github-robot authored Sep 5, 2024
2 parents c7a879c + c4240b2 commit c65990c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 84 deletions.
24 changes: 0 additions & 24 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13453,12 +13453,6 @@ const docTemplate = `{
"status": {
"type": "string"
},
"tagList": {
"type": "array",
"items": {
"$ref": "#/definitions/model.KeyValue"
}
},
"uuid": {
"description": "uuid is universally unique identifier for the resource",
"type": "string"
Expand Down Expand Up @@ -13487,12 +13481,6 @@ const docTemplate = `{
"type": "string",
"example": "subnet00"
},
"tagList": {
"type": "array",
"items": {
"$ref": "#/definitions/model.KeyValue"
}
},
"zone": {
"type": "string"
}
Expand Down Expand Up @@ -13560,12 +13548,6 @@ const docTemplate = `{
"type": "string",
"example": "Managed by CB-Tumblebug"
},
"tagList": {
"type": "array",
"items": {
"$ref": "#/definitions/model.KeyValue"
}
},
"uuid": {
"description": "uuid is universally unique identifier for the resource",
"type": "string"
Expand Down Expand Up @@ -13600,12 +13582,6 @@ const docTemplate = `{
"items": {
"$ref": "#/definitions/model.TbSubnetReq"
}
},
"tagList": {
"type": "array",
"items": {
"$ref": "#/definitions/model.KeyValue"
}
}
}
},
Expand Down
24 changes: 0 additions & 24 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -13446,12 +13446,6 @@
"status": {
"type": "string"
},
"tagList": {
"type": "array",
"items": {
"$ref": "#/definitions/model.KeyValue"
}
},
"uuid": {
"description": "uuid is universally unique identifier for the resource",
"type": "string"
Expand Down Expand Up @@ -13480,12 +13474,6 @@
"type": "string",
"example": "subnet00"
},
"tagList": {
"type": "array",
"items": {
"$ref": "#/definitions/model.KeyValue"
}
},
"zone": {
"type": "string"
}
Expand Down Expand Up @@ -13553,12 +13541,6 @@
"type": "string",
"example": "Managed by CB-Tumblebug"
},
"tagList": {
"type": "array",
"items": {
"$ref": "#/definitions/model.KeyValue"
}
},
"uuid": {
"description": "uuid is universally unique identifier for the resource",
"type": "string"
Expand Down Expand Up @@ -13593,12 +13575,6 @@
"items": {
"$ref": "#/definitions/model.TbSubnetReq"
}
},
"tagList": {
"type": "array",
"items": {
"$ref": "#/definitions/model.KeyValue"
}
}
}
},
Expand Down
16 changes: 0 additions & 16 deletions src/api/rest/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2751,10 +2751,6 @@ definitions:
type: string
status:
type: string
tagList:
items:
$ref: '#/definitions/model.KeyValue'
type: array
uuid:
description: uuid is universally unique identifier for the resource
type: string
Expand All @@ -2772,10 +2768,6 @@ definitions:
name:
example: subnet00
type: string
tagList:
items:
$ref: '#/definitions/model.KeyValue'
type: array
zone:
type: string
required:
Expand Down Expand Up @@ -2825,10 +2817,6 @@ definitions:
string can be used) for special System purpose
example: Managed by CB-Tumblebug
type: string
tagList:
items:
$ref: '#/definitions/model.KeyValue'
type: array
uuid:
description: uuid is universally unique identifier for the resource
type: string
Expand All @@ -2851,10 +2839,6 @@ definitions:
items:
$ref: '#/definitions/model.TbSubnetReq'
type: array
tagList:
items:
$ref: '#/definitions/model.KeyValue'
type: array
required:
- connectionName
- name
Expand Down
15 changes: 8 additions & 7 deletions src/core/model/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ package model

// TbSubnetReq is a struct that represents TB subnet object.
type TbSubnetReq struct { // Tumblebug
Name string `json:"name" validate:"required" example:"subnet00"`
IPv4_CIDR string `json:"ipv4_CIDR" validate:"required" example:"10.0.1.0/24"`
Zone string `json:"zone,omitempty"`
TagList []KeyValue `json:"tagList,omitempty"`
Description string `json:"description,omitempty" example:"subnet00 managed by CB-Tumblebug"`
// KeyValueList []KeyValue `json:"keyValueList,omitempty"`
Name string `json:"name" validate:"required" example:"subnet00"`
IPv4_CIDR string `json:"ipv4_CIDR" validate:"required" example:"10.0.1.0/24"`
Zone string `json:"zone,omitempty"`
Description string `json:"description,omitempty" example:"subnet00 managed by CB-Tumblebug"`
// todo: restore the tag list later
// TagList []KeyValue `json:"tagList,omitempty"`
// IdFromCsp string `json:"idFromCsp,omitempty"`
}

Expand All @@ -46,8 +46,9 @@ type TbSubnetInfo struct { // Tumblebug
Status string `json:"status"`
IPv4_CIDR string `json:"ipv4_CIDR"`
Zone string `json:"zone,omitempty"`
TagList []KeyValue `json:"tagList,omitempty"`
BastionNodes []BastionNode `json:"bastionNodes,omitempty"`
KeyValueList []KeyValue `json:"keyValueList,omitempty"`
Description string `json:"description"`
// todo: restore the tag list later
// TagList []KeyValue `json:"tagList,omitempty"`
}
6 changes: 4 additions & 2 deletions src/core/model/vnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type TbVNetReq struct { // Tumblebug
CidrBlock string `json:"cidrBlock" example:"10.0.0.0/16"`
SubnetInfoList []TbSubnetReq `json:"subnetInfoList"`
Description string `json:"description" example:"vnet00 managed by CB-Tumblebug"`
TagList []KeyValue `json:"tagList,omitempty"`
// todo: restore the tag list later
// TagList []KeyValue `json:"tagList,omitempty"`
// CspVNetId string `json:"cspVNetId" example:""`
}

Expand Down Expand Up @@ -49,7 +50,8 @@ type TbVNetInfo struct { // Tumblebug
KeyValueList []KeyValue `json:"keyValueList,omitempty"`
AssociatedObjectList []string `json:"associatedObjectList"`
IsAutoGenerated bool `json:"isAutoGenerated"`
TagList []KeyValue `json:"tagList,omitempty"`
// todo: restore the tag list later
// TagList []KeyValue `json:"tagList,omitempty"`

// SystemLabel is for describing the Resource in a keyword (any string can be used) for special System purpose
SystemLabel string `json:"systemLabel" example:"Managed by CB-Tumblebug" default:""`
Expand Down
9 changes: 6 additions & 3 deletions src/core/resource/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ func CreateSubnet(nsId string, vNetId string, subnetReq *model.TbSubnetReq) (mod
spReqt.ReqInfo.Name = subnetInfo.Uuid
spReqt.ReqInfo.Zone = subnetReq.Zone
spReqt.ReqInfo.IPv4_CIDR = subnetReq.IPv4_CIDR
spReqt.ReqInfo.TagList = subnetReq.TagList
// todo: restore the tag list later
// spReqt.ReqInfo.TagList = subnetReq.TagList

client := resty.New()
method := "POST"
Expand Down Expand Up @@ -330,7 +331,8 @@ func CreateSubnet(nsId string, vNetId string, subnetReq *model.TbSubnetReq) (mod
subnetInfo.CspSubnetName = spSubnetInfo.IId.NameId
subnetInfo.IPv4_CIDR = spSubnetInfo.IPv4_CIDR
subnetInfo.Zone = spSubnetInfo.Zone
subnetInfo.TagList = spSubnetInfo.TagList
// todo: restore the tag list later
// subnetInfo.TagList = spSubnetInfo.TagList
subnetInfo.KeyValueList = spSubnetInfo.KeyValueList
break
}
Expand Down Expand Up @@ -824,8 +826,9 @@ func RegisterSubnet(nsId string, vNetId string, subnetReq *model.TbRegisterSubne
subnetInfo.CspSubnetName = spResp.IId.NameId
subnetInfo.IPv4_CIDR = spResp.IPv4_CIDR
subnetInfo.Zone = spResp.Zone
subnetInfo.TagList = spResp.TagList
subnetInfo.KeyValueList = spResp.KeyValueList
// todo: restore the tag list later
// subnetInfo.TagList = spResp.TagList

// Set status to 'Available'
subnetInfo.Status = string(NetworkAvailable)
Expand Down
24 changes: 16 additions & 8 deletions src/core/resource/vnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ func CreateVNet(nsId string, vNetReq *model.TbVNetReq) (model.TbVNetInfo, error)
vNetInfo.Uuid = uuid
vNetInfo.ConnectionName = vNetReq.ConnectionName
vNetInfo.Description = vNetReq.Description
vNetInfo.TagList = vNetReq.TagList
// todo: restore the tag list later
// vNetInfo.TagList = vNetReq.TagList

// Set a vNetKey for the vNet object
vNetKey := common.GenResourceKey(nsId, resourceType, vNetInfo.Id)
Expand All @@ -315,7 +316,8 @@ func CreateVNet(nsId string, vNetReq *model.TbVNetReq) (model.TbVNetInfo, error)
Uuid: common.GenUid(),
IPv4_CIDR: subnetInfo.IPv4_CIDR,
Zone: subnetInfo.Zone,
TagList: subnetInfo.TagList,
// todo: restore the tag list later
// TagList: subnetInfo.TagList,
})
}

Expand Down Expand Up @@ -349,7 +351,8 @@ func CreateVNet(nsId string, vNetReq *model.TbVNetReq) (model.TbVNetInfo, error)
Name: subnetInfo.Uuid,
IPv4_CIDR: subnetInfo.IPv4_CIDR,
Zone: subnetInfo.Zone,
TagList: subnetInfo.TagList,
// todo: restore the tag list later
// TagList: subnetInfo.TagList,
})
}

Expand Down Expand Up @@ -417,7 +420,8 @@ func CreateVNet(nsId string, vNetReq *model.TbVNetReq) (model.TbVNetInfo, error)
vNetInfo.CspVNetName = spResp.IId.NameId
vNetInfo.CidrBlock = spResp.IPv4_CIDR
vNetInfo.KeyValueList = spResp.KeyValueList
vNetInfo.TagList = spResp.TagList
// todo: restore the tag list later
// vNetInfo.TagList = spResp.TagList

// Note: Check one by one and update the vNet object with the response from the Spider
// since the order may differ different between slices
Expand All @@ -431,9 +435,10 @@ func CreateVNet(nsId string, vNetReq *model.TbVNetReq) (model.TbVNetInfo, error)
vNetInfo.SubnetInfoList[i].CspSubnetId = spSubnetInfo.IId.SystemId
vNetInfo.SubnetInfoList[i].CspSubnetName = spSubnetInfo.IId.NameId
vNetInfo.SubnetInfoList[i].KeyValueList = spSubnetInfo.KeyValueList
vNetInfo.SubnetInfoList[i].TagList = spSubnetInfo.TagList
vNetInfo.SubnetInfoList[i].Zone = spSubnetInfo.Zone
vNetInfo.SubnetInfoList[i].IPv4_CIDR = spSubnetInfo.IPv4_CIDR
// todo: restore the tag list later
// vNetInfo.SubnetInfoList[i].TagList = spSubnetInfo.TagList
}
}
}
Expand Down Expand Up @@ -585,7 +590,8 @@ func GetVNet(nsId string, vNetId string) (model.TbVNetInfo, error) {
vNetInfo.CspVNetName = spResp.IId.NameId
vNetInfo.CidrBlock = spResp.IPv4_CIDR
vNetInfo.KeyValueList = spResp.KeyValueList
vNetInfo.TagList = spResp.TagList
// todo: restore the tag list later
// vNetInfo.TagList = spResp.TagList

// Save the current operation status and the vNet object
val, err := json.Marshal(vNetInfo)
Expand Down Expand Up @@ -904,7 +910,8 @@ func RegisterVNet(nsId string, vNetRegisterReq *model.TbRegisterVNetReq) (model.
vNetInfo.CspVNetName = spResp.IId.NameId
vNetInfo.CidrBlock = spResp.IPv4_CIDR
vNetInfo.KeyValueList = spResp.KeyValueList
vNetInfo.TagList = spResp.TagList
// todo: restore the tag list later
// vNetInfo.TagList = spResp.TagList

if vNetRegisterReq.CspVNetId != "" {
vNetInfo.SystemLabel = "Registered from CSP resource"
Expand All @@ -925,9 +932,10 @@ func RegisterVNet(nsId string, vNetRegisterReq *model.TbRegisterVNetReq) (model.
CspSubnetId: spSubnetInfo.IId.SystemId,
CspSubnetName: spSubnetInfo.IId.NameId,
KeyValueList: spSubnetInfo.KeyValueList,
TagList: spSubnetInfo.TagList,
Zone: spSubnetInfo.Zone,
IPv4_CIDR: spSubnetInfo.IPv4_CIDR,
// todo: restore the tag list later
// TagList: spSubnetInfo.TagList,
}
vNetInfo.SubnetInfoList = append(vNetInfo.SubnetInfoList, subnet)

Expand Down

0 comments on commit c65990c

Please sign in to comment.