Fix linting issues and update make lint target.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
.vscode
|
.vscode
|
||||||
private.env
|
private.env
|
||||||
*.private.*
|
*.private.*
|
||||||
providers/azurebatch/deployment/
|
providers/azurebatch/deployment/
|
||||||
|
Dockerfile
|
||||||
|
.dockerignore
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ linter-settings:
|
|||||||
lll:
|
lll:
|
||||||
line-length: 200
|
line-length: 200
|
||||||
|
|
||||||
|
timeout: 10m
|
||||||
|
|
||||||
run:
|
run:
|
||||||
skip-dirs:
|
skip-dirs:
|
||||||
# This directory contains copy code from upstream kubernetes/kubernetes, skip it.
|
# This directory contains copy code from upstream kubernetes/kubernetes, skip it.
|
||||||
|
|||||||
18
Dockerfile
18
Dockerfile
@@ -1,3 +1,5 @@
|
|||||||
|
ARG GOLANG_CI_LINT_VERSION
|
||||||
|
|
||||||
FROM golang:1.18 as builder
|
FROM golang:1.18 as builder
|
||||||
ENV PATH /go/bin:/usr/local/go/bin:$PATH
|
ENV PATH /go/bin:/usr/local/go/bin:$PATH
|
||||||
ENV GOPATH /go
|
ENV GOPATH /go
|
||||||
@@ -7,6 +9,22 @@ ARG BUILD_TAGS=""
|
|||||||
RUN make VK_BUILD_TAGS="${BUILD_TAGS}" build
|
RUN make VK_BUILD_TAGS="${BUILD_TAGS}" build
|
||||||
RUN cp bin/virtual-kubelet /usr/bin/virtual-kubelet
|
RUN cp bin/virtual-kubelet /usr/bin/virtual-kubelet
|
||||||
|
|
||||||
|
FROM golangci/golangci-lint:${GOLANG_CI_LINT_VERSION} as lint
|
||||||
|
WORKDIR /app
|
||||||
|
COPY go.mod ./
|
||||||
|
COPY go.sum ./
|
||||||
|
RUN \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
|
go mod download
|
||||||
|
COPY . .
|
||||||
|
ARG OUT_FORMAT
|
||||||
|
RUN \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
|
--mount=type=cache,target=/root/.cache/golangci-lint \
|
||||||
|
golangci-lint run -v $(if [ -n "${OUT_FORMAT}" ]; then echo "--out-format=${OUT_FORMAT}"; fi)
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=builder /usr/bin/virtual-kubelet /usr/bin/virtual-kubelet
|
COPY --from=builder /usr/bin/virtual-kubelet /usr/bin/virtual-kubelet
|
||||||
COPY --from=builder /etc/ssl/certs/ /etc/ssl/certs
|
COPY --from=builder /etc/ssl/certs/ /etc/ssl/certs
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -183,6 +183,10 @@ envtest: kubebuilder_2.3.1_${TEST_OS}_${TEST_ARCH}
|
|||||||
fmt:
|
fmt:
|
||||||
goimports -w $(shell go list -f '{{.Dir}}' ./...)
|
goimports -w $(shell go list -f '{{.Dir}}' ./...)
|
||||||
|
|
||||||
|
|
||||||
|
export GOLANG_CI_LINT_VERSION ?= v1.48.0
|
||||||
|
DOCKER_BUILD ?= docker buildx build
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint: $(gobin_tool)
|
lint:
|
||||||
gobin -run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.33.0 run ./...
|
$(DOCKER_BUILD) --target=lint --build-arg GOLANG_CI_LINT_VERSION --build-arg OUT_FORMAT .
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ func NewMockProvider(providerConfig, nodeName, operatingSystem string, internalI
|
|||||||
|
|
||||||
// loadConfig loads the given json configuration files.
|
// loadConfig loads the given json configuration files.
|
||||||
func loadConfig(providerConfig, nodeName string) (config MockConfig, err error) {
|
func loadConfig(providerConfig, nodeName string) (config MockConfig, err error) {
|
||||||
data, err := ioutil.ReadFile(providerConfig)
|
data, err := os.ReadFile(providerConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config, err
|
return config, err
|
||||||
}
|
}
|
||||||
@@ -283,7 +283,7 @@ func (p *MockProvider) GetContainerLogs(ctx context.Context, namespace, podName,
|
|||||||
ctx = addAttributes(ctx, span, namespaceKey, namespace, nameKey, podName, containerNameKey, containerName)
|
ctx = addAttributes(ctx, span, namespaceKey, namespace, nameKey, podName, containerNameKey, containerName)
|
||||||
|
|
||||||
log.G(ctx).Infof("receive GetContainerLogs %q", podName)
|
log.G(ctx).Infof("receive GetContainerLogs %q", podName)
|
||||||
return ioutil.NopCloser(strings.NewReader("")), nil
|
return io.NopCloser(strings.NewReader("")), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunInContainer executes a command in a container in the pod, copying data
|
// RunInContainer executes a command in a container in the pod, copying data
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WithTLSConfig returns a NodeOpt which creates a base TLSConfig with the default cipher suites and tls min verions.
|
// WithTLSConfig returns a NodeOpt which creates a base TLSConfig with the default cipher suites and tls min verions.
|
||||||
@@ -31,7 +31,7 @@ func WithTLSConfig(opts ...func(*tls.Config) error) NodeOpt {
|
|||||||
// WithCAFromPath makes a TLS config option to set up client auth using the path to a PEM encoded CA cert.
|
// WithCAFromPath makes a TLS config option to set up client auth using the path to a PEM encoded CA cert.
|
||||||
func WithCAFromPath(p string) func(*tls.Config) error {
|
func WithCAFromPath(p string) func(*tls.Config) error {
|
||||||
return func(cfg *tls.Config) error {
|
return func(cfg *tls.Config) error {
|
||||||
pem, err := ioutil.ReadFile(p)
|
pem, err := os.ReadFile(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error reading ca cert pem: %w", err)
|
return fmt.Errorf("error reading ca cert pem: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user