Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to Go 1.20 #239

Merged
merged 4 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build-images-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ jobs:
name: Build Bundle
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19.x
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.20.x
id: go
- name: Check out code
uses: actions/checkout@v3
Expand Down Expand Up @@ -147,10 +147,10 @@ jobs:
needs: [build, build-bundle]
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19.x
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.20.x
id: go
- name: Check out code
uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/code-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ jobs:
importpath: golang.org/x/tools/cmd/goimports@latest

steps:
- name: Set up Go 1.19.x
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.20.x
id: go

- name: Check out code
Expand Down Expand Up @@ -90,10 +90,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.19.x
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.20.x
id: go

- name: Check out code
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Unit Tests
strategy:
matrix:
go-version: [ 1.19.x ]
go-version: [ 1.20.x ]
platform: [ ubuntu-latest ]
runs-on: ${{ matrix.platform }}
defaults:
Expand Down Expand Up @@ -53,10 +53,10 @@ jobs:
run:
shell: bash
steps:
- name: Set up Go 1.19.x
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.20.x
id: go
- name: Check out code
uses: actions/checkout@v3
Expand Down Expand Up @@ -94,10 +94,10 @@ jobs:
name: Verify manifests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19.x
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.20.x
id: go
- name: Check out code
uses: actions/checkout@v3
Expand All @@ -109,10 +109,10 @@ jobs:
name: Verify bundle
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19.x
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.20.x
id: go
- name: Check out code
uses: actions/checkout@v3
Expand All @@ -124,10 +124,10 @@ jobs:
name: Verify fmt
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19.x
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.20.x
id: go
- name: Check out code
uses: actions/checkout@v3
Expand All @@ -139,7 +139,7 @@ jobs:
name: Test Scripts
strategy:
matrix:
go-version: [ 1.19.x ]
go-version: [ 1.20.x ]
platform: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.platform }}
defaults:
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.19 as builder
FROM golang:1.20 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ run-lint: $(GOLANGCI-LINT) ## Run lint tests
$(GOLANGCI-LINT) run

$(GOLANGCI-LINT):
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_PATH)/bin v1.50.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_PATH)/bin v1.54.2

.PHONY: golangci-lint
golangci-lint: $(GOLANGCI-LINT) ## Download golangci-lint locally if necessary.
Expand Down
6 changes: 3 additions & 3 deletions controllers/authpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (r *AuthPolicyReconciler) deleteResources(ctx context.Context, ap *api.Auth

// remove direct back ref
if targetNetworkObject != nil {
if err := r.deleteNetworkResourceDirectBackReference(ctx, ap, targetNetworkObject); err != nil {
if err := r.deleteNetworkResourceDirectBackReference(ctx, targetNetworkObject); err != nil {
return err
}
}
Expand All @@ -186,8 +186,8 @@ func (r *AuthPolicyReconciler) reconcileNetworkResourceDirectBackReference(ctx c
return r.ReconcileTargetBackReference(ctx, client.ObjectKeyFromObject(ap), targetNetworkObject, common.AuthPolicyBackRefAnnotation)
}

func (r *AuthPolicyReconciler) deleteNetworkResourceDirectBackReference(ctx context.Context, ap *api.AuthPolicy, targetNetworkObject client.Object) error {
return r.DeleteTargetBackReference(ctx, client.ObjectKeyFromObject(ap), targetNetworkObject, common.AuthPolicyBackRefAnnotation)
func (r *AuthPolicyReconciler) deleteNetworkResourceDirectBackReference(ctx context.Context, targetNetworkObject client.Object) error {
return r.DeleteTargetBackReference(ctx, targetNetworkObject, common.AuthPolicyBackRefAnnotation)
}

// SetupWithManager sets up the controller with the Manager.
Expand Down
4 changes: 2 additions & 2 deletions controllers/authpolicy_istio_authorization_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ func (r *AuthPolicyReconciler) deleteIstioAuthorizationPolicies(ctx context.Cont
}

for _, gw := range gwDiffObj.GatewaysWithInvalidPolicyRef {
listOptions := &client.ListOptions{LabelSelector: labels.SelectorFromSet(labels.Set(istioAuthorizationPolicyLabels(client.ObjectKeyFromObject(gw.Gateway), client.ObjectKeyFromObject(ap))))}
listOptions := &client.ListOptions{LabelSelector: labels.SelectorFromSet(istioAuthorizationPolicyLabels(client.ObjectKeyFromObject(gw.Gateway), client.ObjectKeyFromObject(ap)))}
iapList := &istio.AuthorizationPolicyList{}
if err := r.Client().List(ctx, iapList, listOptions); err != nil {
return err
}

for _, iap := range iapList.Items {
// it's OK to just go ahead and delete because we only create one IAP per target network object,
// and a network object can be target by no more than one AuthPolicy
// and a network object can be targeted by no more than one AuthPolicy
if err := r.DeleteResource(ctx, iap); err != nil && !apierrors.IsNotFound(err) {
logger.Error(err, "failed to delete IstioAuthorizationPolicy")
return err
Expand Down
2 changes: 1 addition & 1 deletion controllers/authpolicy_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
"github.com/kuadrant/kuadrant-operator/pkg/common"
"k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down
2 changes: 1 addition & 1 deletion controllers/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
Expand Down
28 changes: 7 additions & 21 deletions controllers/kuadrant_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ func (r *KuadrantReconciler) Reconcile(eventCtx context.Context, req ctrl.Reques
logger.V(1).Error(gwErr, "Reconciling cluster gateways failed")
}

specResult, specErr := r.reconcileSpec(ctx, kObj)
if specErr == nil && specResult.Requeue {
eguzki marked this conversation as resolved.
Show resolved Hide resolved
logger.V(1).Info("Reconciling spec not finished. Requeueing.")
return specResult, nil
}
specErr := r.reconcileSpec(ctx, kObj)

statusResult, statusErr := r.reconcileStatus(ctx, kObj, specErr)

Expand Down Expand Up @@ -356,20 +352,16 @@ func (r *KuadrantReconciler) registerServiceMeshMember(ctx context.Context, kObj
return r.ReconcileResource(ctx, &maistrav1.ServiceMeshMember{}, member, reconcilers.CreateOnlyMutator)
}

func (r *KuadrantReconciler) reconcileSpec(ctx context.Context, kObj *kuadrantv1beta1.Kuadrant) (ctrl.Result, error) {
func (r *KuadrantReconciler) reconcileSpec(ctx context.Context, kObj *kuadrantv1beta1.Kuadrant) error {
if err := r.registerExternalAuthorizer(ctx, kObj); err != nil {
return ctrl.Result{}, err
return err
}

if err := r.reconcileLimitador(ctx, kObj); err != nil {
return ctrl.Result{}, err
}

if err := r.reconcileAuthorino(ctx, kObj); err != nil {
return ctrl.Result{}, err
return err
}

return ctrl.Result{}, nil
return r.reconcileAuthorino(ctx, kObj)
}

func controlPlaneProviderName() string {
Expand Down Expand Up @@ -430,10 +422,7 @@ func (r *KuadrantReconciler) reconcileClusterGateways(ctx context.Context, kObj
}
}

if err := errGroup.Wait(); err != nil {
return err
}
return nil
return errGroup.Wait()
}

func (r *KuadrantReconciler) removeAnnotationFromGateways(ctx context.Context, kObj *kuadrantv1beta1.Kuadrant) error {
Expand Down Expand Up @@ -461,10 +450,7 @@ func (r *KuadrantReconciler) removeAnnotationFromGateways(ctx context.Context, k
})
}

if err := errGroup.Wait(); err != nil {
return err
}
return nil
return errGroup.Wait()
}

func (r *KuadrantReconciler) reconcileLimitador(ctx context.Context, kObj *kuadrantv1beta1.Kuadrant) error {
Expand Down
4 changes: 2 additions & 2 deletions controllers/kuadrant_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -88,7 +88,7 @@ func (r *KuadrantReconciler) readyCondition(ctx context.Context, kObj *kuadrantv

if specErr != nil {
cond.Status = metav1.ConditionFalse
cond.Reason = "ReconcilliationError"
cond.Reason = "ReconciliationError"
cond.Message = specErr.Error()
return cond, nil
}
Expand Down
6 changes: 3 additions & 3 deletions controllers/ratelimitpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (r *RateLimitPolicyReconciler) deleteResources(ctx context.Context, rlp *ku

// remove direct back ref
if targetNetworkObject != nil {
if err := r.deleteNetworkResourceDirectBackReference(ctx, rlp, targetNetworkObject); err != nil {
if err := r.deleteNetworkResourceDirectBackReference(ctx, targetNetworkObject); err != nil {
return err
}
}
Expand All @@ -225,8 +225,8 @@ func (r *RateLimitPolicyReconciler) reconcileNetworkResourceDirectBackReference(
return r.ReconcileTargetBackReference(ctx, client.ObjectKeyFromObject(policy), targetNetworkObject, common.RateLimitPolicyBackRefAnnotation)
}

func (r *RateLimitPolicyReconciler) deleteNetworkResourceDirectBackReference(ctx context.Context, rlp *kuadrantv1beta2.RateLimitPolicy, targetNetworkObject client.Object) error {
return r.DeleteTargetBackReference(ctx, client.ObjectKeyFromObject(rlp), targetNetworkObject, common.RateLimitPolicyBackRefAnnotation)
func (r *RateLimitPolicyReconciler) deleteNetworkResourceDirectBackReference(ctx context.Context, targetNetworkObject client.Object) error {
return r.DeleteTargetBackReference(ctx, targetNetworkObject, common.RateLimitPolicyBackRefAnnotation)
}

// SetupWithManager sets up the controller with the Manager.
Expand Down
6 changes: 3 additions & 3 deletions controllers/ratelimitpolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ func testBuildBasicGateway(gwName, ns string) *gatewayapiv1beta1.Gateway {
Annotations: map[string]string{"networking.istio.io/service-type": string(corev1.ServiceTypeClusterIP)},
},
Spec: gatewayapiv1beta1.GatewaySpec{
GatewayClassName: gatewayapiv1beta1.ObjectName("istio"),
GatewayClassName: "istio",
Listeners: []gatewayapiv1beta1.Listener{
{
Name: gatewayapiv1beta1.SectionName("default"),
Name: "default",
Port: gatewayapiv1beta1.PortNumber(80),
Protocol: gatewayapiv1beta1.ProtocolType("HTTP"),
Protocol: "HTTP",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion controllers/ratelimitpolicy_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/go-logr/logr"
apierrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down
2 changes: 1 addition & 1 deletion doc/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* [operator-sdk] version v1.28.1
* [kind] version v0.20.0
* [git][git_tool]
* [go] version 1.19+
* [go] version 1.20+
* [kubernetes] version v1.19+
* [kubectl] version v1.19+

Expand Down
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/kuadrant/kuadrant-operator

go 1.19
go 1.20

require (
github.com/elliotchance/orderedmap/v2 v2.2.0
Expand Down
7 changes: 3 additions & 4 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
// TODO: move the const to a proper place, or get it from config
const (
KuadrantRateLimitClusterName = "kuadrant-rate-limiting-service"
HTTPRouteKind = "HTTPRoute"
RateLimitPoliciesBackRefAnnotation = "kuadrant.io/ratelimitpolicies"
RateLimitPolicyBackRefAnnotation = "kuadrant.io/ratelimitpolicy"
AuthPoliciesBackRefAnnotation = "kuadrant.io/authpolicies"
Expand Down Expand Up @@ -238,7 +237,7 @@ func UnMarshallObjectKey(keyStr string) (client.ObjectKey, error) {
return client.ObjectKey{Namespace: keyStr[:namespaceEndIndex], Name: keyStr[namespaceEndIndex+1:]}, nil
}

// HostnamesToStrings converts []gatewayapi_v1alpha2.Hostname to []string
// HostnamesToStrings converts []gatewayapiv1beta1.Hostname to []string
func HostnamesToStrings(hostnames []gatewayapiv1beta1.Hostname) []string {
return Map(hostnames, func(hostname gatewayapiv1beta1.Hostname) string {
return string(hostname)
Expand All @@ -249,8 +248,8 @@ func HostnamesToStrings(hostnames []gatewayapiv1beta1.Hostname) []string {
// is a subset of at least one of the domains.
// Domains and subdomains may be prefixed with a wildcard label (*.).
// The wildcard label must appear by itself as the first label.
// When one of the subdomains is not a subset of any of the domains, it returns false and
// the subdomain not being subset of any of the domains
// When one of the subdomains is not a subset of the domains, it returns false and
// the subdomain not being subset of the domains
func ValidSubdomains(domains, subdomains []string) (bool, string) {
for _, subdomain := range subdomains {
validSubdomain := false
Expand Down
Loading