Skip to content

Commit

Permalink
chore: format .proto files
Browse files Browse the repository at this point in the history
Refs #2722.

Co-authored-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@talos-systems.com>
  • Loading branch information
AlekSi and smira committed Nov 23, 2021
1 parent 852bf4a commit 20d39c0
Show file tree
Hide file tree
Showing 19 changed files with 312 additions and 341 deletions.
14 changes: 13 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ ARG CGO_ENABLED
ENV CGO_ENABLED ${CGO_ENABLED}
ENV GOCACHE /.cache/go-build
ENV GOMODCACHE /.cache/mod
ENV PROTOTOOL_CACHE_PATH /.cache/prototool
ARG SOURCE_DATE_EPOCH
ENV SOURCE_DATE_EPOCH ${SOURCE_DATE_EPOCH}
WORKDIR /src
Expand All @@ -144,7 +145,18 @@ RUN --mount=type=cache,target=/.cache go mod verify

# The generate target generates code from protobuf service definitions and machinery config.

# format protobuf service definitions
FROM build AS proto-format-build
WORKDIR /src/api
COPY api .
RUN --mount=type=cache,target=/.cache prototool format --overwrite --protoc-bin-path=/toolchain/bin/protoc --protoc-wkt-path=/toolchain/include

FROM --platform=${BUILDPLATFORM} scratch AS fmt-protobuf
COPY --from=proto-format-build /src/api/ /api/

# compile protobuf service definitions
FROM build AS generate-build
COPY --from=proto-format-build /src/api /api/
# Common needs to be at or near the top to satisfy the subsequent imports
COPY ./api/vendor/ /api/vendor/
COPY ./api/common/common.proto /api/common/common.proto
Expand Down Expand Up @@ -179,6 +191,7 @@ RUN --mount=type=cache,target=/.cache go generate ./...
RUN gofumports -w -local github.com/talos-systems/talos ./

FROM --platform=${BUILDPLATFORM} scratch AS generate
COPY --from=proto-format-build /src/api /api/
COPY --from=generate-build /api/common/*.pb.go /pkg/machinery/api/common/
COPY --from=generate-build /api/security/*.pb.go /pkg/machinery/api/security/
COPY --from=generate-build /api/machine/*.pb.go /pkg/machinery/api/machine/
Expand Down Expand Up @@ -627,7 +640,6 @@ RUN --mount=type=cache,target=/.cache FILES="$(gofumports -l -local github.com/t
FROM base AS lint-protobuf
WORKDIR /src/api
COPY api .
COPY prototool.yaml .
RUN prototool lint --protoc-bin-path=/toolchain/bin/protoc --protoc-wkt-path=/toolchain/include

# The markdownlint target performs linting on Markdown files.
Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,15 @@ cloud-images: ## Uploads cloud images (AMIs, etc.) to the cloud registry.

# Code Quality

.PHONY: fmt
fmt: ## Formats the source code.
fmt-go: ## Formats the source code.
@docker run --rm -it -v $(PWD):/src -w /src golang:$(GO_VERSION) bash -c "go install mvdan.cc/gofumpt/gofumports@$(GOFUMPT_VERSION) && gofumports -w -local github.com/talos-systems/talos ."

fmt-protobuf: ## Formats protobuf files.
@$(MAKE) local-fmt-protobuf DEST=./ PLATFORM=linux/amd64

fmt: ## Formats the source code and protobuf files.
@$(MAKE) fmt-go fmt-protobuf

lint-%: ## Runs the specified linter. Valid options are go, protobuf, and markdown (e.g. lint-go).
@$(MAKE) target-lint-$* PLATFORM=linux/amd64

Expand Down
8 changes: 4 additions & 4 deletions api/cluster/cluster.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ package cluster;

option go_package = "github.com/talos-systems/talos/pkg/machinery/api/cluster";

import "google/protobuf/duration.proto";
import "common/common.proto";
import "google/protobuf/duration.proto";

// The cluster service definition.
service ClusterService {
rpc HealthCheck(HealthCheckRequest) returns (stream HealthCheckProgress);
}

message HealthCheckRequest {
google.protobuf.Duration wait_timeout = 1;
ClusterInfo cluster_info = 2;
google.protobuf.Duration wait_timeout = 1;
ClusterInfo cluster_info = 2;
}

message ClusterInfo {
repeated string control_plane_nodes = 1;
repeated string control_plane_nodes = 1;
repeated string worker_nodes = 2;
string force_endpoint = 3;
}
Expand Down
12 changes: 9 additions & 3 deletions api/common/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ message Data {
bytes bytes = 2;
}

message DataResponse { repeated Data messages = 1; }
message DataResponse {
repeated Data messages = 1;
}

message Empty { Metadata metadata = 1; }
message Empty {
Metadata metadata = 1;
}

message EmptyResponse { repeated Empty messages = 1; }
message EmptyResponse {
repeated Empty messages = 1;
}

enum ContainerDriver {
CONTAINERD = 0;
Expand Down
32 changes: 16 additions & 16 deletions api/inspect/inspect.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package inspect;

option go_package = "github.com/talos-systems/talos/pkg/machinery/api/inspect";

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

// The inspect service definition.
//
Expand All @@ -16,26 +16,26 @@ service InspectService {

// The ControllerRuntimeDependency message contains the graph of controller-resource dependencies.
message ControllerRuntimeDependency {
common.Metadata metadata = 1;
repeated ControllerDependencyEdge edges = 2;
common.Metadata metadata = 1;
repeated ControllerDependencyEdge edges = 2;
}

message ControllerRuntimeDependenciesResponse { repeated ControllerRuntimeDependency messages = 1; }
message ControllerRuntimeDependenciesResponse {
repeated ControllerRuntimeDependency messages = 1;
}

enum DependencyEdgeType {
OUTPUT_EXCLUSIVE = 0;
OUTPUT_SHARED = 3;
INPUT_STRONG = 1;
INPUT_WEAK = 2;
INPUT_DESTROY_READY = 4;
OUTPUT_EXCLUSIVE = 0;
OUTPUT_SHARED = 3;
INPUT_STRONG = 1;
INPUT_WEAK = 2;
INPUT_DESTROY_READY = 4;
}

message ControllerDependencyEdge {
string controller_name = 1;

DependencyEdgeType edge_type = 2;

string resource_namespace = 3;
string resource_type = 4;
string resource_id = 5;
string controller_name = 1;
DependencyEdgeType edge_type = 2;
string resource_namespace = 3;
string resource_type = 4;
string resource_id = 5;
}

0 comments on commit 20d39c0

Please sign in to comment.