chore: use Go 1.16 global install command

Plus add stringer tool.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
This commit is contained in:
Alexey Palazhchenko 2021-04-12 12:34:48 +00:00 committed by talos-bot
parent d5e2a45db3
commit cae25909f3
11 changed files with 19 additions and 25 deletions

View File

@ -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.

View File

@ -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

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")