Skip to content

Commit

Permalink
bump linter version and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexei-led committed Dec 14, 2021
1 parent e7f9b79 commit 5412183
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 316 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#
# ----- Go Builder Image ------
#
FROM --platform=${BUILDPLATFORM} golang:1.16-alpine AS builder
FROM --platform=${BUILDPLATFORM} golang:1.17-alpine AS builder

# curl git bash
RUN apk add --no-cache curl git bash make tzdata ca-certificates
COPY --from=golangci/golangci-lint:v1.39-alpine /usr/bin/golangci-lint /usr/bin
COPY --from=golangci/golangci-lint:v1.43-alpine /usr/bin/golangci-lint /usr/bin

#
# ----- Build and Test Image -----
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ platfrom-build: clean lint test ; $(info $(M) building binaries for multiple os/
setup-tools: setup-lint setup-gocov setup-gocov-xml setup-go2xunit setup-mockery setup-ghr

setup-lint:
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.39
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43
setup-gocov:
$(GO) install github.com/axw/gocov/...
setup-gocov-xml:
Expand Down
14 changes: 4 additions & 10 deletions cmd/secrets-init-webhook/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"strings"

dockerTypes "github.com/docker/docker/api/types"
Expand Down Expand Up @@ -122,7 +122,7 @@ func getImageBlob(container *ContainerInfo, registrySkipVerify bool) (*imagev1.I
return nil, fmt.Errorf("cannot download blob: %s", err.Error())
}

b, err := ioutil.ReadAll(reader)
b, err := io.ReadAll(reader)
if err != nil {
return nil, fmt.Errorf("cannot read blob: %s", err.Error())
}
Expand Down Expand Up @@ -188,10 +188,7 @@ func (k *ContainerInfo) readDockerSecret(ctx context.Context, namespace, secretN

func (k *ContainerInfo) parseDockerConfig(dockerCreds DockerCreds) (bool, error) {
for registryName, registryAuth := range dockerCreds.Auths {
if strings.HasPrefix(registryName, "https://") {
registryName = strings.TrimPrefix(registryName, "https://")
}

registryName = strings.TrimPrefix(registryName, "https://")
registryName = strings.TrimSuffix(registryName, "/")

if strings.HasPrefix(k.Image, registryName) {
Expand Down Expand Up @@ -309,10 +306,7 @@ func (k *ContainerInfo) Collect(container *corev1.Container, podSpec *corev1.Pod
// In case of other public docker registry
if k.RegistryName == "" && k.RegistryAddress == "" {
registryName := container.Image
if strings.HasPrefix(registryName, "https://") {
registryName = strings.TrimPrefix(registryName, "https://")
}

registryName = strings.TrimPrefix(registryName, "https://")
registryName = strings.Split(registryName, "/")[0]
k.RegistryName = registryName
k.RegistryAddress = fmt.Sprintf("https://%s", registryName)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/doitintl/kube-secrets-init
go 1.16

require (
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/heroku/docker-registry-client v0.0.0-20190909225348-afc9e1acc3d5
github.com/opencontainers/image-spec v1.0.1
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.10.0
github.com/sirupsen/logrus v1.8.1
github.com/slok/kubewebhook/v2 v2.0.0
Expand Down
Loading

0 comments on commit 5412183

Please sign in to comment.