Skip to content

Commit

Permalink
wip: bridges
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Mar 5, 2024
1 parent 76aae6d commit 8e97684
Show file tree
Hide file tree
Showing 26 changed files with 1,849 additions and 28 deletions.
254 changes: 254 additions & 0 deletions charts/typhoon/crds/typhoon-crds.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions config/304-xslttransformation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ spec:
status: {}
schema:
openAPIV3Schema:
description: typhoon CloudEvents XSLT transformation.
description: Typhoon CloudEvents XSLT transformation.
type: object
properties:
spec:
description: Desired state of the typhoon component.
description: Desired state of the Typhoon component.
type: object
properties:
xslt:
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/flow/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ var (
Group: GroupName,
Resource: "xslttransformations",
}

// BridgeResource respresents a bundled application flow.
BridgeResource = schema.GroupResource{
Group: GroupName,
Resource: "bridges",
}
)
32 changes: 32 additions & 0 deletions pkg/apis/flow/v1alpha1/bridge_lifecycle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package v1alpha1

import (
"github.com/zeiss/typhoon/pkg/apis/common/v1alpha1"
"k8s.io/apimachinery/pkg/runtime/schema"

"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
)

// GetGroupVersionKind implements kmeta.OwnerRefable.
func (*Bridge) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind("Bridge")
}

// GetConditionSet implements duckv1.KRShaped.
func (t *Bridge) GetConditionSet() apis.ConditionSet {
return v1alpha1.DefaultConditionSet
}

// GetStatus implements duckv1.KRShaped.
func (t *Bridge) GetStatus() *duckv1.Status {
return &t.Status.Status
}

// GetStatusManager implements Reconcilable.
func (t *Bridge) GetStatusManager() *v1alpha1.StatusManager {
return &v1alpha1.StatusManager{
ConditionSet: t.GetConditionSet(),
Status: &t.Status,
}
}
94 changes: 94 additions & 0 deletions pkg/apis/flow/v1alpha1/bridge_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/zeiss/typhoon/pkg/apis/common/v1alpha1"
)

// +genclient
// +genreconciler
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Bridge is the Schema for the Bridge target.
type Bridge struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec BridgeSpec `json:"spec"`
Status v1alpha1.Status `json:"status,omitempty"`
}

// Check the interfaces Bridge should be implementing.
var (
_ v1alpha1.Reconcilable = (*Bridge)(nil)
)

// BridgeSpec defines the desired state of the component.
type BridgeSpec struct {
Components []Component `json:"components"`
}

// Component holds a component of a bridge.
// +k8s:deepcopy-gen=false
type Component struct {
Object isBridgeObject_BridgeObject `json:"object"`
}

// GetObject return the object of the component.
func (c *Component) GetObject() isBridgeObject_BridgeObject {
if c != nil {
return c.Object
}

return nil
}

// GetTransformation returns the transformation of the component.
func (c *Component) GetTransformation() *BridgeObject_Transformation {
if x, ok := c.GetObject().(*BridgeObject_Transformation); ok {
return x
}

return nil
}

// DeepCopy is a helper function for deepcopy-gen.
func (in *Component) DeepCopy() *Component {
if in == nil {
return nil
}
out := new(Component)
in.DeepCopyInto(out)

return out
}

// DeepCopyInto is a helper function for deepcopy-gen.
func (in *Component) DeepCopyInto(out *Component) {
*out = *in
if in.GetTransformation() != nil {
in.GetTransformation().DeepCopyInto(out.GetTransformation())
}
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// BridgeList is a list of component instances.
type BridgeList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Bridge `json:"items"`
}

type isBridgeObject_BridgeObject interface {
isBridgeObject_BridgeObject()
}

// BridgeObject_Transformation is a component of a bridge.
type BridgeObject_Transformation struct {
Transformation TransformationSpec
}

// Check the interfaces BridgeObject_Transformation should be implementing.
func (*BridgeObject_Transformation) isBridgeObject_BridgeObject() {}
26 changes: 0 additions & 26 deletions pkg/apis/flow/v1alpha1/register_test.go

This file was deleted.

101 changes: 101 additions & 0 deletions pkg/apis/flow/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 8e97684

Please sign in to comment.