Skip to content

Commit

Permalink
Merge pull request #62 from vshn/feat/kafka
Browse files Browse the repository at this point in the history
Add Support for Kafka
  • Loading branch information
glrf committed Dec 5, 2022
2 parents 0d26f25 + 69b85dc commit 99e905f
Show file tree
Hide file tree
Showing 27 changed files with 2,180 additions and 5 deletions.
115 changes: 115 additions & 0 deletions apis/exoscale/v1/kafka_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package v1

import (
"reflect"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
"github.com/crossplane/crossplane-runtime/pkg/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// KafkaParameters are the configurable fields of a Kafka instance.
type KafkaParameters struct {
Maintenance MaintenanceSpec `json:"maintenance,omitempty"`

// +kubebuilder:validation:Required

// Zone is the datacenter identifier in which the instance runs in.
Zone Zone `json:"zone"`

DBaaSParameters `json:",inline"`

// Version is the (minor) version identifier for the instance (e.g. "3.2").
Version string `json:"version,omitempty"`

// KafkaSettings contains additional Kafka settings.
KafkaSettings runtime.RawExtension `json:"kafkaSettings,omitempty"`
}

// KafkaSpec defines the desired state of a Kafka.
type KafkaSpec struct {
xpv1.ResourceSpec `json:",inline"`
ForProvider KafkaParameters `json:"forProvider"`
}

// KafkaObservation are the observable fields of a Kafka.
type KafkaObservation struct {
Version string `json:"version,omitempty"`
// KafkaSettings contains additional Kafka settings as set by the provider.
KafkaSettings runtime.RawExtension `json:"kafkaSettings,omitempty"`

// State of individual service nodes
NodeStates []NodeState `json:"nodeStates,omitempty"`

// Service notifications
Notifications []Notification `json:"notifications,omitempty"`
}

// KafkaStatus represents the observed state of a Kafka instance.
type KafkaStatus struct {
xpv1.ResourceStatus `json:",inline"`
AtProvider KafkaObservation `json:"atProvider,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="Synced",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status"
// +kubebuilder:printcolumn:name="External Name",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name"
// +kubebuilder:printcolumn:name="Plan",type="string",JSONPath=".spec.forProvider.size.plan"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={crossplane,exoscale}
// +kubebuilder:webhook:verbs=create;update,path=/validate-exoscale-crossplane-io-v1-kafka,mutating=false,failurePolicy=fail,groups=exoscale.crossplane.io,resources=kafkas,versions=v1,name=kafkas.exoscale.crossplane.io,sideEffects=None,admissionReviewVersions=v1

// Kafka is the API for creating Kafka.
type Kafka struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec KafkaSpec `json:"spec"`
Status KafkaStatus `json:"status,omitempty"`
}

// GetProviderConfigName returns the name of the ProviderConfig.
// Returns empty string if reference not given.
func (in *Kafka) GetProviderConfigName() string {
if ref := in.GetProviderConfigReference(); ref != nil {
return ref.Name
}
return ""
}

// GetInstanceName returns the external name of the instance in the following precedence:
//
// .metadata.annotations."crossplane.io/external-name"
// .metadata.name
func (in *Kafka) GetInstanceName() string {
if name := meta.GetExternalName(in); name != "" {
return name
}
return in.Name
}

// +kubebuilder:object:root=true

// KafkaList contains a list of Kafka
type KafkaList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Kafka `json:"items"`
}

// Kafka type metadata.
var (
KafkaKind = reflect.TypeOf(Kafka{}).Name()
KafkaGroupKind = schema.GroupKind{Group: Group, Kind: KafkaKind}.String()
KafkaKindAPIVersion = KafkaKind + "." + SchemeGroupVersion.String()
KafkaGroupVersionKind = SchemeGroupVersion.WithKind(KafkaKind)
)

func init() {
SchemeBuilder.Register(&Kafka{}, &KafkaList{})
}
139 changes: 139 additions & 0 deletions apis/exoscale/v1/zz_generated.deepcopy.go

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

66 changes: 66 additions & 0 deletions apis/exoscale/v1/zz_generated.managed.go

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

9 changes: 9 additions & 0 deletions apis/exoscale/v1/zz_generated.managedlist.go

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

8 changes: 4 additions & 4 deletions docs/modules/ROOT/examples/exoscale_iamkey.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
apiVersion: exoscale.crossplane.io/v1
kind: IAMKey
metadata:
name: my-exoscale-iam-key
name: iam-key-local-dev
spec:
forProvider:
keyName: iam-key
keyName: iam-key-local-dev
services:
sos:
buckets:
- bucket-test-1
- bucket-local-dev
zone: CH-DK-2
providerConfigRef:
name: provider-config
writeConnectionSecretToRef:
name: my-exoscale-iam-key
name: my-exoscale-user-credentials
namespace: default
Loading

0 comments on commit 99e905f

Please sign in to comment.