Skip to content

Fix proto style issues; enable protolint #3737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ jobs:
run: go install github.com/containerd/[email protected]
- name: Check license boilerplates
run: ltag -t ./hack/ltag --check -v
- name: Install protolint
run: go install github.com/yoheimuta/protolint/cmd/[email protected]
- name: Check protobuf files
run: protolint .

lint-go:
name: "Lint Go"
Expand Down
11 changes: 11 additions & 0 deletions .protolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is the configuration for protolint.
# See https://github.com/yoheimuta/protolint/blob/v0.55.6/_example/config/.protolint.yaml for details.
---
lint:
rules:
# Enable all default rules.
no_default: false
rules_option:
# MAX_LINE_LENGTH rule option.
max_line_length:
max_chars: 100
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ lint: check-generated
find . -name '*.sh' ! -path "./.git/*" | xargs shfmt -s -d
go-licenses check --include_tests ./... --allowed_licenses=$$(cat ./hack/allowed-licenses.txt)
ltag -t ./hack/ltag --check -v
protolint .

.PHONY: clean
clean:
Expand Down
64 changes: 32 additions & 32 deletions pkg/driver/external/driver.proto
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
syntax = "proto3";

option go_package = "github.com/lima-vm/lima/v2/pkg/driver/external";

import "google/protobuf/empty.proto";

option go_package = "github.com/lima-vm/lima/v2/pkg/driver/external";

service Driver {
rpc Validate(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc Initialize(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc CreateDisk(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc Start(google.protobuf.Empty) returns (stream StartResponse);
rpc Stop(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc Validate(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc Initialize(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc CreateDisk(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc Start(google.protobuf.Empty) returns (stream StartResponse);
rpc Stop(google.protobuf.Empty) returns (google.protobuf.Empty);

rpc RunGUI(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc ChangeDisplayPassword(ChangeDisplayPasswordRequest) returns (google.protobuf.Empty);
rpc GetDisplayConnection(google.protobuf.Empty) returns (GetDisplayConnectionResponse);
rpc RunGUI(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc ChangeDisplayPassword(ChangeDisplayPasswordRequest) returns (google.protobuf.Empty);
rpc GetDisplayConnection(google.protobuf.Empty) returns (GetDisplayConnectionResponse);

rpc CreateSnapshot(CreateSnapshotRequest) returns (google.protobuf.Empty);
rpc ApplySnapshot(ApplySnapshotRequest) returns (google.protobuf.Empty);
rpc DeleteSnapshot(DeleteSnapshotRequest) returns (google.protobuf.Empty);
rpc ListSnapshots(google.protobuf.Empty) returns (ListSnapshotsResponse);
rpc CreateSnapshot(CreateSnapshotRequest) returns (google.protobuf.Empty);
rpc ApplySnapshot(ApplySnapshotRequest) returns (google.protobuf.Empty);
rpc DeleteSnapshot(DeleteSnapshotRequest) returns (google.protobuf.Empty);
rpc ListSnapshots(google.protobuf.Empty) returns (ListSnapshotsResponse);

rpc Register(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc Unregister(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc Register(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc Unregister(google.protobuf.Empty) returns (google.protobuf.Empty);

rpc ForwardGuestAgent(google.protobuf.Empty) returns (ForwardGuestAgentResponse);
rpc GuestAgentConn(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc ForwardGuestAgent(google.protobuf.Empty) returns (ForwardGuestAgentResponse);
rpc GuestAgentConn(google.protobuf.Empty) returns (google.protobuf.Empty);

rpc SetConfig(SetConfigRequest) returns (google.protobuf.Empty);
rpc SetConfig(SetConfigRequest) returns (google.protobuf.Empty);

rpc GetInfo(google.protobuf.Empty) returns (InfoResponse);
rpc GetInfo(google.protobuf.Empty) returns (InfoResponse);
}

message InfoResponse{
bytes info_json = 1;
bytes info_json = 1;
}

message StartResponse {
bool success = 1;
string error = 2;
bool success = 1;
string error = 2;
}

message SetConfigRequest {
bytes instance_config_json = 1;
int64 ssh_local_port = 3;
bytes instance_config_json = 1;
int64 ssh_local_port = 3;
}

message ChangeDisplayPasswordRequest {
string password = 1;
string password = 1;
}

message GetDisplayConnectionResponse {
string connection = 1;
string connection = 1;
}

message CreateSnapshotRequest {
string tag = 1;
string tag = 1;
}

message ApplySnapshotRequest {
string tag = 1;
string tag = 1;
}

message DeleteSnapshotRequest {
string tag = 1;
string tag = 1;
}

message ListSnapshotsResponse {
string snapshots = 1;
string snapshots = 1;
}

message ForwardGuestAgentResponse {
bool should_forward = 1;
bool should_forward = 1;
}
17 changes: 9 additions & 8 deletions pkg/guestagent/api/guestservice.pb.desc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@



guestservice.protogoogle/protobuf/empty.protogoogle/protobuf/timestamp.proto"0
Info(
local_ports ( 2.IPPortR
localPorts"�
Event.
time ( 2.google.protobuf.TimestampRtime3
local_ports_added ( 2.IPPortRlocalPortsAdded7
local_ports_removed ( 2.IPPortRlocalPortsRemoved
added_local_ports ( 2.IPPortRaddedLocalPorts7
removed_local_ports ( 2.IPPortRremovedLocalPorts
errors ( Rerrors"H
IPPort
protocol ( Rprotocol
Expand All @@ -16,15 +16,16 @@ localPorts"
Inotify

mount_path ( R mountPath.
time ( 2.google.protobuf.TimestampRtime"�
time ( 2.google.protobuf.TimestampRtime"�
TunnelMessage
id ( Rid
protocol ( Rprotocol
data ( Rdata
guestAddr ( R guestAddr$
udpTargetAddr ( RudpTargetAddr2�
data ( Rdata

guest_addr ( R guestAddr&
udp_target_addr ( RudpTargetAddr2�
GuestService(
GetInfo.google.protobuf.Empty.Info-
GetEvents.google.protobuf.Empty.Event01
PostInotify.Inotify.google.protobuf.Empty(,
Tunnel.TunnelMessage.TunnelMessage(0B$Z"github.com/lima-vm/lima/v2/pkg/apibproto3
Tunnel.TunnelMessage.TunnelMessage(0B/Z-github.com/lima-vm/lima/v2/pkg/guestagent/apibproto3
Expand Down
83 changes: 42 additions & 41 deletions pkg/guestagent/api/guestservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions pkg/guestagent/api/guestservice.proto
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
syntax = "proto3";
option go_package = "github.com/lima-vm/lima/v2/pkg/api";

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/lima-vm/lima/v2/pkg/guestagent/api";

service GuestService {
rpc GetInfo(google.protobuf.Empty) returns (Info);
rpc GetEvents(google.protobuf.Empty) returns (stream Event);
rpc PostInotify(stream Inotify) returns (google.protobuf.Empty);

rpc Tunnel(stream TunnelMessage) returns (stream TunnelMessage);
}

Expand All @@ -18,13 +19,13 @@ message Info {

message Event {
google.protobuf.Timestamp time = 1;
repeated IPPort local_ports_added = 2;
repeated IPPort local_ports_removed = 3;
repeated IPPort added_local_ports = 2;
repeated IPPort removed_local_ports = 3;
repeated string errors = 4;
}

message IPPort {
string protocol = 1; //tcp, udp
string protocol = 1; // tcp, udp
string ip = 2;
int32 port = 3;
}
Expand All @@ -36,8 +37,8 @@ message Inotify {

message TunnelMessage {
string id = 1;
string protocol = 2; //tcp, udp
string protocol = 2; // tcp, udp
bytes data = 3;
string guestAddr = 4;
string udpTargetAddr = 5;
string guest_addr = 4;
string udp_target_addr = 5;
}
2 changes: 1 addition & 1 deletion pkg/guestagent/guestagent_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (a *agent) collectEvent(ctx context.Context, st eventState) (*api.Event, ev
ev.Time = timestamppb.Now()
return ev, newSt
}
ev.LocalPortsAdded, ev.LocalPortsRemoved = comparePorts(st.ports, newSt.ports)
ev.AddedLocalPorts, ev.RemovedLocalPorts = comparePorts(st.ports, newSt.ports)
ev.Time = timestamppb.Now()
return ev, newSt
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/hostagent/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (pf *portForwarder) forwardingAddresses(guest *api.IPPort) (hostAddr, guest
}

func (pf *portForwarder) OnEvent(ctx context.Context, ev *api.Event) {
for _, f := range ev.LocalPortsRemoved {
for _, f := range ev.RemovedLocalPorts {
if f.Protocol != "tcp" {
continue
}
Expand All @@ -99,7 +99,7 @@ func (pf *portForwarder) OnEvent(ctx context.Context, ev *api.Event) {
logrus.WithError(err).Warnf("failed to stop forwarding tcp port %d", f.Port)
}
}
for _, f := range ev.LocalPortsAdded {
for _, f := range ev.AddedLocalPorts {
if f.Protocol != "tcp" {
continue
}
Expand Down
Loading