Skip to content

Commit f131c20

Browse files
author
Joonas Bergius
committed
chore(x/wasmbus): Address linter feedback
Signed-off-by: Joonas Bergius <[email protected]>
1 parent f9cd2db commit f131c20

File tree

8 files changed

+81
-84
lines changed

8 files changed

+81
-84
lines changed

x/wasmbus/control/api.go

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ type ProviderAuctionRequest struct {
5151
// Constraints are key-value pairs that are used to filter hosts.
5252
// Required even if empty (unfortunately).
5353
Constraints map[string]string `json:"constraints"`
54-
ProviderId string `json:"provider_id,omitempty"`
54+
ProviderID string `json:"provider_id,omitempty"`
5555
ProviderRef string `json:"provider_ref,omitempty"`
5656
}
5757

5858
type ProviderAuctionResponsePayload struct {
59-
HostId string `json:"host_id"`
59+
HostID string `json:"host_id"`
6060
Constraints map[string]string `json:"constraints,omitempty"`
61-
ProviderId string `json:"provider_id,omitempty"`
61+
ProviderID string `json:"provider_id,omitempty"`
6262
ProviderRef string `json:"provider_ref,omitempty"`
6363
}
6464

@@ -68,50 +68,48 @@ type ComponentAuctionRequest struct {
6868
// Constraints are key-value pairs that are used to filter hosts.
6969
// Required even if empty (unfortunately).
7070
Constraints map[string]string `json:"constraints"`
71-
ComponentId string `json:"component_id,omitempty"`
71+
ComponentID string `json:"component_id,omitempty"`
7272
ComponentRef string `json:"component_ref,omitempty"`
7373
}
7474

7575
type ComponentAuctionResponsePayload struct {
76-
HostId string `json:"host_id"`
76+
HostID string `json:"host_id"`
7777
Constraints map[string]string `json:"constraints,omitempty"`
78-
ComponentId string `json:"component_id,omitempty"`
78+
ComponentID string `json:"component_id,omitempty"`
7979
ComponentRef string `json:"component_ref,omitempty"`
8080
}
8181

8282
type ComponentAuctionResponse = Response[ComponentAuctionResponsePayload]
8383

8484
type ScaleComponentRequest struct {
85-
ComponentId string `json:"component_id"`
85+
ComponentID string `json:"component_id"`
8686
ComponentRef string `json:"component_ref"`
8787
Annotations map[string]string `json:"annotations,omitempty"`
8888
Count int `json:"count"`
89-
HostId string `json:"host_id"`
89+
HostID string `json:"host_id"`
9090
Config []string `json:"config,omitempty"`
9191
AllowUpdate bool `json:"allow_update,omitempty"`
9292
}
9393

94-
type ScaleComponentResponsePayload struct {
95-
}
94+
type ScaleComponentResponsePayload struct{}
9695

9796
type ScaleComponentResponse = Response[ScaleComponentResponsePayload]
9897

9998
type UpdateComponentRequest struct {
100-
HostId string `json:"-"`
99+
HostID string `json:"-"`
101100

102-
ComponentId string `json:"component_id"`
101+
ComponentID string `json:"component_id"`
103102
NewComponentRef string `json:"new_component_ref"`
104103
Annotations map[string]string `json:"annotations,omitempty"`
105104
}
106105

107-
type UpdateComponentResponsePayload struct {
108-
}
106+
type UpdateComponentResponsePayload struct{}
109107

110108
type UpdateComponentResponse = Response[UpdateComponentResponsePayload]
111109

112110
type ProviderStartRequest struct {
113-
HostId string `json:"host_id"`
114-
ProviderId string `json:"provider_id"`
111+
HostID string `json:"host_id"`
112+
ProviderID string `json:"provider_id"`
115113
ProviderRef string `json:"provider_ref"`
116114
Annotations map[string]string `json:"annotations,omitempty"`
117115
Config []string `json:"config,omitempty"`
@@ -122,16 +120,16 @@ type ProviderStartResponsePayload struct{}
122120
type ProviderStartResponse = Response[ProviderStartResponsePayload]
123121

124122
type ProviderStopRequest struct {
125-
HostId string `json:"host_id"`
126-
ProviderId string `json:"provider_id"`
123+
HostID string `json:"host_id"`
124+
ProviderID string `json:"provider_id"`
127125
}
128126

129127
type ProviderStopResponsePayload struct{}
130128

131129
type ProviderStopResponse = Response[ProviderStopResponsePayload]
132130

133131
type HostStopRequest struct {
134-
HostId string `json:"host_id"`
132+
HostID string `json:"host_id"`
135133
Timeout int `json:"timeout,omitempty"`
136134
}
137135

@@ -177,7 +175,7 @@ type ConfigDeleteResponsePayload struct{}
177175
type ConfigDeleteResponse = Response[ConfigDeleteResponsePayload]
178176

179177
type HostLabelPutRequest struct {
180-
HostId string `json:"-"`
178+
HostID string `json:"-"`
181179
Key string `json:"key"`
182180
Value string `json:"value"`
183181
}
@@ -187,7 +185,7 @@ type HostLabelPutResponsePayload struct{}
187185
type HostLabelPutResponse = Response[HostLabelPutResponsePayload]
188186

189187
type HostLabelDeleteRequest struct {
190-
HostId string `json:"-"`
188+
HostID string `json:"-"`
191189
Key string `json:"key"`
192190
// NOTE(lxf): This is expected to be sent even if blak. Seems like an API bug.
193191
Value string `json:"value"`
@@ -198,11 +196,10 @@ type HostLabelDeleteResponsePayload struct{}
198196
type HostLabelDeleteResponse = Response[HostLabelDeleteResponsePayload]
199197

200198
// NOTE(lxf): Despite being a 'Get', this acts as a 'List' operation
201-
type LinkGetRequest struct {
202-
}
199+
type LinkGetRequest struct{}
203200

204201
type LinkGetResponsePayload struct {
205-
SourceId string `json:"source_id"`
202+
SourceID string `json:"source_id"`
206203
Target string `json:"target"`
207204
Name string `json:"name"`
208205
WitNamespace string `json:"wit_namespace"`
@@ -215,7 +212,7 @@ type LinkGetResponsePayload struct {
215212
type LinkGetResponse = Response[[]LinkGetResponsePayload]
216213

217214
type LinkPutRequest struct {
218-
SourceId string `json:"source_id"`
215+
SourceID string `json:"source_id"`
219216
Target string `json:"target"`
220217
Name string `json:"name"`
221218
WitNamespace string `json:"wit_namespace"`
@@ -230,7 +227,7 @@ type LinkPutResponsePayload struct{}
230227
type LinkPutResponse = Response[LinkPutResponsePayload]
231228

232229
type LinkDeleteRequest struct {
233-
SourceId string `json:"source_id"`
230+
SourceID string `json:"source_id"`
234231
Name string `json:"name"`
235232
WitNamespace string `json:"wit_namespace"`
236233
WitPackage string `json:"wit_package"`
@@ -247,11 +244,11 @@ type ClaimsGetResponsePayload map[string]string
247244
type ClaimsGetResponse = Response[ClaimsGetResponsePayload]
248245

249246
type HostInventoryRequest struct {
250-
HostId string `json:"-"`
247+
HostID string `json:"-"`
251248
}
252249

253250
type ComponentDescription struct {
254-
Id string `json:"id"`
251+
ID string `json:"id"`
255252
ImageRef string `json:"image_ref"`
256253
Name string `json:"name"`
257254
Annotations map[string]string `json:"annotations"`
@@ -260,7 +257,7 @@ type ComponentDescription struct {
260257
}
261258

262259
type ProviderDescription struct {
263-
Id string `json:"id"`
260+
ID string `json:"id"`
264261
ImageRef string `json:"image_ref"`
265262
Name string `json:"name"`
266263
Annotations map[string]string `json:"annotations"`
@@ -270,7 +267,7 @@ type ProviderDescription struct {
270267
type HostInventoryResponsePayload struct {
271268
Components []ComponentDescription `json:"components"`
272269
Providers []ProviderDescription `json:"providers"`
273-
HostId string `json:"host_id"`
270+
HostID string `json:"host_id"`
274271
FriendlyName string `json:"friendly_name"`
275272
Labels map[string]string `json:"labels"`
276273
Version string `json:"version"`
@@ -288,12 +285,12 @@ type HostPingRequest struct {
288285
}
289286

290287
type HostPingResponsePayload struct {
291-
Id string `json:"id"`
288+
ID string `json:"id"`
292289
Labels map[string]string `json:"labels"`
293290
FriendlyName string `json:"friendly_name"`
294291
Version string `json:"version"`
295292
Lattice string `json:"lattice"`
296-
RpcHost string `json:"rpc_host"`
293+
RPCHost string `json:"rpc_host"`
297294
CtlHost string `json:"ctl_host"`
298295
UptimeSeconds int `json:"uptime_seconds"`
299296
UptimeHuman string `json:"uptime_human"`

x/wasmbus/control/client.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (c *Client) subject(ids ...string) string {
2929
}
3030

3131
func (c *Client) ScaleComponent(ctx context.Context, req *ScaleComponentRequest) (*ScaleComponentResponse, error) {
32-
subject := c.subject("component", "scale", req.HostId)
32+
subject := c.subject("component", "scale", req.HostID)
3333
wReq := wasmbus.NewLatticeRequest(c.Bus, subject, req, ScaleComponentResponse{})
3434
return wReq.Execute(ctx)
3535
}
@@ -53,25 +53,25 @@ func (c *Client) ComponentAuction(ctx context.Context, req *ComponentAuctionRequ
5353
}
5454

5555
func (c *Client) UpdateComponent(ctx context.Context, req *UpdateComponentRequest) (*UpdateComponentResponse, error) {
56-
subject := c.subject("component", "update", req.HostId)
56+
subject := c.subject("component", "update", req.HostID)
5757
wReq := wasmbus.NewLatticeRequest(c.Bus, subject, req, UpdateComponentResponse{})
5858
return wReq.Execute(ctx)
5959
}
6060

6161
func (c *Client) ProviderStart(ctx context.Context, req *ProviderStartRequest) (*ProviderStartResponse, error) {
62-
subject := c.subject("provider", "start", req.HostId)
62+
subject := c.subject("provider", "start", req.HostID)
6363
wReq := wasmbus.NewLatticeRequest(c.Bus, subject, req, ProviderStartResponse{})
6464
return wReq.Execute(ctx)
6565
}
6666

6767
func (c *Client) ProviderStop(ctx context.Context, req *ProviderStopRequest) (*ProviderStopResponse, error) {
68-
subject := c.subject("provider", "stop", req.HostId)
68+
subject := c.subject("provider", "stop", req.HostID)
6969
wReq := wasmbus.NewLatticeRequest(c.Bus, subject, req, ProviderStopResponse{})
7070
return wReq.Execute(ctx)
7171
}
7272

7373
func (c *Client) HostStop(ctx context.Context, req *HostStopRequest) (*HostStopResponse, error) {
74-
subject := c.subject("host", "stop", req.HostId)
74+
subject := c.subject("host", "stop", req.HostID)
7575
wReq := wasmbus.NewLatticeRequest(c.Bus, subject, req, HostStopResponse{})
7676
return wReq.Execute(ctx)
7777
}
@@ -89,13 +89,13 @@ func (c *Client) ConfigDelete(ctx context.Context, req *ConfigDeleteRequest) (*C
8989
}
9090

9191
func (c *Client) HostLabelPut(ctx context.Context, req *HostLabelPutRequest) (*HostLabelPutResponse, error) {
92-
subject := c.subject("label", "put", req.HostId)
92+
subject := c.subject("label", "put", req.HostID)
9393
wReq := wasmbus.NewLatticeRequest(c.Bus, subject, req, HostLabelPutResponse{})
9494
return wReq.Execute(ctx)
9595
}
9696

9797
func (c *Client) HostLabelDelete(ctx context.Context, req *HostLabelDeleteRequest) (*HostLabelDeleteResponse, error) {
98-
subject := c.subject("label", "del", req.HostId)
98+
subject := c.subject("label", "del", req.HostID)
9999
wReq := wasmbus.NewLatticeRequest(c.Bus, subject, req, HostLabelDeleteResponse{})
100100
return wReq.Execute(ctx)
101101
}
@@ -125,13 +125,13 @@ func (c *Client) ClaimsGet(ctx context.Context, req *ClaimsGetRequest) (*ClaimsG
125125
}
126126

127127
func (c *Client) HostInventory(ctx context.Context, req *HostInventoryRequest) (*HostInventoryResponse, error) {
128-
subject := c.subject("host", "get", req.HostId)
128+
subject := c.subject("host", "get", req.HostID)
129129
wReq := wasmbus.NewLatticeRequest(c.Bus, subject, req, HostInventoryResponse{})
130130
return wReq.Execute(ctx)
131131
}
132132

133133
// NOTE(lxf): Why scatter/gather pattern? Why not just send a message to each host?
134-
func (c *Client) HostPing(ctx context.Context, req *HostPingRequest) (*HostPingResponse, error) {
134+
func (c *Client) HostPing(_ context.Context, req *HostPingRequest) (*HostPingResponse, error) {
135135
reply := wasmbus.NewInbox()
136136
sub, err := c.Subscribe(reply, 10)
137137
if err != nil {

x/wasmbus/control/client_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func wrapTest(f func(*testing.T, *Client), c *Client) func(*testing.T) {
2828

2929
func testProvider(t *testing.T, c *Client) {
3030
req := &ProviderAuctionRequest{
31-
ProviderId: "test-provider",
31+
ProviderID: "test-provider",
3232
ProviderRef: wasmbustest.ValidProvider,
3333
Constraints: make(map[string]string),
3434
}
@@ -42,13 +42,13 @@ func testProvider(t *testing.T, c *Client) {
4242
t.Fatalf("auction failed: %v", resp)
4343
}
4444

45-
if resp.Response.HostId == "" {
45+
if resp.Response.HostID == "" {
4646
t.Fatalf("host id is empty")
4747
}
4848

4949
reqStart := &ProviderStartRequest{
50-
HostId: resp.Response.HostId,
51-
ProviderId: req.ProviderId,
50+
HostID: resp.Response.HostID,
51+
ProviderID: req.ProviderID,
5252
ProviderRef: req.ProviderRef,
5353
}
5454

@@ -66,7 +66,7 @@ func testComponent(t *testing.T, c *Client) {
6666
// we first need an auction to find the host id
6767

6868
auctionReq := &ComponentAuctionRequest{
69-
ComponentId: "test-component",
69+
ComponentID: "test-component",
7070
ComponentRef: wasmbustest.ValidComponent,
7171
Constraints: make(map[string]string),
7272
}
@@ -77,8 +77,8 @@ func testComponent(t *testing.T, c *Client) {
7777
}
7878

7979
scaleReq := &ScaleComponentRequest{
80-
HostId: auctionResp.Response.HostId,
81-
ComponentId: auctionReq.ComponentId,
80+
HostID: auctionResp.Response.HostID,
81+
ComponentID: auctionReq.ComponentID,
8282
ComponentRef: auctionReq.ComponentRef,
8383
Count: 1,
8484
}
@@ -102,8 +102,8 @@ func testComponent(t *testing.T, c *Client) {
102102
t.Logf("attempt %d/%d: trying to update component", i, attempts)
103103

104104
updateReq := &UpdateComponentRequest{
105-
HostId: auctionResp.Response.HostId,
106-
ComponentId: auctionReq.ComponentId,
105+
HostID: auctionResp.Response.HostID,
106+
ComponentID: auctionReq.ComponentID,
107107
NewComponentRef: auctionReq.ComponentRef,
108108
Annotations: map[string]string{"test": "test"},
109109
}

0 commit comments

Comments
 (0)