Skip to content

Commit e53f4ca

Browse files
Merge pull request #1700 from Kuadrant/add-apiproduct-apikey-to-kuadrant
Add apiproduct apikey to kuadrant
2 parents 4ba4637 + fdf345f commit e53f4ca

28 files changed

+2228
-2
lines changed

Makefile

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,21 @@ else
182182
RELATED_IMAGE_WASMSHIM ?= oci://quay.io/kuadrant/wasm-shim:$(WASM_SHIM_VERSION)
183183
endif
184184

185+
## developer-portal-controller
186+
DEVELOPERPORTAL_VERSION ?= latest
187+
developerportal_version_is_semantic := $(call is_semantic_version,$(DEVELOPERPORTAL_VERSION))
188+
189+
ifeq (latest,$(DEVELOPERPORTAL_VERSION))
190+
RELATED_IMAGE_DEVELOPERPORTAL ?= quay.io/kuadrant/developer-portal-controller:latest
191+
DEVELOPERPORTAL_GITREF = main
192+
else ifeq (true,$(developerportal_version_is_semantic))
193+
RELATED_IMAGE_DEVELOPERPORTAL ?= quay.io/kuadrant/developer-portal-controller:v$(DEVELOPERPORTAL_VERSION)
194+
DEVELOPERPORTAL_GITREF = v$(DEVELOPERPORTAL_VERSION)
195+
else
196+
RELATED_IMAGE_DEVELOPERPORTAL ?= quay.io/kuadrant/developer-portal-controller:$(DEVELOPERPORTAL_VERSION)
197+
DEVELOPERPORTAL_GITREF = $(DEVELOPERPORTAL_VERSION)
198+
endif
199+
185200
## gatewayapi-provider
186201
GATEWAYAPI_PROVIDER ?= istio
187202

@@ -332,10 +347,12 @@ extensions-manifests: controller-gen ## Generate WebhookConfiguration, ClusterRo
332347
dependencies-manifests: export AUTHORINO_OPERATOR_GITREF := $(AUTHORINO_OPERATOR_GITREF)
333348
dependencies-manifests: export LIMITADOR_OPERATOR_GITREF := $(LIMITADOR_OPERATOR_GITREF)
334349
dependencies-manifests: export DNS_OPERATOR_GITREF := $(DNS_OPERATOR_GITREF)
350+
dependencies-manifests: export DEVELOPERPORTAL_GITREF := $(DEVELOPERPORTAL_GITREF)
335351
dependencies-manifests: ## Update kuadrant dependencies manifests.
336352
$(call patch-config,config/dependencies/authorino/kustomization.template.yaml,config/dependencies/authorino/kustomization.yaml)
337353
$(call patch-config,config/dependencies/limitador/kustomization.template.yaml,config/dependencies/limitador/kustomization.yaml)
338354
$(call patch-config,config/dependencies/dns/kustomization.template.yaml,config/dependencies/dns/kustomization.yaml)
355+
$(call patch-config,config/dependencies/developer-portal/kustomization.template.yaml,config/dependencies/developer-portal/kustomization.yaml)
339356

340357
.PHONY: generate
341358
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
@@ -430,14 +447,17 @@ bundle: $(OPM) $(YQ) manifests dependencies-manifests kustomize operator-sdk ##
430447
# Set desired Wasm-shim image
431448
V="$(RELATED_IMAGE_WASMSHIM)" \
432449
$(YQ) eval '(select(.kind == "Deployment").spec.template.spec.containers[].env[] | select(.name == "RELATED_IMAGE_WASMSHIM").value) = strenv(V)' -i config/manager/manager.yaml
450+
# Set desired developer-portal-controller image
451+
V="$(RELATED_IMAGE_DEVELOPERPORTAL)" \
452+
$(YQ) eval '(select(.kind == "Deployment").spec.template.spec.containers[].env[] | select(.name == "RELATED_IMAGE_DEVELOPERPORTAL").value) = strenv(V)' -i config/manager/manager.yaml
433453
# Set desired operator image
434454
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
435455
# Update CSV
436456
$(call update-csv-config,kuadrant-operator.v$(BUNDLE_VERSION),config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml,.metadata.name)
437457
$(call update-csv-config,$(BUNDLE_VERSION),config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml,.spec.version)
438458
$(call update-csv-config,$(IMG),config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml,.metadata.annotations.containerImage)
439459
# Generate bundle
440-
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(BUNDLE_VERSION) $(BUNDLE_METADATA_OPTS)
460+
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(BUNDLE_VERSION) $(BUNDLE_METADATA_OPTS) --extra-service-accounts=developer-portal-controller-manager
441461
$(MAKE) bundle-post-generate LIMITADOR_OPERATOR_BUNDLE_IMG=$(LIMITADOR_OPERATOR_BUNDLE_IMG) \
442462
AUTHORINO_OPERATOR_BUNDLE_IMG=$(AUTHORINO_OPERATOR_BUNDLE_IMG) \
443463
DNS_OPERATOR_BUNDLE_IMG=$(DNS_OPERATOR_BUNDLE_IMG)

api/v1beta1/kuadrant_types.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ func (k *Kuadrant) IsMTLSAuthorinoEnabled() bool {
7171
return k.Spec.MTLS.IsAuthorinoEnabled()
7272
}
7373

74+
func (k *Kuadrant) IsDeveloperPortalEnabled() bool {
75+
if k == nil || k.Spec.Components == nil || k.Spec.Components.DeveloperPortal == nil {
76+
return false
77+
}
78+
return k.Spec.Components.DeveloperPortal.Enabled
79+
}
80+
7481
// KuadrantSpec defines the desired state of Kuadrant
7582
type KuadrantSpec struct {
7683
Observability Observability `json:"observability,omitempty"`
@@ -79,6 +86,9 @@ type KuadrantSpec struct {
7986
// will add the configuration required to enable mTLS between an Istio provided
8087
// gateway and the Kuadrant components.
8188
MTLS *MTLS `json:"mtls,omitempty"`
89+
// +optional
90+
// Components configures optional Kuadrant components
91+
Components *Components `json:"components,omitempty"`
8292
}
8393

8494
// Observability configures telemetry and monitoring settings for Kuadrant components.
@@ -142,6 +152,16 @@ type LogLevel struct {
142152
Error *string `json:"error,omitempty"`
143153
}
144154

155+
type Components struct {
156+
// +optional
157+
// DeveloperPortal enables the developer portal integration including APIProduct and APIKeyRequest CRDs
158+
DeveloperPortal *DeveloperPortal `json:"developerPortal,omitempty"`
159+
}
160+
161+
type DeveloperPortal struct {
162+
Enabled bool `json:"enabled,omitempty"`
163+
}
164+
145165
type MTLS struct {
146166
Enable bool `json:"enable,omitempty"`
147167

api/v1beta1/kuadrant_types_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,53 @@ func TestLogLevelStructure(t *testing.T) {
308308
})
309309
}
310310
}
311+
312+
func TestIsDeveloperPortalEnabled(t *testing.T) {
313+
tests := []struct {
314+
name string
315+
components *Components
316+
expectedRes bool
317+
}{
318+
{
319+
name: "components is nil",
320+
components: nil,
321+
expectedRes: false,
322+
},
323+
{
324+
name: "developer portal not set",
325+
components: &Components{},
326+
expectedRes: false,
327+
},
328+
{
329+
name: "developer portal disabled",
330+
components: &Components{
331+
DeveloperPortal: &DeveloperPortal{Enabled: false},
332+
},
333+
expectedRes: false,
334+
},
335+
{
336+
name: "developer portal enabled",
337+
components: &Components{
338+
DeveloperPortal: &DeveloperPortal{Enabled: true},
339+
},
340+
expectedRes: true,
341+
},
342+
}
343+
for _, tt := range tests {
344+
kuadrantCR := &Kuadrant{
345+
Spec: KuadrantSpec{
346+
Components: tt.components,
347+
},
348+
}
349+
t.Run(tt.name, func(subT *testing.T) {
350+
got := kuadrantCR.IsDeveloperPortalEnabled()
351+
assert.Equal(subT, got, tt.expectedRes)
352+
})
353+
}
354+
355+
t.Run("kuadrant is nil", func(subT *testing.T) {
356+
var kuadrantCR *Kuadrant
357+
got := kuadrantCR.IsDeveloperPortalEnabled()
358+
assert.Assert(subT, !got)
359+
})
360+
}

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)