Skip to content

Commit f47a9da

Browse files
authored
Merge pull request moby#4135 from jedevc/chore-add-protolint
Add protobuf linting
2 parents cab7db2 + 04c7b9d commit f47a9da

File tree

12 files changed

+355
-318
lines changed

12 files changed

+355
-318
lines changed

.protolint.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
lint:
2+
directories:
3+
exclude:
4+
- vendor
5+
6+
rules:
7+
no_default: true
8+
9+
add:
10+
# syntax
11+
- INDENT
12+
- SYNTAX_CONSISTENT
13+
- QUOTE_CONSISTENT
14+
15+
# ordering
16+
- IMPORTS_SORTED
17+
18+
# naming
19+
- PACKAGE_NAME_LOWER_CASE
20+
- RPC_NAMES_UPPER_CAMEL_CASE
21+
- RPC_NAMES_CASE
22+
- SERVICE_NAMES_UPPER_CAMEL_CASE
23+
24+
rules_option:
25+
indent:
26+
style: tab
27+
not_insert_newline: true

api/services/control/control.pb.go

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

api/services/control/control.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ syntax = "proto3";
22

33
package moby.buildkit.v1;
44

5-
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
6-
import "google/protobuf/timestamp.proto";
7-
import "github.com/moby/buildkit/solver/pb/ops.proto";
8-
import "github.com/moby/buildkit/api/types/worker.proto";
95
// import "github.com/containerd/containerd/api/types/descriptor.proto";
106
import "github.com/gogo/googleapis/google/rpc/status.proto";
7+
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
8+
import "github.com/moby/buildkit/api/types/worker.proto";
9+
import "github.com/moby/buildkit/solver/pb/ops.proto";
1110
import "github.com/moby/buildkit/sourcepolicy/pb/policy.proto";
11+
import "google/protobuf/timestamp.proto";
1212

1313
option (gogoproto.sizer_all) = true;
1414
option (gogoproto.marshaler_all) = true;

docker-bake.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ target "lint" {
9393
{ name = "labs", tags = "dfrunsecurity", target = "golangci-lint" },
9494
{ name = "nydus", tags = "nydus", target = "golangci-lint" },
9595
{ name = "yaml", tags = "", target = "yamllint" },
96+
{ name = "proto", tags = "", target = "protolint" },
9697
]
9798
}
9899
}

frontend/gateway/pb/gateway.pb.go

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

frontend/gateway/pb/gateway.proto

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ syntax = "proto3";
22

33
package moby.buildkit.v1.frontend;
44

5-
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
65
import "github.com/gogo/googleapis/google/rpc/status.proto";
7-
import "github.com/moby/buildkit/solver/pb/ops.proto";
6+
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
87
import "github.com/moby/buildkit/api/types/worker.proto";
8+
import "github.com/moby/buildkit/solver/pb/ops.proto";
9+
import "github.com/moby/buildkit/sourcepolicy/pb/policy.proto";
910
import "github.com/moby/buildkit/util/apicaps/pb/caps.proto";
1011
import "github.com/tonistiigi/fsutil/types/stat.proto";
11-
import "github.com/moby/buildkit/sourcepolicy/pb/policy.proto";
12-
13-
1412

1513
option (gogoproto.sizer_all) = true;
1614
option (gogoproto.marshaler_all) = true;
@@ -70,7 +68,7 @@ message RefMap {
7068
}
7169

7270
message Attestations {
73-
repeated Attestation attestation = 1;
71+
repeated Attestation attestation = 1;
7472
}
7573

7674
message Attestation {
@@ -167,7 +165,7 @@ message SolveResponse {
167165
// deprecated
168166
string ref = 1; // can be used by readfile request
169167
// deprecated
170-
/* bytes ExporterAttr = 2;*/
168+
// bytes ExporterAttr = 2;
171169

172170
// these fields are returned when allowMapReturn was set
173171
Result result = 3;

hack/dockerfiles/lint.Dockerfile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
# syntax=docker/dockerfile-upstream:master
22

33
ARG GO_VERSION=1.20
4+
ARG PROTOLINT_VERSION=0.45.0
5+
ARG GOLANGCI_LINT_VERSION=1.52.2
46

5-
FROM golang:${GO_VERSION}-alpine AS base
7+
FROM golang:${GO_VERSION}-alpine AS golang-base
8+
FROM yoheimuta/protolint:${PROTOLINT_VERSION} AS protolint-base
9+
10+
FROM golang-base AS base
611
ENV GOFLAGS="-buildvcs=false"
12+
ARG GOLANGCI_LINT_VERSION
713
RUN apk add --no-cache gcc musl-dev yamllint
8-
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.52.2
14+
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v${GOLANGCI_LINT_VERSION}
15+
COPY --link --from=protolint-base /usr/local/bin/protolint /usr/local/bin/protolint
916
WORKDIR /go/src/github.com/moby/buildkit
1017

1118
FROM base as golangci-lint
@@ -20,6 +27,12 @@ RUN --mount=target=/go/src/github.com/moby/buildkit --mount=target=/root/.cache,
2027
yamllint -c .yamllint.yml --strict . && \
2128
touch /yamllint.done
2229

30+
FROM base as protolint
31+
RUN --mount=target=/go/src/github.com/moby/buildkit \
32+
protolint lint . && \
33+
touch /protolint.done
34+
2335
FROM scratch
2436
COPY --link --from=golangci-lint /golangci-lint.done /
2537
COPY --link --from=yamllint /yamllint.done /
38+
COPY --link --from=protolint /protolint.done /

session/auth/auth.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ package moby.filesync.v1;
55
option go_package = "auth";
66

77
service Auth{
8-
rpc Credentials(CredentialsRequest) returns (CredentialsResponse);
9-
rpc FetchToken(FetchTokenRequest) returns (FetchTokenResponse);
10-
rpc GetTokenAuthority(GetTokenAuthorityRequest) returns (GetTokenAuthorityResponse);
11-
rpc VerifyTokenAuthority(VerifyTokenAuthorityRequest) returns (VerifyTokenAuthorityResponse);
8+
rpc Credentials(CredentialsRequest) returns (CredentialsResponse);
9+
rpc FetchToken(FetchTokenRequest) returns (FetchTokenResponse);
10+
rpc GetTokenAuthority(GetTokenAuthorityRequest) returns (GetTokenAuthorityResponse);
11+
rpc VerifyTokenAuthority(VerifyTokenAuthorityRequest) returns (VerifyTokenAuthorityResponse);
1212
}
1313

1414
message CredentialsRequest {

session/filesync/filesync.proto

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ option go_package = "filesync";
77
import "github.com/tonistiigi/fsutil/types/wire.proto";
88

99
service FileSync{
10-
rpc DiffCopy(stream fsutil.types.Packet) returns (stream fsutil.types.Packet);
11-
rpc TarStream(stream fsutil.types.Packet) returns (stream fsutil.types.Packet);
10+
rpc DiffCopy(stream fsutil.types.Packet) returns (stream fsutil.types.Packet);
11+
rpc TarStream(stream fsutil.types.Packet) returns (stream fsutil.types.Packet);
1212
}
1313

1414
service FileSend{
15-
rpc DiffCopy(stream BytesMessage) returns (stream BytesMessage);
15+
rpc DiffCopy(stream BytesMessage) returns (stream BytesMessage);
1616
}
1717

18-
1918
// BytesMessage contains a chunk of byte data
2019
message BytesMessage{
2120
bytes data = 1;

session/secrets/secrets.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package moby.buildkit.secrets.v1;
55
option go_package = "secrets";
66

77
service Secrets{
8-
rpc GetSecret(GetSecretRequest) returns (GetSecretResponse);
8+
rpc GetSecret(GetSecretRequest) returns (GetSecretResponse);
99
}
1010

1111

0 commit comments

Comments
 (0)