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

THREESCALE-10882 Managed services sync #213

Merged
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ commands:
jobs:
install-operator:
docker:
- image: cimg/go:1.19
- image: cimg/go:1.20
steps:
- setup_remote_docker:
docker_layer_caching: true
Expand All @@ -54,7 +54,7 @@ jobs:
- image: circleci/ruby:2.6
steps:
- go/install:
version: 1.19.10
version: '1.20.14'
- checkout
- run: sudo gem install license_finder --version 5.7.1
- run: make licenses-check
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:

run-unit-test:
docker:
- image: cimg/go:1.19
- image: cimg/go:1.20
steps:
- checkout
- run:
Expand All @@ -122,7 +122,7 @@ jobs:
docker_layer_caching: true
steps:
- go/install:
version: 1.19.10
version: '1.20.14'
- checkout
- run:
name: Install KinD
Expand All @@ -139,7 +139,7 @@ jobs:
no_output_timeout: 30m
lint:
docker:
- image: cimg/go:1.19
- image: cimg/go:1.20
steps:
- checkout
- run:
Expand All @@ -149,7 +149,7 @@ jobs:

bundle-validate:
docker:
- image: cimg/go:1.19
- image: cimg/go:1.20
steps:
- checkout
- run: make bundle
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ test-unit: generate fmt vet manifests ## Run Unit tests.
# 3) Timeout waiting for process kube-apiserver to stop https://github.com/kubernetes-sigs/controller-runtime/issues/1571
test-integration: export USE_EXISTING_CLUSTER=true
test-integration: generate fmt vet manifests ## Run Integration tests.
go test ./... -tags integration -ginkgo.v -ginkgo.progress -v -timeout 600s
go test ./... -tags integration -ginkgo.v -v -timeout 600s

.PHONY: bundle-validate
bundle-validate: $(OPERATOR_SDK)
Expand Down Expand Up @@ -222,7 +222,7 @@ bundle-run: $(OPERATOR_SDK)
GOLANGCI-LINT=$(PROJECT_PATH)/bin/golangci-lint
$(GOLANGCI-LINT):
mkdir -p $(PROJECT_PATH)/bin
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.52.2

.PHONY: golangci-lint
golangci-lint: $(GOLANGCI-LINT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ spec:
com.company: Red_Hat
control-plane: controller-manager
rht.comp: 3scale_apicast
rht.comp_ver: "2.14"
rht.comp_ver: "2.15"
rht.prod_name: Red_Hat_Integration
rht.prod_ver: master
rht.subcomp: apicast_operator
Expand Down
25 changes: 20 additions & 5 deletions bundle/manifests/apps.3scale.net_apicasts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ spec:
type: string
tls:
items:
description: IngressTLS describes the transport layer security associated with an Ingress.
description: IngressTLS describes the transport layer security associated with an ingress.
properties:
hosts:
description: Hosts are a list of hosts included in the TLS certificate. The values in this list must match the name/s used in the tlsSecret. Defaults to the wildcard host setting for the loadbalancer controller fulfilling this Ingress, if left unspecified.
description: hosts is a list of hosts included in the TLS certificate. The values in this list must match the name/s used in the tlsSecret. Defaults to the wildcard host setting for the loadbalancer controller fulfilling this Ingress, if left unspecified.
items:
type: string
type: array
x-kubernetes-list-type: atomic
secretName:
description: SecretName is the name of the secret used to terminate TLS traffic on port 443. Field is left optional to allow TLS routing based on SNI hostname alone. If the SNI host in a listener conflicts with the "Host" header field used by an IngressRule, the SNI host is used for termination and value of the Host header is used for routing.
description: secretName is the name of the secret used to terminate TLS traffic on port 443. Field is left optional to allow TLS routing based on SNI hostname alone. If the SNI host in a listener conflicts with the "Host" header field used by an IngressRule, the SNI host is used for termination and value of the "Host" header is used for routing.
type: string
type: object
type: array
Expand Down Expand Up @@ -267,6 +267,21 @@ spec:
resources:
description: Resources can be used to set custom compute Kubernetes Resource Requirements for the APIcast deployment.
properties:
claims:
description: "Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. \n This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. \n This field is immutable. It can only be set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: Name must match the name of one entry in pod.spec.resourceClaims of the Pod where this field is used. It makes that resource available inside a container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
Expand All @@ -283,7 +298,7 @@ spec:
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
responseCodesIncluded:
Expand Down Expand Up @@ -335,7 +350,7 @@ spec:
conditions:
description: 'Represents the observations of a foo''s current state. Known .status.conditions.type are: "Available"'
items:
description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, \n type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
Expand Down
37 changes: 30 additions & 7 deletions config/crd/bases/apps.3scale.net_apicasts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ spec:
tls:
items:
description: IngressTLS describes the transport layer security
associated with an Ingress.
associated with an ingress.
properties:
hosts:
description: Hosts are a list of hosts included in the TLS
description: hosts is a list of hosts included in the TLS
certificate. The values in this list must match the name/s
used in the tlsSecret. Defaults to the wildcard host setting
for the loadbalancer controller fulfilling this Ingress,
Expand All @@ -171,12 +171,13 @@ spec:
type: array
x-kubernetes-list-type: atomic
secretName:
description: SecretName is the name of the secret used to
description: secretName is the name of the secret used to
terminate TLS traffic on port 443. Field is left optional
to allow TLS routing based on SNI hostname alone. If the
SNI host in a listener conflicts with the "Host" header
field used by an IngressRule, the SNI host is used for
termination and value of the Host header is used for routing.
termination and value of the "Host" header is used for
routing.
type: string
type: object
type: array
Expand Down Expand Up @@ -341,6 +342,27 @@ spec:
description: Resources can be used to set custom compute Kubernetes
Resource Requirements for the APIcast deployment.
properties:
claims:
description: "Claims lists the names of resources, defined in
spec.resourceClaims, that are used by this container. \n This
is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable. It can only be set
for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: Name must match the name of one entry in pod.spec.resourceClaims
of the Pod where this field is used. It makes that resource
available inside a container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
Expand All @@ -361,7 +383,8 @@ spec:
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
to an implementation-defined value. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
responseCodesIncluded:
Expand Down Expand Up @@ -429,8 +452,8 @@ spec:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
type FooStatus struct{ // Represents the observations of a foo's
current state. // Known .status.conditions.type are: \"Available\",
\n type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
Expand Down
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
rht.prod_name: Red_Hat_Integration
rht.prod_ver: master
rht.comp: 3scale_apicast
rht.comp_ver: 2.14
rht.comp_ver: 2.15
rht.subcomp: apicast_operator
rht.subcomp_t: infrastructure
spec:
Expand Down
10 changes: 4 additions & 6 deletions controllers/apps/apicast_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import (
"context"
"encoding/json"

appsv1alpha1 "github.com/3scale/apicast-operator/apis/apps/v1alpha1"
"github.com/3scale/apicast-operator/pkg/reconcilers"
"github.com/go-logr/logr"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/api/errors"
apimachinerymetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -32,10 +33,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

appsv1alpha1 "github.com/3scale/apicast-operator/apis/apps/v1alpha1"
"github.com/3scale/apicast-operator/pkg/reconcilers"
)

// APIcastReconciler reconciles a APIcast object
Expand Down Expand Up @@ -124,6 +121,7 @@ func (r *APIcastReconciler) Reconcile(eventCtx context.Context, req ctrl.Request

func (r *APIcastReconciler) SetupWithManager(mgr ctrl.Manager) error {
secretToApicastEventMapper := &SecretToApicastEventMapper{
Context: context.TODO(),
K8sClient: r.Client(),
Logger: r.Log.WithName("secretToApicastEventMapper"),
Namespace: r.WatchedNamespace,
Expand All @@ -142,7 +140,7 @@ func (r *APIcastReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&appsv1alpha1.APIcast{}).
Watches(
&source.Kind{Type: &v1.Secret{}},
&corev1.Secret{},
handler.EnqueueRequestsFromMapFunc(secretToApicastEventMapper.Map),
builder.WithPredicates(labelSelectorPredicate),
).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

appsv1alpha1 "github.com/3scale/apicast-operator/apis/apps/v1alpha1"
"github.com/3scale/apicast-operator/pkg/apicast"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/apicast_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
Expand Down
5 changes: 3 additions & 2 deletions controllers/apps/secret_to_apicast_event_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import (

// SecretToApicastEventMapper is an EventHandler that maps secret object to apicast CR's
type SecretToApicastEventMapper struct {
Context context.Context
K8sClient client.Client
Logger logr.Logger
Namespace string
}

func (s *SecretToApicastEventMapper) Map(obj client.Object) []reconcile.Request {
func (s *SecretToApicastEventMapper) Map(ctx context.Context, obj client.Object) []reconcile.Request {
apicastList := &appsv1alpha1.APIcastList{}

// filter by Secret UID
Expand All @@ -29,7 +30,7 @@ func (s *SecretToApicastEventMapper) Map(obj client.Object) []reconcile.Request
opts = append(opts, client.InNamespace(s.Namespace))
}

err := s.K8sClient.List(context.Background(), apicastList, opts...)
err := s.K8sClient.List(ctx, apicastList, opts...)
if err != nil {
s.Logger.Error(err, "reading apicast list")
return nil
Expand Down
11 changes: 3 additions & 8 deletions controllers/apps/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ import (
"path/filepath"
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

Expand All @@ -49,10 +48,7 @@ func testClient() client.Client { return k8sClient }

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
RunSpecs(t, "Controller Suite")
}

var _ = BeforeSuite(func() {
Expand Down Expand Up @@ -94,8 +90,7 @@ var _ = BeforeSuite(func() {
err = mgr.Start(ctrl.SetupSignalHandler())
Expect(err).ToNot(HaveOccurred())
}()

}, 60)
})

var _ = AfterSuite(func() {
By("tearing down the test environment")
Expand Down
2 changes: 1 addition & 1 deletion doc/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* [operator-sdk] version v1.2.0
* [docker] version 17.03+
* [git][git_tool]
* [go] version 1.19
* [go] version 1.20
* [kubernetes] version v1.22.1+
* [kubectl] version v1.22.0+
* Access to a Kubernetes v1.21.0+ cluster.
Expand Down
Loading