Skip to content

Commit

Permalink
deps bump go to 1.19
Browse files Browse the repository at this point in the history
Signed-off-by: Enrique Llorente <[email protected]>
  • Loading branch information
qinqon committed Sep 7, 2023
1 parent 7cbda25 commit 6aa4c8f
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 35 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- uses: arnested/go-version-action@v1
id: go-version
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v1
uses: actions/setup-go@v4
with:
go-version: ${{ steps.go-version.outputs.minimal }}
go-version-file: "go.mod"
- name: Run lint
run: make lint
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: arnested/go-version-action@v1
id: go-version
- name: Install Go ${{ steps.go-version.outputs.minimal }}
uses: actions/setup-go@v2
- name: Check out code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ steps.go-version.outputs.minimal }}
go-version-file: "go.mod"
- name: Run unit test
run: make test
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
Expand All @@ -104,11 +102,9 @@ linters:
- nolintlint
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/qinqon/kube-admission-webhook

go 1.17
go 1.19

require (
github.com/github-release/github-release v0.10.0
Expand Down
2 changes: 1 addition & 1 deletion hack/lint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -xe

version=v1.42.1
version=v1.53.3
timeout=5m

go run github.com/golangci/golangci-lint/cmd/golangci-lint@$version run --timeout $timeout
Expand Down
1 change: 1 addition & 0 deletions pkg/certificate/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"

"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down
20 changes: 11 additions & 9 deletions pkg/certificate/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,17 @@ type Manager struct {
// It will also starts at cert manager [1] that will update them if they expire.
// The generate certificate include the following fields:
// DNSNames (for every service the webhook refers too):
// - ${service.Name}
// - ${service.Name}.${service.namespace}
// - ${service.Name}.${service.namespace}.svc
// - ${service.Name}
// - ${service.Name}.${service.namespace}
// - ${service.Name}.${service.namespace}.svc
//
// Subject:
// - CN: ${webhookName}
// - CN: ${webhookName}
//
// Usages:
// - UsageDigitalSignature
// - UsageKeyEncipherment
// - UsageServerAuth
// - UsageDigitalSignature
// - UsageKeyEncipherment
// - UsageServerAuth
//
// It will also update the webhook caBundle field with the cluster CA cert and
// approve the generated cert/key with k8s certification approval mechanism
Expand Down Expand Up @@ -307,7 +309,7 @@ func (m *Manager) nextRotationDeadlineForCert(certificate *x509.Certificate, ove
}

func (m *Manager) elapsedToRotateCAFromLastDeadline() time.Duration {
deadline := m.now()
deadline := m.now() //nolint:staticcheck // lint mark it as unused

// If deadline was previously calculated return it, else do the
// calculations
Expand All @@ -323,7 +325,7 @@ func (m *Manager) elapsedToRotateCAFromLastDeadline() time.Duration {
}

func (m *Manager) elapsedToRotateServicesFromLastDeadline() time.Duration {
deadline := m.now()
deadline := m.now() //nolint:staticcheck // lint mark it as unused

// If deadline was previously calculated return it, else do the
// calculations
Expand Down
2 changes: 1 addition & 1 deletion pkg/certificate/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (m *Manager) getTLSCerts(secretKey types.NamespacedName) ([]*x509.Certifica
return certs, nil
}

//FIXME: Is this default/webhookname good key for ca secret
// FIXME: Is this default/webhookname good key for ca secret
func (m *Manager) caSecretKey() types.NamespacedName {
return types.NamespacedName{Namespace: m.namespace, Name: m.webhookName + "-ca"}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var (
}()
)

func init() { // nolint:gochecknoinits
func init() { //nolint:gochecknoinits
metrics.Registry.MustRegister(RequestLatency, RequestTotal, RequestInFlight)
}

Expand Down
5 changes: 2 additions & 3 deletions pkg/webhook/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -295,7 +294,7 @@ func (s *Server) Start(ctx context.Context) error {
if s.ClientCAName != "" {
certPool := x509.NewCertPool()
var clientCABytes []byte
clientCABytes, err = ioutil.ReadFile(filepath.Join(s.CertDir, s.ClientCAName))
clientCABytes, err = os.ReadFile(filepath.Join(s.CertDir, s.ClientCAName))
if err != nil {
return fmt.Errorf("failed to read client CA cert: %v", err)
}
Expand Down Expand Up @@ -346,7 +345,7 @@ func (s *Server) Start(ctx context.Context) error {
// server has been started.
func (s *Server) StartedChecker() healthz.Checker {
config := &tls.Config{
InsecureSkipVerify: true, // nolint:gosec // config is used to connect to our own webhook port.
InsecureSkipVerify: true, //nolint:gosec // config is used to connect to our own webhook port.
}
return func(req *http.Request) error {
s.mu.Lock()
Expand Down
8 changes: 4 additions & 4 deletions pkg/webhook/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package webhook_test
import (
"context"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"

Expand Down Expand Up @@ -123,7 +123,7 @@ var _ = Describe("Webhook Server", func() {
resp, err := client.Get(fmt.Sprintf("https://%s/somepath", testHostPort))
Expect(err).NotTo(HaveOccurred())
defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
return io.ReadAll(resp.Body)
}).Should(Equal([]byte("gadzooks!")))

Expect(server.StartedChecker()(nil)).To(Succeed())
Expand Down Expand Up @@ -163,7 +163,7 @@ var _ = Describe("Webhook Server", func() {
Expect(err).NotTo(HaveOccurred())
defer resp.Body.Close()

Expect(ioutil.ReadAll(resp.Body)).To(Equal([]byte("gadzooks!")))
Expect(io.ReadAll(resp.Body)).To(Equal([]byte("gadzooks!")))
})

It("should inject dependencies, if an inject func has been provided already", func() {
Expand All @@ -188,7 +188,7 @@ var _ = Describe("Webhook Server", func() {
resp, err := client.Get(fmt.Sprintf("https://%s/somepath", testHostPort))
Expect(err).NotTo(HaveOccurred())
defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
return io.ReadAll(resp.Body)
}).Should(Equal([]byte("gadzooks!")))

ctxCancel()
Expand Down

0 comments on commit 6aa4c8f

Please sign in to comment.