Skip to content

Commit

Permalink
chore: update golang x tools version
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Apr 9, 2024
1 parent a761bf3 commit 489231f
Show file tree
Hide file tree
Showing 49 changed files with 3,797 additions and 1,379 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-reloader-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
build-reloader-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get reloader image version
id: version
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: minikube start
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update helm
run: |
helm repo add emqx https://repos.emqx.io/charts
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/cts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
echo "KUBECONFIG=/etc/rancher/k3s/k3s.yaml" >> $GITHUB_ENV
- if: matrix.kubernetes-env == 'minikube'
run: minikube start --kubernetes-version="${{ matrix.kubernetes-version }}"
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
- name: install kubebuilder
run: |
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
Expand All @@ -58,7 +58,7 @@ jobs:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v2
- uses: docker/setup-qemu-action@v2
with:
Expand Down Expand Up @@ -124,10 +124,10 @@ jobs:
echo "KUBECONFIG=/etc/rancher/k3s/k3s.yaml" >> $GITHUB_ENV
- if: matrix.kubernetes-env == 'minikube'
run: minikube start --kubernetes-version="${{ matrix.kubernetes-version }}"
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
- name: Deploy operator
timeout-minutes: 5
uses: ./.github/actions/deploy-operator
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ jobs:
--namespace cert-manager \
--create-namespace \
--set installCRDs=true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: '1.20'
- uses: actions/checkout@v3
go-version: '1.21'
- uses: actions/checkout@v4
- name: Build image
env:
IMG: "emqx/emqx-operator-controller:${{ github.sha }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install gitlint
run: |
sudo apt-get update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
helm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get tag
id: get_tag
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Check helm
run: |
version=$(grep -E "^version" deploy/charts/emqx-operator/Chart.yaml | grep -oE "[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)\.[0-9])?")
Expand Down
26 changes: 12 additions & 14 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ jobs:
e2e: ${{ steps.e2e.outputs.e2e }}

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
- uses: golangci/golangci-lint-action@v3
go-version: '1.21'
- uses: golangci/golangci-lint-action@v4
with:
## TODO: https://github.com/golangci/golangci-lint-action/issues/759
version: v1.52.2
args: --timeout=5m
- run: go install github.com/google/go-licenses@latest
- run: $(go env GOPATH)/bin/go-licenses check . --disallowed_types forbidden,restricted,unknown
Expand Down Expand Up @@ -77,10 +75,10 @@ jobs:

steps:
- run: minikube start
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
- run: go install github.com/onsi/ginkgo/v2/ginkgo@latest
- name: Install Telepresence
env:
Expand All @@ -98,7 +96,7 @@ jobs:
filename="$(basename $FILE)"
filename="${filename%.*}"
$(go env GOPATH)/bin/ginkgo -v --cover -covermode=atomic -coverpkg=./... -coverprofile=${filename}.out --focus-file=${filename} $(dirname $FILE)
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: coverprofile
path: |
Expand All @@ -107,12 +105,12 @@ jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
- run: make test
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: coverprofile
path: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
--namespace cert-manager \
--create-namespace \
--set installCRDs=true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: '1.20'
- uses: actions/checkout@v3
go-version: '1.21'
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get pre stable version
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.20.3 as builder
FROM golang:1.21 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
22 changes: 11 additions & 11 deletions apis/apps/v1beta3/emqxbroker_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var v1bete3EmqxBroker = &EmqxBroker{
Expand All @@ -40,7 +40,7 @@ var v1bete3EmqxBroker = &EmqxBroker{
},
},
Spec: EmqxBrokerSpec{
Replicas: pointer.Int32(3),
Replicas: ptr.To(int32(3)),
Env: []corev1.EnvVar{
{
Name: "foo",
Expand Down Expand Up @@ -77,7 +77,7 @@ var v1bete3EmqxBroker = &EmqxBroker{
},
},
Persistent: corev1.PersistentVolumeClaimSpec{
StorageClassName: pointer.String("foo"),
StorageClassName: ptr.To("foo"),
},
InitContainers: []corev1.Container{
{
Expand All @@ -97,9 +97,9 @@ var v1bete3EmqxBroker = &EmqxBroker{
ACL: []string{"allow, all."},
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &corev1.PodSecurityContext{
RunAsUser: pointer.Int64(1000),
RunAsGroup: pointer.Int64(1000),
FSGroup: pointer.Int64(1000),
RunAsUser: ptr.To(int64(1000)),
RunAsGroup: ptr.To(int64(1000)),
FSGroup: ptr.To(int64(1000)),
FSGroupChangePolicy: &[]corev1.PodFSGroupChangePolicy{corev1.FSGroupChangeAlways}[0],
},
ExtraVolumes: []corev1.Volume{
Expand Down Expand Up @@ -202,10 +202,10 @@ var v1beta4EmqxBroker = &v1beta4.EmqxBroker{
},
},
Spec: v1beta4.EmqxBrokerSpec{
Replicas: pointer.Int32(3),
Replicas: ptr.To(int32(3)),
Persistent: &corev1.PersistentVolumeClaimTemplate{
Spec: corev1.PersistentVolumeClaimSpec{
StorageClassName: pointer.String("foo"),
StorageClassName: ptr.To("foo"),
},
},
Template: v1beta4.EmqxTemplate{
Expand Down Expand Up @@ -333,9 +333,9 @@ var v1beta4EmqxBroker = &v1beta4.EmqxBroker{
},
},
PodSecurityContext: &corev1.PodSecurityContext{
RunAsUser: pointer.Int64(1000),
RunAsGroup: pointer.Int64(1000),
FSGroup: pointer.Int64(1000),
RunAsUser: ptr.To(int64(1000)),
RunAsGroup: ptr.To(int64(1000)),
FSGroup: ptr.To(int64(1000)),
FSGroupChangePolicy: &[]corev1.PodFSGroupChangePolicy{corev1.FSGroupChangeAlways}[0],
},
},
Expand Down
22 changes: 11 additions & 11 deletions apis/apps/v1beta3/emqxenterprise_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var v1bete3EmqxEnterprise = &EmqxEnterprise{
Expand All @@ -40,7 +40,7 @@ var v1bete3EmqxEnterprise = &EmqxEnterprise{
},
},
Spec: EmqxEnterpriseSpec{
Replicas: pointer.Int32(3),
Replicas: ptr.To(int32(3)),
Env: []corev1.EnvVar{
{
Name: "foo",
Expand Down Expand Up @@ -77,7 +77,7 @@ var v1bete3EmqxEnterprise = &EmqxEnterprise{
},
},
Persistent: corev1.PersistentVolumeClaimSpec{
StorageClassName: pointer.String("foo"),
StorageClassName: ptr.To("foo"),
},
InitContainers: []corev1.Container{
{
Expand All @@ -100,9 +100,9 @@ var v1bete3EmqxEnterprise = &EmqxEnterprise{
ACL: []string{"allow, all."},
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &corev1.PodSecurityContext{
RunAsUser: pointer.Int64(1000),
RunAsGroup: pointer.Int64(1000),
FSGroup: pointer.Int64(1000),
RunAsUser: ptr.To(int64(1000)),
RunAsGroup: ptr.To(int64(1000)),
FSGroup: ptr.To(int64(1000)),
FSGroupChangePolicy: &[]corev1.PodFSGroupChangePolicy{corev1.FSGroupChangeAlways}[0],
},
ExtraVolumes: []corev1.Volume{
Expand Down Expand Up @@ -205,13 +205,13 @@ var v1beta4EmqxEnterprise = &v1beta4.EmqxEnterprise{
},
},
Spec: v1beta4.EmqxEnterpriseSpec{
Replicas: pointer.Int32(3),
Replicas: ptr.To(int32(3)),
License: v1beta4.EmqxLicense{
SecretName: "fake-license-secret",
},
Persistent: &corev1.PersistentVolumeClaimTemplate{
Spec: corev1.PersistentVolumeClaimSpec{
StorageClassName: pointer.String("foo"),
StorageClassName: ptr.To("foo"),
},
},
Template: v1beta4.EmqxTemplate{
Expand Down Expand Up @@ -339,9 +339,9 @@ var v1beta4EmqxEnterprise = &v1beta4.EmqxEnterprise{
},
},
PodSecurityContext: &corev1.PodSecurityContext{
RunAsUser: pointer.Int64(1000),
RunAsGroup: pointer.Int64(1000),
FSGroup: pointer.Int64(1000),
RunAsUser: ptr.To(int64(1000)),
RunAsGroup: ptr.To(int64(1000)),
FSGroup: ptr.To(int64(1000)),
FSGroupChangePolicy: &[]corev1.PodFSGroupChangePolicy{corev1.FSGroupChangeAlways}[0],
},
},
Expand Down
17 changes: 9 additions & 8 deletions apis/apps/v1beta4/emqxbroker_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand Down Expand Up @@ -64,19 +65,19 @@ func (r *EmqxBroker) Default() {
var _ webhook.Validator = &EmqxBroker{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *EmqxBroker) ValidateCreate() error {
func (r *EmqxBroker) ValidateCreate() (admission.Warnings, error) {
emqxbrokerlog.Info("validate create", "name", r.Name)

if err := validateImageVersion(r, nil); err != nil {
emqxbrokerlog.Error(err, "validate create failed")
return err
return nil, err
}

return nil
return nil, nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *EmqxBroker) ValidateUpdate(old runtime.Object) error {
func (r *EmqxBroker) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
emqxbrokerlog.Info("validate update", "name", r.Name)

callbacks := []func(new, old Emqx) error{
Expand All @@ -88,17 +89,17 @@ func (r *EmqxBroker) ValidateUpdate(old runtime.Object) error {
for _, cb := range callbacks {
if err := cb(r, old.(*EmqxBroker)); err != nil {
emqxbrokerlog.Error(err, "validate create failed")
return err
return nil, err
}
}
return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *EmqxBroker) ValidateDelete() error {
func (r *EmqxBroker) ValidateDelete() (admission.Warnings, error) {
emqxbrokerlog.Info("validate delete", "name", r.Name)

return nil
return nil, nil
}

func defaultLabelsAndAnnotations(r Emqx) {
Expand Down
Loading

0 comments on commit 489231f

Please sign in to comment.