Skip to content

Feature: Buf gen and workflow #1704

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions .github/workflows/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Buf

on:
push:
branches:
- main

pull_request:
branches:
- main
paths:
- "proto/**"

jobs:
buf:
name: Run buf
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: bufbuild/buf-action@v1
with:
github_token: ${{ github.token }}
21 changes: 21 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: v2
managed:
enabled: true
override:
- file_option: go_package_prefix
value: github.com/distribworks/dkron/v4/types

inputs:
- directory: ./proto
plugins:
#- remote: buf.build/protocolbuffers/go:v1.31.0
- local: protoc-gen-go
out: types
opt:
- paths=source_relative
#- remote: buf.build/grpc/go:v1.5.1
- local: protoc-gen-go-grpc
out: types
opt:
- paths=source_relative

51 changes: 26 additions & 25 deletions proto/dkron.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// protoc -I proto/ --go_out=types --go_opt=paths=source_relative --go-grpc_out=types --go-grpc_opt=paths=source_relative dkron.proto
syntax = "proto3";

package types;

Check failure on line 4 in proto/dkron.proto

View workflow job for this annotation

GitHub Actions / Run buf

Package name "types" should be suffixed with a correctly formed version, such as "types.v1".

Check failure on line 4 in proto/dkron.proto

View workflow job for this annotation

GitHub Actions / Run buf

Files with package "types" must be within a directory "types" relative to root but were in directory ".".
option go_package = "github.com/distribworks/dkron/plugin/types";

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

option go_package = "github.com/distribworks/dkron/plugin/types";

Check failure on line 9 in proto/dkron.proto

View workflow job for this annotation

GitHub Actions / Run buf

Files in package "types" have multiple values "github.com/distribworks/dkron/plugin/types,github.com/distribworks/dkron/types" for option "go_package" and all values must be equal.

message Job {
string name = 1;
Expand Down Expand Up @@ -54,7 +55,7 @@
string job_name = 1;
}

message DeleteJobResponse{
message DeleteJobResponse {
Job job = 1;
}

Expand All @@ -68,10 +69,10 @@

message Execution {
string job_name = 1;
bool success = 2;
bytes output = 3;
string node_name = 4;
int64 group = 5;
bool success = 2;
bytes output = 3;
string node_name = 4;
int64 group = 5;
uint32 attempt = 6;
google.protobuf.Timestamp started_at = 7;
google.protobuf.Timestamp finished_at = 8;
Expand Down Expand Up @@ -104,16 +105,16 @@

message RaftServer {
string id = 1;
string node = 2;
string address = 3;
bool leader = 4;
bool voter = 5;
string raft_protocol = 6;
string node = 2;
string address = 3;
bool leader = 4;
bool voter = 5;
string raft_protocol = 6;
}

message RaftGetConfigurationResponse {
repeated RaftServer servers = 1;
uint64 index = 2;
uint64 index = 2;
}

message RaftRemovePeerByIDRequest {
Expand All @@ -133,18 +134,18 @@
repeated Execution executions = 1;
}

service Dkron {

Check failure on line 137 in proto/dkron.proto

View workflow job for this annotation

GitHub Actions / Run buf

Service name "Dkron" should be suffixed with "Service".
rpc GetJob (GetJobRequest) returns (GetJobResponse);
rpc ExecutionDone (ExecutionDoneRequest) returns (ExecutionDoneResponse);
rpc Leave (google.protobuf.Empty) returns (google.protobuf.Empty);
rpc SetJob (SetJobRequest) returns (SetJobResponse);
rpc DeleteJob (DeleteJobRequest) returns (DeleteJobResponse);
rpc RunJob (RunJobRequest) returns (RunJobResponse);
rpc ToggleJob (ToggleJobRequest) returns (ToggleJobResponse);
rpc RaftGetConfiguration (google.protobuf.Empty) returns (RaftGetConfigurationResponse);
rpc RaftRemovePeerByID (RaftRemovePeerByIDRequest) returns (google.protobuf.Empty);
rpc GetActiveExecutions (google.protobuf.Empty) returns (GetActiveExecutionsResponse);
rpc SetExecution (Execution) returns (google.protobuf.Empty);
rpc GetJob(GetJobRequest) returns (GetJobResponse);
rpc ExecutionDone(ExecutionDoneRequest) returns (ExecutionDoneResponse);
rpc Leave(google.protobuf.Empty) returns (google.protobuf.Empty);

Check failure on line 140 in proto/dkron.proto

View workflow job for this annotation

GitHub Actions / Run buf

RPC response type "Empty" should be named "LeaveResponse" or "DkronLeaveResponse".

Check failure on line 140 in proto/dkron.proto

View workflow job for this annotation

GitHub Actions / Run buf

RPC request type "Empty" should be named "LeaveRequest" or "DkronLeaveRequest".

Check failure on line 140 in proto/dkron.proto

View workflow job for this annotation

GitHub Actions / Run buf

RPC "Leave" has the same type "google.protobuf.Empty" for the request and response.

Check failure on line 140 in proto/dkron.proto

View workflow job for this annotation

GitHub Actions / Run buf

"google.protobuf.Empty" is used as the request or response type for multiple RPCs.
rpc SetJob(SetJobRequest) returns (SetJobResponse);
rpc DeleteJob(DeleteJobRequest) returns (DeleteJobResponse);
rpc RunJob(RunJobRequest) returns (RunJobResponse);
rpc ToggleJob(ToggleJobRequest) returns (ToggleJobResponse);
rpc RaftGetConfiguration(google.protobuf.Empty) returns (RaftGetConfigurationResponse);

Check failure on line 145 in proto/dkron.proto

View workflow job for this annotation

GitHub Actions / Run buf

RPC request type "Empty" should be named "RaftGetConfigurationRequest" or "DkronRaftGetConfigurationRequest".

Check failure on line 145 in proto/dkron.proto

View workflow job for this annotation

GitHub Actions / Run buf

"google.protobuf.Empty" is used as the request or response type for multiple RPCs.
rpc RaftRemovePeerByID(RaftRemovePeerByIDRequest) returns (google.protobuf.Empty);
rpc GetActiveExecutions(google.protobuf.Empty) returns (GetActiveExecutionsResponse);
rpc SetExecution(Execution) returns (google.protobuf.Empty);
}

message AgentRunRequest {
Expand All @@ -153,5 +154,5 @@
}

service Agent {
rpc AgentRun (AgentRunRequest) returns (stream AgentRunStream);
rpc AgentRun(AgentRunRequest) returns (stream AgentRunStream);
}
7 changes: 4 additions & 3 deletions proto/executor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
syntax = "proto3";

package types;

option go_package = "github.com/distribworks/dkron/plugin/types";

message ExecuteRequest {
Expand All @@ -11,12 +12,12 @@ message ExecuteRequest {
}

message ExecuteResponse {
bytes output = 1;
string error = 2;
bytes output = 1;
string error = 2;
}

service Executor {
rpc Execute (ExecuteRequest) returns (ExecuteResponse);
rpc Execute(ExecuteRequest) returns (ExecuteResponse);
}

message StatusUpdateRequest {
Expand Down
70 changes: 36 additions & 34 deletions proto/pro.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,96 +2,98 @@
syntax = "proto3";

package types;
option go_package = "github.com/distribworks/dkron/types";

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

option go_package = "github.com/distribworks/dkron/types";

// Policy is a policy definition
message Policy {
string name = 1;
string rules = 2;
string name = 1;
string rules = 2;
}

message ACLPolicyUpsertRequest {
Policy policy = 1;
Policy policy = 1;
}

message ACLPolicyUpsertResponse {
bool success = 1;
bool success = 1;
}

message ACLPolicyDeleteRequest {
string name = 1;
string name = 1;
}

message ACLPolicyDeleteResponse {
bool success = 1;
bool success = 1;
}

message ACLPolicyInfoRequest {
string name = 1;
string name = 1;
}

message ACLPolicyInfoResponse {
Policy policy = 1;
Policy policy = 1;
}

message ACLPolicyListResponse {
repeated Policy policies = 1;
repeated Policy policies = 1;
}

enum TokenType {
management = 0;
client = 1;
management = 0;
client = 1;
}

// Token is the representation of a token
message Token {
string accessor = 1;
string secret = 2;
string name = 3;
TokenType type = 4;
google.protobuf.Timestamp create_time = 5;
google.protobuf.Timestamp expire_time = 6;
repeated string policies = 7;
string accessor = 1;
string secret = 2;
string name = 3;
TokenType type = 4;
google.protobuf.Timestamp create_time = 5;
google.protobuf.Timestamp expire_time = 6;
repeated string policies = 7;
}

message ACLTokenUpsertRequest {
Token token = 1;
Token token = 1;
}

message ACLTokenUpsertResponse {
bool success = 1;
bool success = 1;
}

message ACLTokenDeleteRequest {
string accessor = 1;
string accessor = 1;
}

message ACLTokenDeleteResponse {
bool success = 1;
bool success = 1;
}

message ACLTokenInfoRequest {
string accessor = 1;
string accessor = 1;
}

message ACLTokenInfoResponse {
Token token = 1;
Token token = 1;
}

message ACLTokenListResponse {
repeated Token tokens = 1;
repeated Token tokens = 1;
}

// DkronPro is the DkronPro service definition
service DkronPro {
rpc ACLPolicyUpsert (ACLPolicyUpsertRequest) returns (ACLPolicyUpsertResponse);
rpc ACLPolicyDelete (ACLPolicyDeleteRequest) returns (ACLPolicyDeleteResponse);
rpc ACLPolicyInfo (ACLPolicyInfoRequest) returns (ACLPolicyInfoResponse);
rpc ACLPolicyList (google.protobuf.Empty) returns (ACLPolicyListResponse);
rpc ACLTokenUpsert (ACLTokenUpsertRequest) returns (ACLTokenUpsertResponse);
rpc ACLTokenDelete (ACLTokenDeleteRequest) returns (ACLTokenDeleteResponse);
rpc ACLTokenInfo (ACLTokenInfoRequest) returns (ACLTokenInfoResponse);
rpc ACLTokenList (google.protobuf.Empty) returns (ACLTokenListResponse);
rpc ACLPolicyUpsert(ACLPolicyUpsertRequest) returns (ACLPolicyUpsertResponse);
rpc ACLPolicyDelete(ACLPolicyDeleteRequest) returns (ACLPolicyDeleteResponse);
rpc ACLPolicyInfo(ACLPolicyInfoRequest) returns (ACLPolicyInfoResponse);
rpc ACLPolicyList(google.protobuf.Empty) returns (ACLPolicyListResponse);
rpc ACLTokenUpsert(ACLTokenUpsertRequest) returns (ACLTokenUpsertResponse);
rpc ACLTokenDelete(ACLTokenDeleteRequest) returns (ACLTokenDeleteResponse);
rpc ACLTokenInfo(ACLTokenInfoRequest) returns (ACLTokenInfoResponse);
rpc ACLTokenList(google.protobuf.Empty) returns (ACLTokenListResponse);
}
26 changes: 15 additions & 11 deletions types/dkron.pb.go

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

2 changes: 1 addition & 1 deletion types/dkron_grpc.pb.go

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

17 changes: 11 additions & 6 deletions types/executor.pb.go

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

Loading
Loading