Skip to content

Commit

Permalink
Implemented TaskDefinition Managed Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskniep committed Jan 8, 2024
1 parent 280f439 commit 7fab81b
Show file tree
Hide file tree
Showing 15 changed files with 1,252 additions and 43 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ spec:
# Covered Managed Resources
Currently covered Managed Resources:
- [Application](#application)
- [TaskDefinition](#taskdefinition)

## Application

Expand All @@ -109,6 +110,27 @@ spec:
name: provider-spring-cloud-dataflow-config
```

## TaskDefinition

[docs](https://docs.spring.io/spring-cloud-dataflow/docs/current/reference/htmlsingle/#spring-cloud-dataflow-task)

[rest api](https://docs.spring.io/spring-cloud-dataflow/docs/current/reference/htmlsingle/#api-guide-resources-task-definitions)

Example:
```
apiVersion: core.springclouddataflow.crossplane.io/v1alpha1
kind: TaskDefinition
metadata:
name: task-1
spec:
forProvider:
name: "MyTask01"
description: "Test Task"
definition: "App001"
providerConfigRef:
name: provider-spring-cloud-dataflow-config
```

# Contribute
## Developing
1. Add new type by running the following command:
Expand Down Expand Up @@ -136,8 +158,11 @@ Start SpringCloudDataFlow environment for tests
```
sudo docker-compose -f tests/docker-compose.yaml up
```

UI: http://localhost:9393/dashboard

OpenAPI Spec: http://localhost:9393/v3/api-docs

Swagger-Ui: http://localhost:9393/swagger-ui/index.html


24 changes: 19 additions & 5 deletions apis/core/v1alpha1/application_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,28 @@ type ApplicationParameters struct {

// Type of the Application (immutable)
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Name is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Type is immutable"
// +kubebuilder:validation:Enum=app;source;processor;sink;task
Type string `json:"type"`

Version string `json:"version"`
Uri string `json:"uri"`
DefaultVersion bool `json:"defaultVersion"`
BootVersion string `json:"bootVersion"`
// Version of the Application (immutable)
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Version is immutable"
Version string `json:"version"`

// Uri of the Application (immutable)
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Uri is immutable"
Uri string `json:"uri"`

// Is this Application the Default
// +kubebuilder:validation:Required
DefaultVersion bool `json:"defaultVersion"`

// BootVersion of the Application (immutable)
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="BootVersion is immutable"
BootVersion string `json:"bootVersion"`
}

// ApplicationObservation are the observable fields of a Application.
Expand Down
105 changes: 105 additions & 0 deletions apis/core/v1alpha1/taskdefinition_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
Copyright 2022 The Crossplane Authors.
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 (
"reflect"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
)

// TaskDefinitionParameters are the configurable fields of a TaskDefinition.
type TaskDefinitionParameters struct {

// Name of the task definition (immutable)
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Name is immutable"
Name string `json:"name"`

// Description of the task definition (immutable)
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Description is immutable"
Description string `json:"description"`

// The definition for the task, using Data Flow DSL (immutable)
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Definition is immutable"
Definition string `json:"definition"`
}

// TaskDefinitionObservation are the observable fields of a TaskDefinition.
type TaskDefinitionObservation struct {
Name string `json:"name"`
Description string `json:"description"`
Definition string `json:"definition"`
Composed bool `json:"composed"`
ComposedTaskElement bool `json:"composedTaskElement"`
Status string `json:"status"`
}

// A TaskDefinitionSpec defines the desired state of a TaskDefinition.
type TaskDefinitionSpec struct {
xpv1.ResourceSpec `json:",inline"`
ForProvider TaskDefinitionParameters `json:"forProvider"`
}

// A TaskDefinitionStatus represents the observed state of a TaskDefinition.
type TaskDefinitionStatus struct {
xpv1.ResourceStatus `json:",inline"`
AtProvider TaskDefinitionObservation `json:"atProvider,omitempty"`
}

// +kubebuilder:object:root=true

// A TaskDefinition is an example API type.
// +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="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,springclouddataflow}
type TaskDefinition struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec TaskDefinitionSpec `json:"spec"`
Status TaskDefinitionStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

// TaskDefinition type metadata.
var (
TaskDefinitionKind = reflect.TypeOf(TaskDefinition{}).Name()
TaskDefinitionGroupKind = schema.GroupKind{Group: Group, Kind: TaskDefinitionKind}.String()
TaskDefinitionKindAPIVersion = TaskDefinitionKind + "." + SchemeGroupVersion.String()
TaskDefinitionGroupVersionKind = SchemeGroupVersion.WithKind(TaskDefinitionKind)
)

func init() {
SchemeBuilder.Register(&TaskDefinition{}, &TaskDefinitionList{})
}
123 changes: 123 additions & 0 deletions apis/core/v1alpha1/zz_generated.deepcopy.go

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

76 changes: 76 additions & 0 deletions apis/core/v1alpha1/zz_generated.managed.go

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

Loading

0 comments on commit 7fab81b

Please sign in to comment.