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

[WIP] THREESCALE-8002 - feat: product v1beta2 #810

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ else
GOBIN=$(shell $(GO) env GOBIN)
endif

# Set sed -i as it's different for mac vs gnu
ifeq ($(shell uname -s | tr A-Z a-z), darwin)
SED_INLINE ?= sed -i ''
else
SED_INLINE ?= sed -i
endif

MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))

Expand Down Expand Up @@ -85,6 +92,7 @@ manager: generate fmt vet
# Run against the configured Kubernetes cluster in ~/.kube/config
run: export WATCH_NAMESPACE=$(LOCAL_RUN_NAMESPACE)
run: export THREESCALE_DEBUG=1
run: export ENABLE_WEBHOOKS=false
run: generate fmt vet manifests
$(GO) run ./main.go --zap-devel

Expand Down Expand Up @@ -199,7 +207,7 @@ bundle-custom-updates: $(YQ)
$(YQ) --inplace '.spec.displayName = "$(BUNDLE_PREFIX) 3scale operator"' $(PROJECT_PATH)/bundle/manifests/3scale-operator.clusterserviceversion.yaml
$(YQ) --inplace '.spec.provider.name = "$(BUNDLE_PREFIX)"' $(PROJECT_PATH)/bundle/manifests/3scale-operator.clusterserviceversion.yaml
$(YQ) --inplace '.annotations."operators.operatorframework.io.bundle.package.v1" = "$(BUNDLE_PREFIX)-3scale-operator"' $(PROJECT_PATH)/bundle/metadata/annotations.yaml
sed -E -i 's/(operators\.operatorframework\.io\.bundle\.package\.v1=).+/\1$(BUNDLE_PREFIX)-3scale-operator/' $(PROJECT_PATH)/bundle.Dockerfile
$(SED_INLINE) -E 's/(operators\.operatorframework\.io\.bundle\.package\.v1=).+/\1$(BUNDLE_PREFIX)-3scale-operator/' $(PROJECT_PATH)/bundle.Dockerfile
@echo "Update operator image reference URL"
$(YQ) --inplace '.metadata.annotations.containerImage = "$(IMG)"' $(PROJECT_PATH)/bundle/manifests/3scale-operator.clusterserviceversion.yaml
$(YQ) --inplace '.spec.install.spec.deployments[0].spec.template.spec.containers[0].image = "$(IMG)"' $(PROJECT_PATH)/bundle/manifests/3scale-operator.clusterserviceversion.yaml
Expand Down
3 changes: 3 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ resources:
- group: capabilities
kind: Application
version: v1beta1
- group: capabilities
kind: Product
version: v1beta2
version: 3-alpha
plugins:
go.sdk.operatorframework.io/v2-alpha: {}
9 changes: 5 additions & 4 deletions apis/capabilities/v1beta1/backend_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"regexp"
"strings"

"github.com/3scale/3scale-operator/apis/capabilities/v1beta2"
"github.com/3scale/3scale-operator/pkg/common"
"github.com/go-logr/logr"
"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -90,14 +91,14 @@ type BackendSpec struct {
// system_name attr is unique for all metrics AND methods
// In other words, if metric's system_name is A, there is no metric or method with system_name A.
// +optional
Metrics map[string]MetricSpec `json:"metrics,omitempty"`
Metrics map[string]v1beta2.MetricSpec `json:"metrics,omitempty"`

// Methods
// Map: system_name -> MethodSpec
// system_name attr is unique for all metrics AND methods
// In other words, if metric's system_name is A, there is no metric or method with system_name A.
// +optional
Methods map[string]MethodSpec `json:"methods,omitempty"`
Methods map[string]v1beta2.MethodSpec `json:"methods,omitempty"`

// ProviderAccountRef references account provider credentials
// +optional
Expand Down Expand Up @@ -177,7 +178,7 @@ func (backend *Backend) SetDefaults(logger logr.Logger) bool {
}

if backend.Spec.Metrics == nil {
backend.Spec.Metrics = map[string]MetricSpec{}
backend.Spec.Metrics = map[string]v1beta2.MetricSpec{}
updated = true
}

Expand All @@ -190,7 +191,7 @@ func (backend *Backend) SetDefaults(logger logr.Logger) bool {
}
if !hitsFound {
logger.V(1).Info("Hits metric added")
backend.Spec.Metrics["hits"] = MetricSpec{
backend.Spec.Metrics["hits"] = v1beta2.MetricSpec{
Name: "Hits",
Unit: "hit",
Description: "Number of API hits",
Expand Down
406 changes: 406 additions & 0 deletions apis/capabilities/v1beta1/product_conversion.go

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions apis/capabilities/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions apis/capabilities/v1beta2/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2020 Red Hat.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1beta2 contains API Schema definitions for the capabilities v1beta2 API group
// +kubebuilder:object:generate=true
// +groupName=capabilities.3scale.net
package v1beta2

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "capabilities.3scale.net", Version: "v1beta2"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
4 changes: 4 additions & 0 deletions apis/capabilities/v1beta2/product_conversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package v1beta2

// Hub marks this type as a conversion hub.
func (*Product) Hub() {}
Loading