Skip to content

Commit 05f99f6

Browse files
authored
Merge pull request #3737 from alexandear/chore/enable-protolint
Fix proto style issues; enable protolint
2 parents b76b7ff + e47c240 commit 05f99f6

File tree

10 files changed

+113
-94
lines changed

10 files changed

+113
-94
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ jobs:
6666
run: go install github.com/containerd/[email protected]
6767
- name: Check license boilerplates
6868
run: ltag -t ./hack/ltag --check -v
69+
- name: Install protolint
70+
run: go install github.com/yoheimuta/protolint/cmd/[email protected]
71+
- name: Check protobuf files
72+
run: protolint .
6973

7074
lint-go:
7175
name: "Lint Go"

.protolint.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This is the configuration for protolint.
2+
# See https://github.com/yoheimuta/protolint/blob/v0.55.6/_example/config/.protolint.yaml for details.
3+
---
4+
lint:
5+
rules:
6+
# Enable all default rules.
7+
no_default: false
8+
rules_option:
9+
# MAX_LINE_LENGTH rule option.
10+
max_line_length:
11+
max_chars: 100

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ lint: check-generated
514514
find . -name '*.sh' ! -path "./.git/*" | xargs shfmt -s -d
515515
go-licenses check --include_tests ./... --allowed_licenses=$$(cat ./hack/allowed-licenses.txt)
516516
ltag -t ./hack/ltag --check -v
517+
protolint .
517518

518519
.PHONY: clean
519520
clean:

pkg/driver/external/driver.proto

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
11
syntax = "proto3";
22

3-
option go_package = "github.com/lima-vm/lima/v2/pkg/driver/external";
4-
53
import "google/protobuf/empty.proto";
64

5+
option go_package = "github.com/lima-vm/lima/v2/pkg/driver/external";
6+
77
service Driver {
8-
rpc Validate(google.protobuf.Empty) returns (google.protobuf.Empty);
9-
rpc Initialize(google.protobuf.Empty) returns (google.protobuf.Empty);
10-
rpc CreateDisk(google.protobuf.Empty) returns (google.protobuf.Empty);
11-
rpc Start(google.protobuf.Empty) returns (stream StartResponse);
12-
rpc Stop(google.protobuf.Empty) returns (google.protobuf.Empty);
8+
rpc Validate(google.protobuf.Empty) returns (google.protobuf.Empty);
9+
rpc Initialize(google.protobuf.Empty) returns (google.protobuf.Empty);
10+
rpc CreateDisk(google.protobuf.Empty) returns (google.protobuf.Empty);
11+
rpc Start(google.protobuf.Empty) returns (stream StartResponse);
12+
rpc Stop(google.protobuf.Empty) returns (google.protobuf.Empty);
1313

14-
rpc RunGUI(google.protobuf.Empty) returns (google.protobuf.Empty);
15-
rpc ChangeDisplayPassword(ChangeDisplayPasswordRequest) returns (google.protobuf.Empty);
16-
rpc GetDisplayConnection(google.protobuf.Empty) returns (GetDisplayConnectionResponse);
14+
rpc RunGUI(google.protobuf.Empty) returns (google.protobuf.Empty);
15+
rpc ChangeDisplayPassword(ChangeDisplayPasswordRequest) returns (google.protobuf.Empty);
16+
rpc GetDisplayConnection(google.protobuf.Empty) returns (GetDisplayConnectionResponse);
1717

18-
rpc CreateSnapshot(CreateSnapshotRequest) returns (google.protobuf.Empty);
19-
rpc ApplySnapshot(ApplySnapshotRequest) returns (google.protobuf.Empty);
20-
rpc DeleteSnapshot(DeleteSnapshotRequest) returns (google.protobuf.Empty);
21-
rpc ListSnapshots(google.protobuf.Empty) returns (ListSnapshotsResponse);
18+
rpc CreateSnapshot(CreateSnapshotRequest) returns (google.protobuf.Empty);
19+
rpc ApplySnapshot(ApplySnapshotRequest) returns (google.protobuf.Empty);
20+
rpc DeleteSnapshot(DeleteSnapshotRequest) returns (google.protobuf.Empty);
21+
rpc ListSnapshots(google.protobuf.Empty) returns (ListSnapshotsResponse);
2222

23-
rpc Register(google.protobuf.Empty) returns (google.protobuf.Empty);
24-
rpc Unregister(google.protobuf.Empty) returns (google.protobuf.Empty);
23+
rpc Register(google.protobuf.Empty) returns (google.protobuf.Empty);
24+
rpc Unregister(google.protobuf.Empty) returns (google.protobuf.Empty);
2525

26-
rpc ForwardGuestAgent(google.protobuf.Empty) returns (ForwardGuestAgentResponse);
27-
rpc GuestAgentConn(google.protobuf.Empty) returns (google.protobuf.Empty);
26+
rpc ForwardGuestAgent(google.protobuf.Empty) returns (ForwardGuestAgentResponse);
27+
rpc GuestAgentConn(google.protobuf.Empty) returns (google.protobuf.Empty);
2828

29-
rpc SetConfig(SetConfigRequest) returns (google.protobuf.Empty);
29+
rpc SetConfig(SetConfigRequest) returns (google.protobuf.Empty);
3030

31-
rpc GetInfo(google.protobuf.Empty) returns (InfoResponse);
31+
rpc GetInfo(google.protobuf.Empty) returns (InfoResponse);
3232
}
3333

3434
message InfoResponse{
35-
bytes info_json = 1;
35+
bytes info_json = 1;
3636
}
3737

3838
message StartResponse {
39-
bool success = 1;
40-
string error = 2;
39+
bool success = 1;
40+
string error = 2;
4141
}
4242

4343
message SetConfigRequest {
44-
bytes instance_config_json = 1;
45-
int64 ssh_local_port = 3;
44+
bytes instance_config_json = 1;
45+
int64 ssh_local_port = 3;
4646
}
4747

4848
message ChangeDisplayPasswordRequest {
49-
string password = 1;
49+
string password = 1;
5050
}
5151

5252
message GetDisplayConnectionResponse {
53-
string connection = 1;
53+
string connection = 1;
5454
}
5555

5656
message CreateSnapshotRequest {
57-
string tag = 1;
57+
string tag = 1;
5858
}
5959

6060
message ApplySnapshotRequest {
61-
string tag = 1;
61+
string tag = 1;
6262
}
6363

6464
message DeleteSnapshotRequest {
65-
string tag = 1;
65+
string tag = 1;
6666
}
6767

6868
message ListSnapshotsResponse {
69-
string snapshots = 1;
69+
string snapshots = 1;
7070
}
7171

7272
message ForwardGuestAgentResponse {
73-
bool should_forward = 1;
73+
bool should_forward = 1;
7474
}

pkg/guestagent/api/guestservice.pb.desc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-

2+

33
guestservice.protogoogle/protobuf/empty.protogoogle/protobuf/timestamp.proto"0
44
Info(
55
local_ports ( 2.IPPortR
66
localPorts"�
77
Event.
88
time ( 2.google.protobuf.TimestampRtime3
9-
local_ports_added ( 2.IPPortRlocalPortsAdded7
10-
local_ports_removed ( 2.IPPortRlocalPortsRemoved
9+
added_local_ports ( 2.IPPortRaddedLocalPorts7
10+
removed_local_ports ( 2.IPPortRremovedLocalPorts
1111
errors ( Rerrors"H
1212
IPPort
1313
protocol ( Rprotocol
@@ -16,15 +16,16 @@ localPorts"
1616
Inotify
1717

1818
mount_path ( R mountPath.
19-
time ( 2.google.protobuf.TimestampRtime"�
19+
time ( 2.google.protobuf.TimestampRtime"�
2020
TunnelMessage
2121
id ( Rid
2222
protocol ( Rprotocol
23-
data ( Rdata
24-
guestAddr ( R guestAddr$
25-
udpTargetAddr ( RudpTargetAddr2�
23+
data ( Rdata
24+
25+
guest_addr ( R guestAddr&
26+
udp_target_addr ( RudpTargetAddr2�
2627
GuestService(
2728
GetInfo.google.protobuf.Empty.Info-
2829
GetEvents.google.protobuf.Empty.Event01
2930
PostInotify.Inotify.google.protobuf.Empty(,
30-
Tunnel.TunnelMessage.TunnelMessage(0B$Z"github.com/lima-vm/lima/v2/pkg/apibproto3
31+
Tunnel.TunnelMessage.TunnelMessage(0B/Z-github.com/lima-vm/lima/v2/pkg/guestagent/apibproto3

pkg/guestagent/api/guestservice.pb.go

Lines changed: 42 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/guestagent/api/guestservice.proto

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
syntax = "proto3";
2-
option go_package = "github.com/lima-vm/lima/v2/pkg/api";
32

43
import "google/protobuf/empty.proto";
54
import "google/protobuf/timestamp.proto";
65

6+
option go_package = "github.com/lima-vm/lima/v2/pkg/guestagent/api";
7+
78
service GuestService {
89
rpc GetInfo(google.protobuf.Empty) returns (Info);
910
rpc GetEvents(google.protobuf.Empty) returns (stream Event);
1011
rpc PostInotify(stream Inotify) returns (google.protobuf.Empty);
11-
12+
1213
rpc Tunnel(stream TunnelMessage) returns (stream TunnelMessage);
1314
}
1415

@@ -18,13 +19,13 @@ message Info {
1819

1920
message Event {
2021
google.protobuf.Timestamp time = 1;
21-
repeated IPPort local_ports_added = 2;
22-
repeated IPPort local_ports_removed = 3;
22+
repeated IPPort added_local_ports = 2;
23+
repeated IPPort removed_local_ports = 3;
2324
repeated string errors = 4;
2425
}
2526

2627
message IPPort {
27-
string protocol = 1; //tcp, udp
28+
string protocol = 1; // tcp, udp
2829
string ip = 2;
2930
int32 port = 3;
3031
}
@@ -36,8 +37,8 @@ message Inotify {
3637

3738
message TunnelMessage {
3839
string id = 1;
39-
string protocol = 2; //tcp, udp
40+
string protocol = 2; // tcp, udp
4041
bytes data = 3;
41-
string guestAddr = 4;
42-
string udpTargetAddr = 5;
42+
string guest_addr = 4;
43+
string udp_target_addr = 5;
4344
}

pkg/guestagent/guestagent_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (a *agent) collectEvent(ctx context.Context, st eventState) (*api.Event, ev
184184
ev.Time = timestamppb.Now()
185185
return ev, newSt
186186
}
187-
ev.LocalPortsAdded, ev.LocalPortsRemoved = comparePorts(st.ports, newSt.ports)
187+
ev.AddedLocalPorts, ev.RemovedLocalPorts = comparePorts(st.ports, newSt.ports)
188188
ev.Time = timestamppb.Now()
189189
return ev, newSt
190190
}

pkg/hostagent/port.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (pf *portForwarder) forwardingAddresses(guest *api.IPPort) (hostAddr, guest
8686
}
8787

8888
func (pf *portForwarder) OnEvent(ctx context.Context, ev *api.Event) {
89-
for _, f := range ev.LocalPortsRemoved {
89+
for _, f := range ev.RemovedLocalPorts {
9090
if f.Protocol != "tcp" {
9191
continue
9292
}
@@ -99,7 +99,7 @@ func (pf *portForwarder) OnEvent(ctx context.Context, ev *api.Event) {
9999
logrus.WithError(err).Warnf("failed to stop forwarding tcp port %d", f.Port)
100100
}
101101
}
102-
for _, f := range ev.LocalPortsAdded {
102+
for _, f := range ev.AddedLocalPorts {
103103
if f.Protocol != "tcp" {
104104
continue
105105
}

0 commit comments

Comments
 (0)