Skip to content

Commit

Permalink
feat(crd): add Konnect API group
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Aug 1, 2024
1 parent c10e829 commit 476b7bf
Show file tree
Hide file tree
Showing 29 changed files with 454 additions and 490 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ verify.generators: verify.repo generate verify.diff
# Build - Generators
# ------------------------------------------------------------------------------

CRD_GEN_PATHS ?= ./api/configuration/...
CRD_GEN_PATHS ?= ./api/configuration/...;./api/konnect/...
CRD_INCUBATOR_GEN_PATHS ?= ./api/incubator/...
CRD_OPTIONS ?= "+crd:allowDangerousTypes=true"

Expand Down Expand Up @@ -151,6 +151,7 @@ generate.clientsets: client-gen
--input configuration/v1 \
--input configuration/v1alpha1 \
--input configuration/v1beta1 \
--input konnect/v1alpha1 \
--input incubator/v1alpha1 \
--output-dir pkg/ \
--output-pkg $(REPO_URL)/pkg/
Expand Down
5 changes: 3 additions & 2 deletions api/configuration/v1/kongconsumer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1"
konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1"
)

// +genclient
Expand Down Expand Up @@ -72,7 +73,7 @@ func (c KongConsumer) GetTypeName() string {
func (c *KongConsumer) SetKonnectLabels(labels map[string]string) {
}

func (c *KongConsumer) GetKonnectAPIAuthConfigurationRef() configurationv1alpha1.KonnectAPIAuthConfigurationRef {
func (c *KongConsumer) GetKonnectAPIAuthConfigurationRef() konnectv1alpha1.KonnectAPIAuthConfigurationRef {
return c.Spec.KonnectConfiguration.APIAuthConfigurationRef
}

Expand All @@ -91,7 +92,7 @@ type KongConsumerSpec struct {
ControlPlaneRef configurationv1alpha1.ControlPlaneRef `json:"controlPlaneRef,omitempty"`

// KonnectConfiguration holds the Konnect configuration like authentication configuration.
KonnectConfiguration configurationv1alpha1.KonnectConfiguration `json:"konnect,omitempty"`
KonnectConfiguration konnectv1alpha1.KonnectConfiguration `json:"konnect,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
6 changes: 4 additions & 2 deletions api/configuration/v1alpha1/kongroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package v1alpha1
import (
sdkkonnectgocomp "github.com/Kong/sdk-konnect-go/models/components"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1"
)

// TODO(pmalek): expression field is not in OpenAPI spec but error message references it:
Expand Down Expand Up @@ -51,7 +53,7 @@ func (c KongRoute) GetTypeName() string {
return "KongRoute"
}

func (c *KongRoute) GetKonnectAPIAuthConfigurationRef() KonnectAPIAuthConfigurationRef {
func (c *KongRoute) GetKonnectAPIAuthConfigurationRef() konnectv1alpha1.KonnectAPIAuthConfigurationRef {
return c.Spec.KonnectConfiguration.APIAuthConfigurationRef
}

Expand All @@ -77,7 +79,7 @@ type KongRouteSpec struct {

// KonnectConfiguration holds the Konnect configuration like authentication configuration.
// +kubebuilder:validation:Required
KonnectConfiguration KonnectConfiguration `json:"konnect,omitempty"`
KonnectConfiguration konnectv1alpha1.KonnectConfiguration `json:"konnect,omitempty"`

KongRouteAPISpec `json:",inline"`
}
Expand Down
6 changes: 4 additions & 2 deletions api/configuration/v1alpha1/kongservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package v1alpha1
import (
sdkkonnectgocomp "github.com/Kong/sdk-konnect-go/models/components"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1"
)

// KongService is the schema for Services API which defines a Kong Service.
Expand Down Expand Up @@ -52,7 +54,7 @@ func (c KongService) GetTypeName() string {
func (c *KongService) SetKonnectLabels(labels map[string]string) {
}

func (c *KongService) GetKonnectAPIAuthConfigurationRef() KonnectAPIAuthConfigurationRef {
func (c *KongService) GetKonnectAPIAuthConfigurationRef() konnectv1alpha1.KonnectAPIAuthConfigurationRef {
return c.Spec.KonnectConfiguration.APIAuthConfigurationRef
}

Expand All @@ -74,7 +76,7 @@ type KongServiceSpec struct {

// KonnectConfiguration holds the Konnect configuration like authentication configuration.
// +kubebuilder:validation:Required
KonnectConfiguration KonnectConfiguration `json:"konnect,omitempty"`
KonnectConfiguration konnectv1alpha1.KonnectConfiguration `json:"konnect,omitempty"`

KongServiceAPISpec `json:",inline"`
}
Expand Down
111 changes: 0 additions & 111 deletions api/configuration/v1alpha1/zz_generated.deepcopy.go

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

20 changes: 20 additions & 0 deletions api/konnect/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright 2021 Kong, Inc.
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 v1alpha1 contains API Schema definitions for the konnect.konghq.com v1alpha1 API group.
// +kubebuilder:object:generate=true
// +groupName=konnect.konghq.com
package v1alpha1
41 changes: 41 additions & 0 deletions api/konnect/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright 2022 Kong, Inc.
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 v1alpha1

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: "konnect.konghq.com", Version: "v1alpha1"}

// SchemeGroupVersion is a convenience var for generated clientsets.
SchemeGroupVersion = GroupVersion

// 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
)

// Resource takes an unqualified resource and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func init() {
// KonnectAPIAuthConfiguration is the Schema for the Konnect configuration type.
//
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:scope=Namespaced
// +kubebuilder:object:root=true
// +kubebuilder:object:generate=true
Expand Down Expand Up @@ -39,8 +40,6 @@ type KonnectAPIAuthConfigurationSpec struct {
Token string `json:"token"`

// ServerURL is the URL of the Konnect server.
// TODO(pmalek): do we want this validation?
// +Xkubebuilder:validation:Enum=us.api.konghq.com;eu.api.konghq.com;au.api.konghq.com
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Server URL is immutable"
ServerURL string `json:"serverURL"`
Expand Down
Loading

0 comments on commit 476b7bf

Please sign in to comment.