From cec8948f25f8812b40cf5ec246c15db361a2108a Mon Sep 17 00:00:00 2001 From: Marcus Vaal Date: Thu, 13 Jun 2024 11:39:09 -0500 Subject: [PATCH] feat(pencil): Updated deprecated utilities and GitHub Actions (#66) * Updated deprecated utilities and GitHub Actions * Updated values.yaml to retrigger helm release --- .github/workflows/build_pr.yaml | 8 +++--- .github/workflows/helm_release.yaml | 27 ++++++++++--------- Dockerfile | 2 +- Makefile | 2 +- .../kubernetes-sidecar-injector/values.yaml | 2 ++ go.sum | 4 +++ pkg/admission/admission.go | 5 ++-- 7 files changed, 28 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build_pr.yaml b/.github/workflows/build_pr.yaml index 92b6746..9412f8c 100644 --- a/.github/workflows/build_pr.yaml +++ b/.github/workflows/build_pr.yaml @@ -10,20 +10,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go ^1.21 - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ^1.21 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Unit Test run: make test - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: push: false platforms: linux/amd64,linux/arm64 \ No newline at end of file diff --git a/.github/workflows/helm_release.yaml b/.github/workflows/helm_release.yaml index 304a8bc..fbbf594 100644 --- a/.github/workflows/helm_release.yaml +++ b/.github/workflows/helm_release.yaml @@ -7,20 +7,21 @@ on: jobs: release: + name: Release runs-on: ubuntu-latest steps: - id: github-repository - uses: ASzc/change-string-case-action@v2 + uses: ASzc/change-string-case-action@v6 with: string: ${{ github.repository }} - name: Set up Go ^1.21 - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ^1.21 - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} @@ -35,7 +36,7 @@ jobs: - name: Code specific changes id: code-specific-changes - uses: tj-actions/changed-files@v23 + uses: tj-actions/changed-files@v44 with: files_ignore: | charts @@ -45,7 +46,7 @@ jobs: - name: Automated Code Version Bump if: steps.code-specific-changes.outputs.any_modified == 'true' id: code-version-bump - uses: phips28/gh-action-bump-version@v9.0.27 + uses: phips28/gh-action-bump-version@v11.0.4 env: GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} with: @@ -53,18 +54,18 @@ jobs: - name: Set up Docker Buildx if: steps.code-specific-changes.outputs.any_modified == 'true' - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub if: steps.code-specific-changes.outputs.any_modified == 'true' - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_PASSWORD }} - name: Build and push merge to main if: steps.code-specific-changes.outputs.any_modified == 'true' - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: push: true tags: ${{ steps.github-repository.outputs.lowercase }}:${{ steps.code-version-bump.outputs.newTag }},${{ steps.github-repository.outputs.lowercase }}:latest @@ -72,7 +73,7 @@ jobs: - name: Get specific changed files id: helm-specific-changes - uses: tj-actions/changed-files@v23 + uses: tj-actions/changed-files@v44 with: files: | charts/kubernetes-sidecar-injector @@ -80,7 +81,7 @@ jobs: - name: Automated Helm Version Bump if: steps.helm-specific-changes.outputs.any_modified == 'true' id: helm-version-bump - uses: phips28/gh-action-bump-version@v9.0.27 + uses: phips28/gh-action-bump-version@v11.0.4 env: GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} PACKAGEJSON_DIR: charts @@ -113,18 +114,18 @@ jobs: - name: commit the new Chart.yml if: steps.helm-specific-changes.outputs.any_modified == 'true' - uses: stefanzweifel/git-auto-commit-action@v4 + uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Automated Change [skip ci] - name: Install Helm if: steps.helm-specific-changes.outputs.any_modified == 'true' - uses: azure/setup-helm@v1 + uses: azure/setup-helm@v4 with: version: v3.8.0 - name: Run chart-releaser if: steps.helm-specific-changes.outputs.any_modified == 'true' - uses: helm/chart-releaser-action@v1.3.0 + uses: helm/chart-releaser-action@v1.6.0 env: CR_TOKEN: "${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2659d70..946d16d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM golang:1.21 as build -RUN go install golang.org/x/lint/golint@latest +RUN go install honnef.co/go/tools/cmd/staticcheck@latest WORKDIR /build COPY . ./ RUN make release diff --git a/Makefile b/Makefile index d8b7222..f0ae2af 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ KIND_CLUSTER?=cluster1 SRC=$(shell find . -type f -name '*.go' -not -path "./vendor/*") lint: - go list ./... | xargs golint -min_confidence 1.0 + staticcheck ./... vet: go vet ./... diff --git a/charts/kubernetes-sidecar-injector/values.yaml b/charts/kubernetes-sidecar-injector/values.yaml index 8f7fedc..77f22c4 100644 --- a/charts/kubernetes-sidecar-injector/values.yaml +++ b/charts/kubernetes-sidecar-injector/values.yaml @@ -15,7 +15,9 @@ container: metricsPort: 9090 podAnnotations: {} + podLabels: {} + podSecurityContext: {} sidecars: diff --git a/go.sum b/go.sum index 489ba05..7506aaa 100644 --- a/go.sum +++ b/go.sum @@ -192,6 +192,7 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -236,6 +237,7 @@ github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/samber/lo v1.11.0 h1:JfeYozXL1xfkhRUFOfH13ociyeiLSC/GRJjGKI668xM= github.com/samber/lo v1.11.0/go.mod h1:2I7tgIv8Q1SG2xEIkRq0F2i2zgxVpnyPOP0d3Gj2r+A= @@ -256,6 +258,7 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M= +github.com/thoas/go-funk v0.9.1/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -606,6 +609,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= diff --git a/pkg/admission/admission.go b/pkg/admission/admission.go index 34d3212..2105d90 100644 --- a/pkg/admission/admission.go +++ b/pkg/admission/admission.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" log "github.com/sirupsen/logrus" - "io/ioutil" + "io" admissionv1 "k8s.io/api/admission/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "net/http" @@ -102,7 +102,7 @@ func validateRequest(req *http.Request) error { } func readRequestBody(req *http.Request) ([]byte, error) { - body, err := ioutil.ReadAll(req.Body) + body, err := io.ReadAll(req.Body) if err != nil { return nil, fmt.Errorf("unable to read Request Body: %v", err) } @@ -130,7 +130,6 @@ func (handler *Handler) writeDeniedAdmissionResponse(ar *admissionv1.AdmissionRe func (handler *Handler) writeErrorAdmissionReview(status int, message string, res http.ResponseWriter) { admResp := handler.errorAdmissionReview(status, message) handler.write(admResp, res) - return } func (handler *Handler) errorAdmissionReview(httpErrorCode int, message string) *admissionv1.AdmissionReview {