Skip to content

Commit

Permalink
Update types for api for collections
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskuchin committed Aug 28, 2023
1 parent 3cfc0a5 commit f2a86f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions internal/bowtie/client/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ type BowtieResourceLocation struct {
}

type BowtieResourcePorts struct {
Range []int64 `json:"range,omitempty"`
Collection []int64 `json:"collection,omitempty"`
Range []int64 `json:"range,omitempty"`
Collection BowtieResourcePortCollection `json:"collection,omitempty"`
}

type BowtieResourcePortCollection struct {
Ports []int64 `json:"ports,omitempty"`
}

func (c *Client) CreateResource(name, protocol string, ip, cidr, dns string, portRange, portCollection []int64) (string, BowtieResource, error) {
Expand All @@ -70,8 +74,10 @@ func (c *Client) UpsertResource(id, name, protocol, ip, cidr, dns string, portRa
DNS: dns,
},
Ports: BowtieResourcePorts{
Range: portRange,
Collection: portCollection,
Range: portRange,
Collection: BowtieResourcePortCollection{
Ports: portCollection,
},
},
}

Expand Down
2 changes: 1 addition & 1 deletion internal/bowtie/resources/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (r *resourceResource) Read(ctx context.Context, req resource.ReadRequest, r
return
}

if len(resource.Ports.Collection) > 0 {
if len(resource.Ports.Collection.Ports) > 0 {
state.Ports.Range = types.ListNull(types.Int64Type)
collection, diags := types.ListValueFrom(ctx, types.Int64Type, resource.Ports.Collection)
resp.Diagnostics.Append(diags...)
Expand Down

0 comments on commit f2a86f4

Please sign in to comment.