Skip to content

Commit 0889cf9

Browse files
committed
feat(proto): buf format, new command acced
1 parent eac05fe commit 0889cf9

File tree

10 files changed

+109
-133
lines changed

10 files changed

+109
-133
lines changed

docs/advanced/buf.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,12 @@ buf push --tag <TAG_NAME>
150150
### Format
151151

152152
```shell
153-
# FIXME buf don't have proto formatter yet
154-
prototool format -w proto;
153+
# dry-run, show changes
154+
buf format --diff
155+
# format and write
156+
buf format -w
157+
# use the --exit-code flag to exit with a non-zero exit code if there is a diff
158+
buf format -w --exit-code
155159
```
156160

157161
## Tools

proto/dataapis/data/bigquery/v1/bigquery_options.proto

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

33
package data.bigquery.v1;
44

5+
import "google/protobuf/descriptor.proto";
6+
57
option java_multiple_files = true;
68
option java_package = "data.bigquery.v1";
79

8-
import "google/protobuf/descriptor.proto";
9-
1010
extend google.protobuf.MessageOptions {
1111
string BigQueryTableReference = 66666667;
1212
string BigQueryTableDescription = 66666668;

proto/dataapis/data/privacy/v1/privacy_options.proto

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

33
package data.privacy.v1;
44

5+
import "google/protobuf/descriptor.proto";
6+
57
option java_multiple_files = true;
68
option java_package = "data.privacy.v1";
79

8-
import "google/protobuf/descriptor.proto";
9-
1010
extend google.protobuf.FieldOptions {
1111
bool sensitive = 50000;
1212
}

proto/demoapis/gkit/schema/common/v1/common.proto

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

33
package gkit.schema.common.v1;
44

5+
import "google/protobuf/wrappers.proto";
6+
import "validate/validate.proto";
7+
58
//option go_package = "github.com/xmlking/grpc-starter-kit/gen/go//gkit/schema/common/v1;commonv1";
69
option java_multiple_files = true;
710
option java_package = "gkit.schema.common.v1";
811

9-
import "google/protobuf/wrappers.proto";
10-
import "validate/validate.proto";
11-
1212
// Generic Error message
1313
message Error {
1414
option (validate.ignored) = true;

proto/demoapis/gkit/schema/transaction/v1/transaction.proto

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

33
package gkit.schema.transaction.v1;
44

5-
option java_multiple_files = true;
6-
option java_package = "gkit.schema.transaction.v1";
7-
85
import "google/protobuf/any.proto";
96
import "validate/validate.proto";
107

8+
option java_multiple_files = true;
9+
option java_package = "gkit.schema.transaction.v1";
10+
1111
// Transaction Event
1212
message TransactionEvent {
1313
option (validate.ignored) = true;

proto/demoapis/gkit/schema/transaction/v1alpha1/transaction.proto

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

33
package gkit.schema.transaction.v1alpha1;
44

5+
import "google/protobuf/struct.proto";
6+
57
option java_multiple_files = true;
68
option java_package = "gkit.schema.transaction.v1alpha1";
79

8-
import "google/protobuf/struct.proto";
9-
1010
// Transaction Event
1111
message TransactionEvent1 {
1212
// request

proto/demoapis/gkit/service/account/entities/v1/entities.proto

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

33
package gkit.service.account.entities.v1;
44

5-
option java_multiple_files = true;
6-
option java_package = "gkit.service.account.entities.v1";
7-
85
import "google/protobuf/timestamp.proto";
96
import "google/protobuf/wrappers.proto";
10-
import "validate/validate.proto";
117
import "tagger/tagger.proto";
8+
import "validate/validate.proto";
9+
10+
option java_multiple_files = true;
11+
option java_package = "gkit.service.account.entities.v1";
1212

1313
// User Entity
1414
message User {
@@ -20,7 +20,7 @@ message User {
2020
google.protobuf.StringValue username = 7;
2121
string first_name = 8;
2222
string last_name = 9;
23-
optional string email = 10 [(tagger.tags) = "avro:\"email\" graphql:\"withNewTags,optional\"" ];
23+
optional string email = 10 [(tagger.tags) = "avro:\"email\" graphql:\"withNewTags,optional\""];
2424
gkit.service.account.entities.v1.Profile profile = 11;
2525
}
2626

proto/demoapis/gkit/service/account/profile/v1/profile_service.proto

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

33
package gkit.service.account.profile.v1;
44

5-
option java_multiple_files = true;
6-
option java_package = "gkit.service.account.profile.v1";
7-
5+
import "gkit/service/account/entities/v1/entities.proto";
86
import "google/protobuf/timestamp.proto";
97
// import "shared/proto/common/common.proto";
108
import "google/protobuf/wrappers.proto";
11-
import "gkit/service/account/entities/v1/entities.proto";
129
import "validate/validate.proto";
1310

11+
option java_multiple_files = true;
12+
option java_package = "gkit.service.account.profile.v1";
13+
1414
service ProfileService {
1515
rpc List(ListRequest) returns (ListResponse);
1616
rpc Get(GetRequest) returns (GetResponse);
@@ -20,33 +20,27 @@ service ProfileService {
2020
// FIXME: https://github.com/envoyproxy/protoc-gen-validate/issues/223
2121
// Workaround in .override.go
2222
message ListRequest {
23-
google.protobuf.UInt32Value limit = 1 [
24-
(validate.rules).uint32 = {
25-
gte: 1
26-
lte: 100
27-
}
28-
];
23+
google.protobuf.UInt32Value limit = 1 [(validate.rules).uint32 = {
24+
gte: 1
25+
lte: 100
26+
}];
2927
google.protobuf.UInt32Value page = 2 [(validate.rules).uint32.gte = 1];
3028
google.protobuf.StringValue sort = 3;
31-
google.protobuf.StringValue preferred_theme = 4 [
32-
(validate.rules).string = {
33-
in: [
34-
"dark",
35-
"light",
36-
"cosmic",
37-
"corporate"
38-
]
39-
}
40-
];
41-
gkit.service.account.entities.v1.Profile.GenderType gender = 5 [
42-
(validate.rules).enum = {
43-
in: [
44-
0,
45-
1,
46-
2
47-
]
48-
}
49-
];
29+
google.protobuf.StringValue preferred_theme = 4 [(validate.rules).string = {
30+
in: [
31+
"dark",
32+
"light",
33+
"cosmic",
34+
"corporate"
35+
]
36+
}];
37+
gkit.service.account.entities.v1.Profile.GenderType gender = 5 [(validate.rules).enum = {
38+
in: [
39+
0,
40+
1,
41+
2
42+
]
43+
}];
5044
}
5145

5246
message ListResponse {
@@ -71,27 +65,23 @@ message CreateRequest {
7165
google.protobuf.StringValue user_id = 2 [(validate.rules).string.uuid = true]; // Not Working
7266
google.protobuf.StringValue tz = 3;
7367
google.protobuf.StringValue avatar = 4 [(validate.rules).string.uri_ref = true];
74-
gkit.service.account.entities.v1.Profile.GenderType gender = 5 [
75-
(validate.rules).enum = {
76-
in: [
77-
0,
78-
1,
79-
2
80-
]
81-
}
82-
];
68+
gkit.service.account.entities.v1.Profile.GenderType gender = 5 [(validate.rules).enum = {
69+
in: [
70+
0,
71+
1,
72+
2
73+
]
74+
}];
8375
google.protobuf.Timestamp birthday = 6 [(validate.rules).timestamp.lt_now = true];
84-
google.protobuf.StringValue preferred_theme = 7 [
85-
(validate.rules).string = {
86-
ignore_empty: true,
87-
in: [
88-
"dark",
89-
"light",
90-
"cosmic",
91-
"corporate"
92-
]
93-
}
94-
];
76+
google.protobuf.StringValue preferred_theme = 7 [(validate.rules).string = {
77+
ignore_empty: true,
78+
in: [
79+
"dark",
80+
"light",
81+
"cosmic",
82+
"corporate"
83+
]
84+
}];
9585
}
9686

9787
message CreateResponse {

proto/demoapis/gkit/service/account/user/v1/user_service.proto

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

33
package gkit.service.account.user.v1;
44

5-
option java_multiple_files = true;
6-
option java_package = "gkit.service.account.user.v1";
7-
8-
import "google/protobuf/wrappers.proto";
95
// import "shared/proto/common/common.proto";
106
import "gkit/service/account/entities/v1/entities.proto";
7+
import "google/protobuf/wrappers.proto";
118
import "validate/validate.proto";
129

10+
option java_multiple_files = true;
11+
option java_package = "gkit.service.account.user.v1";
12+
1313
// Ref:
1414
// https://github.com/seizadi/atlas-template/blob/master/resolved/pkg/pb/cmdb.proto
1515

@@ -27,14 +27,12 @@ service UserService {
2727
// with Workaround in .override.go
2828
message ExistRequest {
2929
google.protobuf.StringValue id = 1 [(validate.rules).string.uuid = true]; // Not Working
30-
google.protobuf.StringValue username = 2 [
31-
(validate.rules).string = {
32-
min_len: 4
33-
max_len: 16
34-
pattern: "^[a-z0-9_-]{3,15}$"
35-
max_bytes: 256
36-
}
37-
];
30+
google.protobuf.StringValue username = 2 [(validate.rules).string = {
31+
min_len: 4
32+
max_len: 16
33+
pattern: "^[a-z0-9_-]{3,15}$"
34+
max_bytes: 256
35+
}];
3836
google.protobuf.StringValue first_name = 3 [(validate.rules).string.min_len = 3];
3937
google.protobuf.StringValue last_name = 4 [(validate.rules).string.min_len = 3];
4038
google.protobuf.StringValue email = 5 [(validate.rules).string.email = true]; // Not Working
@@ -46,22 +44,18 @@ message ExistResponse {
4644
}
4745

4846
message ListRequest {
49-
google.protobuf.UInt32Value limit = 1 [
50-
(validate.rules).uint32 = {
51-
gte: 1
52-
lte: 100
53-
}
54-
];
47+
google.protobuf.UInt32Value limit = 1 [(validate.rules).uint32 = {
48+
gte: 1
49+
lte: 100
50+
}];
5551
google.protobuf.UInt32Value page = 2 [(validate.rules).uint32.gte = 1];
5652
google.protobuf.StringValue sort = 3;
57-
google.protobuf.StringValue username = 4 [
58-
(validate.rules).string = {
59-
min_len: 4
60-
max_len: 16
61-
pattern: "^[a-z0-9_-]{3,15}$"
62-
max_bytes: 256
63-
}
64-
];
53+
google.protobuf.StringValue username = 4 [(validate.rules).string = {
54+
min_len: 4
55+
max_len: 16
56+
pattern: "^[a-z0-9_-]{3,15}$"
57+
max_bytes: 256
58+
}];
6559
google.protobuf.StringValue first_name = 5 [(validate.rules).string.min_len = 3];
6660
google.protobuf.StringValue last_name = 6 [(validate.rules).string.min_len = 3];
6761
google.protobuf.StringValue email = 7 [(validate.rules).string.email = true]; // Not Working
@@ -75,14 +69,12 @@ message ListResponse {
7569

7670
message GetRequest {
7771
google.protobuf.StringValue id = 1 [(validate.rules).string.uuid = true]; // Not Working
78-
google.protobuf.StringValue username = 2 [
79-
(validate.rules).string = {
80-
min_len: 4
81-
max_len: 16
82-
pattern: "^[a-z0-9_-]{3,15}$"
83-
max_bytes: 256
84-
}
85-
];
72+
google.protobuf.StringValue username = 2 [(validate.rules).string = {
73+
min_len: 4
74+
max_len: 16
75+
pattern: "^[a-z0-9_-]{3,15}$"
76+
max_bytes: 256
77+
}];
8678
google.protobuf.StringValue first_name = 3 [(validate.rules).string.min_len = 3];
8779
google.protobuf.StringValue last_name = 4 [(validate.rules).string.min_len = 3];
8880
google.protobuf.StringValue email = 5 [(validate.rules).string.email = true]; // Not Working
@@ -92,18 +84,15 @@ message GetResponse {
9284
option (validate.disabled) = true;
9385
gkit.service.account.entities.v1.User result = 1;
9486
// basic.Error error =2;
95-
9687
}
9788

9889
message CreateRequest {
99-
google.protobuf.StringValue username = 2 [
100-
(validate.rules).string = {
101-
min_len: 4
102-
max_len: 16
103-
pattern: "^[a-z0-9_-]{3,15}$"
104-
max_bytes: 256
105-
}
106-
];
90+
google.protobuf.StringValue username = 2 [(validate.rules).string = {
91+
min_len: 4
92+
max_len: 16
93+
pattern: "^[a-z0-9_-]{3,15}$"
94+
max_bytes: 256
95+
}];
10796
google.protobuf.StringValue first_name = 3 [(validate.rules).string.min_len = 3];
10897
google.protobuf.StringValue last_name = 4 [(validate.rules).string.min_len = 3];
10998
google.protobuf.StringValue email = 5 [(validate.rules).string.email = true]; // Not Working
@@ -116,14 +105,12 @@ message CreateResponse {
116105

117106
message UpdateRequest {
118107
google.protobuf.StringValue id = 1 [(validate.rules).string.uuid = true]; // Not Working
119-
google.protobuf.StringValue username = 2 [
120-
(validate.rules).string = {
121-
min_len: 4
122-
max_len: 16
123-
pattern: "^[a-z0-9_-]{3,15}$"
124-
max_bytes: 256
125-
}
126-
];
108+
google.protobuf.StringValue username = 2 [(validate.rules).string = {
109+
min_len: 4
110+
max_len: 16
111+
pattern: "^[a-z0-9_-]{3,15}$"
112+
max_bytes: 256
113+
}];
127114
google.protobuf.StringValue first_name = 3 [(validate.rules).string.min_len = 3];
128115
google.protobuf.StringValue last_name = 4 [(validate.rules).string.min_len = 3];
129116
google.protobuf.StringValue email = 5 [(validate.rules).string.email = true]; // Not Working
@@ -136,14 +123,12 @@ message UpdateResponse {
136123

137124
message DeleteRequest {
138125
google.protobuf.StringValue id = 1 [(validate.rules).string.uuid = true]; // Not Working
139-
google.protobuf.StringValue username = 2 [
140-
(validate.rules).string = {
141-
min_len: 4
142-
max_len: 16
143-
pattern: "^[a-z0-9_-]{3,15}$"
144-
max_bytes: 256
145-
}
146-
];
126+
google.protobuf.StringValue username = 2 [(validate.rules).string = {
127+
min_len: 4
128+
max_len: 16
129+
pattern: "^[a-z0-9_-]{3,15}$"
130+
max_bytes: 256
131+
}];
147132
google.protobuf.StringValue first_name = 3 [(validate.rules).string.min_len = 3];
148133
google.protobuf.StringValue last_name = 4 [(validate.rules).string.min_len = 3];
149134
google.protobuf.StringValue email = 5 [(validate.rules).string.email = true]; // Not Working

0 commit comments

Comments
 (0)