From cae25909f317f07697e076b6f652a8987f5e437c Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Mon, 12 Apr 2021 12:34:48 +0000 Subject: [PATCH] chore: use Go 1.16 global install command Plus add stringer tool. Signed-off-by: Alexey Palazhchenko --- Dockerfile | 11 ++++++----- Makefile | 6 ++++-- pkg/machinery/api/cluster/cluster_grpc.pb.go | 3 +-- pkg/machinery/api/health/health_grpc.pb.go | 3 +-- pkg/machinery/api/inspect/inspect_grpc.pb.go | 3 +-- pkg/machinery/api/machine/machine_grpc.pb.go | 3 +-- pkg/machinery/api/network/network_grpc.pb.go | 3 +-- pkg/machinery/api/resource/resource_grpc.pb.go | 3 +-- pkg/machinery/api/security/security_grpc.pb.go | 3 +-- pkg/machinery/api/storage/storage_grpc.pb.go | 3 +-- pkg/machinery/api/time/time_grpc.pb.go | 3 +-- 11 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index f9e292d30..9ac2134c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,10 +50,11 @@ RUN ["/toolchain/bin/ln", "-svf", "/toolchain/bin/bash", "/bin/sh"] RUN ["/toolchain/bin/ln", "-svf", "/toolchain/etc/ssl", "/etc/ssl"] RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b /toolchain/bin v1.38.0 ARG GOFUMPT_VERSION -RUN cd $(mktemp -d) \ - && go mod init tmp \ - && go get mvdan.cc/gofumpt/gofumports@${GOFUMPT_VERSION} \ +RUN go install mvdan.cc/gofumpt/gofumports@${GOFUMPT_VERSION} \ && mv /go/bin/gofumports /toolchain/go/bin/gofumports +ARG STRINGER_VERSION +RUN go install golang.org/x/tools/cmd/stringer@${STRINGER_VERSION} \ + && mv /go/bin/stringer /toolchain/go/bin/stringer RUN curl -sfL https://github.com/uber/prototool/releases/download/v1.10.0/prototool-Linux-x86_64.tar.gz | tar -xz --strip-components=2 -C /toolchain/bin prototool/bin/prototool COPY ./hack/docgen /go/src/github.com/talos-systems/docgen RUN cd /go/src/github.com/talos-systems/docgen \ @@ -119,7 +120,7 @@ RUN gofumports -w -local github.com/talos-systems/talos /api/ FROM build-go AS go-generate COPY ./pkg/machinery /pkg/machinery WORKDIR /pkg/machinery -RUN --mount=type=cache,target=/.cache go generate /pkg/machinery/config/types/v1alpha1/ +RUN --mount=type=cache,target=/.cache go generate /pkg/machinery/config/types/v1alpha1/... WORKDIR / FROM scratch AS generate @@ -133,7 +134,7 @@ COPY --from=generate-build /api/cluster/*.pb.go /pkg/machinery/api/cluster/ COPY --from=generate-build /api/storage/*.pb.go /pkg/machinery/api/storage/ COPY --from=generate-build /api/resource/*.pb.go /pkg/machinery/api/resource/ COPY --from=generate-build /api/inspect/*.pb.go /pkg/machinery/api/inspect/ -COPY --from=go-generate /pkg/machinery/config/types/v1alpha1/*_doc.go /pkg/machinery/config/types/v1alpha1/ +COPY --from=go-generate /pkg/machinery/config/types/v1alpha1/ /pkg/machinery/config/types/v1alpha1/ # The base target provides a container that can be used to build all Talos # assets. diff --git a/Makefile b/Makefile index b82180669..58c4340e0 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,8 @@ TOOLS ?= ghcr.io/talos-systems/tools:v0.5.0-alpha.0-4-g1f26def PKGS ?= v0.5.0-alpha.0-7-g98964cb EXTRAS ?= v0.3.0-alpha.0-2-gcf3934a GO_VERSION ?= 1.16 -GOFUMPT_VERSION ?= abc0db2c416aca0f60ea33c23c76665f6e7ba0b6 +GOFUMPT_VERSION ?= v0.1.0 +STRINGER_VERSION ?= v0.1.0 IMPORTVET ?= autonomy/importvet:f6b07d9 OPERATING_SYSTEM := $(shell uname -s | tr "[:upper:]" "[:lower:]") TALOSCTL_DEFAULT_TARGET := talosctl-$(OPERATING_SYSTEM) @@ -68,6 +69,7 @@ COMMON_ARGS += --build-arg=TOOLS=$(TOOLS) COMMON_ARGS += --build-arg=PKGS=$(PKGS) COMMON_ARGS += --build-arg=EXTRAS=$(EXTRAS) COMMON_ARGS += --build-arg=GOFUMPT_VERSION=$(GOFUMPT_VERSION) +COMMON_ARGS += --build-arg=STRINGER_VERSION=$(STRINGER_VERSION) COMMON_ARGS += --build-arg=TAG=$(TAG) COMMON_ARGS += --build-arg=ARTIFACTS=$(ARTIFACTS) COMMON_ARGS += --build-arg=IMPORTVET=$(IMPORTVET) @@ -240,7 +242,7 @@ cloud-images: ## Uploads cloud images (AMIs, etc.) to the cloud registry. .PHONY: fmt fmt: ## Formats the source code. - @docker run --rm -it -v $(PWD):/src -w /src golang:$(GO_VERSION) bash -c "export GO111MODULE=on; export GOPROXY=https://proxy.golang.org; cd /tmp && go mod init tmp && go get mvdan.cc/gofumpt/gofumports@$(GOFUMPT_VERSION) && cd - && gofumports -w -local github.com/talos-systems/talos ." + @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 ." lint-%: ## Runs the specified linter. Valid options are go, protobuf, and markdown (e.g. lint-go). @$(MAKE) target-lint-$* PLATFORM=linux/amd64 diff --git a/pkg/machinery/api/cluster/cluster_grpc.pb.go b/pkg/machinery/api/cluster/cluster_grpc.pb.go index ef96edc73..745c00c7c 100644 --- a/pkg/machinery/api/cluster/cluster_grpc.pb.go +++ b/pkg/machinery/api/cluster/cluster_grpc.pb.go @@ -71,8 +71,7 @@ type ClusterServiceServer interface { } // UnimplementedClusterServiceServer must be embedded to have forward compatible implementations. -type UnimplementedClusterServiceServer struct { -} +type UnimplementedClusterServiceServer struct{} func (UnimplementedClusterServiceServer) HealthCheck(*HealthCheckRequest, ClusterService_HealthCheckServer) error { return status.Errorf(codes.Unimplemented, "method HealthCheck not implemented") diff --git a/pkg/machinery/api/health/health_grpc.pb.go b/pkg/machinery/api/health/health_grpc.pb.go index 0ecd2bc5a..3f4eeb304 100644 --- a/pkg/machinery/api/health/health_grpc.pb.go +++ b/pkg/machinery/api/health/health_grpc.pb.go @@ -94,8 +94,7 @@ type HealthServer interface { } // UnimplementedHealthServer must be embedded to have forward compatible implementations. -type UnimplementedHealthServer struct { -} +type UnimplementedHealthServer struct{} func (UnimplementedHealthServer) Check(context.Context, *emptypb.Empty) (*HealthCheckResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") diff --git a/pkg/machinery/api/inspect/inspect_grpc.pb.go b/pkg/machinery/api/inspect/inspect_grpc.pb.go index 6a8ce9a25..82fca3d3a 100644 --- a/pkg/machinery/api/inspect/inspect_grpc.pb.go +++ b/pkg/machinery/api/inspect/inspect_grpc.pb.go @@ -49,8 +49,7 @@ type InspectServiceServer interface { } // UnimplementedInspectServiceServer must be embedded to have forward compatible implementations. -type UnimplementedInspectServiceServer struct { -} +type UnimplementedInspectServiceServer struct{} func (UnimplementedInspectServiceServer) ControllerRuntimeDependencies(context.Context, *emptypb.Empty) (*ControllerRuntimeDependenciesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ControllerRuntimeDependencies not implemented") diff --git a/pkg/machinery/api/machine/machine_grpc.pb.go b/pkg/machinery/api/machine/machine_grpc.pb.go index 9a37ee37d..96501c49f 100644 --- a/pkg/machinery/api/machine/machine_grpc.pb.go +++ b/pkg/machinery/api/machine/machine_grpc.pb.go @@ -739,8 +739,7 @@ type MachineServiceServer interface { } // UnimplementedMachineServiceServer must be embedded to have forward compatible implementations. -type UnimplementedMachineServiceServer struct { -} +type UnimplementedMachineServiceServer struct{} func (UnimplementedMachineServiceServer) ApplyConfiguration(context.Context, *ApplyConfigurationRequest) (*ApplyConfigurationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ApplyConfiguration not implemented") diff --git a/pkg/machinery/api/network/network_grpc.pb.go b/pkg/machinery/api/network/network_grpc.pb.go index fda5ebde7..d1a033d5c 100644 --- a/pkg/machinery/api/network/network_grpc.pb.go +++ b/pkg/machinery/api/network/network_grpc.pb.go @@ -60,8 +60,7 @@ type NetworkServiceServer interface { } // UnimplementedNetworkServiceServer must be embedded to have forward compatible implementations. -type UnimplementedNetworkServiceServer struct { -} +type UnimplementedNetworkServiceServer struct{} func (UnimplementedNetworkServiceServer) Routes(context.Context, *emptypb.Empty) (*RoutesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Routes not implemented") diff --git a/pkg/machinery/api/resource/resource_grpc.pb.go b/pkg/machinery/api/resource/resource_grpc.pb.go index e76f6ad83..a2e087508 100644 --- a/pkg/machinery/api/resource/resource_grpc.pb.go +++ b/pkg/machinery/api/resource/resource_grpc.pb.go @@ -116,8 +116,7 @@ type ResourceServiceServer interface { } // UnimplementedResourceServiceServer must be embedded to have forward compatible implementations. -type UnimplementedResourceServiceServer struct { -} +type UnimplementedResourceServiceServer struct{} func (UnimplementedResourceServiceServer) Get(context.Context, *GetRequest) (*GetResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") diff --git a/pkg/machinery/api/security/security_grpc.pb.go b/pkg/machinery/api/security/security_grpc.pb.go index 6174cb8e7..c8a6058d5 100644 --- a/pkg/machinery/api/security/security_grpc.pb.go +++ b/pkg/machinery/api/security/security_grpc.pb.go @@ -70,8 +70,7 @@ type SecurityServiceServer interface { } // UnimplementedSecurityServiceServer must be embedded to have forward compatible implementations. -type UnimplementedSecurityServiceServer struct { -} +type UnimplementedSecurityServiceServer struct{} func (UnimplementedSecurityServiceServer) Certificate(context.Context, *CertificateRequest) (*CertificateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Certificate not implemented") diff --git a/pkg/machinery/api/storage/storage_grpc.pb.go b/pkg/machinery/api/storage/storage_grpc.pb.go index 048d259c6..014eb3b42 100644 --- a/pkg/machinery/api/storage/storage_grpc.pb.go +++ b/pkg/machinery/api/storage/storage_grpc.pb.go @@ -49,8 +49,7 @@ type StorageServiceServer interface { } // UnimplementedStorageServiceServer must be embedded to have forward compatible implementations. -type UnimplementedStorageServiceServer struct { -} +type UnimplementedStorageServiceServer struct{} func (UnimplementedStorageServiceServer) Disks(context.Context, *emptypb.Empty) (*DisksResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Disks not implemented") diff --git a/pkg/machinery/api/time/time_grpc.pb.go b/pkg/machinery/api/time/time_grpc.pb.go index e0902d2cf..d3585b467 100644 --- a/pkg/machinery/api/time/time_grpc.pb.go +++ b/pkg/machinery/api/time/time_grpc.pb.go @@ -60,8 +60,7 @@ type TimeServiceServer interface { } // UnimplementedTimeServiceServer must be embedded to have forward compatible implementations. -type UnimplementedTimeServiceServer struct { -} +type UnimplementedTimeServiceServer struct{} func (UnimplementedTimeServiceServer) Time(context.Context, *emptypb.Empty) (*TimeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Time not implemented")