Skip to content

Commit

Permalink
feat(pencil): Updated deprecated utilities and GitHub Actions (#66)
Browse files Browse the repository at this point in the history
* Updated deprecated utilities and GitHub Actions 
* Updated values.yaml to retrigger helm release
  • Loading branch information
mvaalexp authored Jun 13, 2024
1 parent 74a1de1 commit cec8948
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 22 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 14 additions & 13 deletions .github/workflows/helm_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -45,42 +46,42 @@ 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:
commit-message: 'CI: Bump app version to {{version}} [skip ci]'

- 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
platforms: linux/amd64,linux/arm64

- 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
- 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
Expand Down Expand Up @@ -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 }}"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
Expand Down
2 changes: 2 additions & 0 deletions charts/kubernetes-sidecar-injector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ container:
metricsPort: 9090

podAnnotations: {}

podLabels: {}

podSecurityContext: {}

sidecars:
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand All @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
5 changes: 2 additions & 3 deletions pkg/admission/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit cec8948

Please sign in to comment.