diff --git a/README.md b/README.md index 81bfcfe..f2e1fb3 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ spec: # Covered Managed Resources Currently covered Managed Resources: - [Application](#application) +- [TaskDefinition](#taskdefinition) ## Application @@ -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: @@ -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 diff --git a/apis/core/v1alpha1/application_types.go b/apis/core/v1alpha1/application_types.go index 959f471..3b5ea85 100644 --- a/apis/core/v1alpha1/application_types.go +++ b/apis/core/v1alpha1/application_types.go @@ -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. diff --git a/apis/core/v1alpha1/taskdefinition_types.go b/apis/core/v1alpha1/taskdefinition_types.go new file mode 100644 index 0000000..c0cdbe3 --- /dev/null +++ b/apis/core/v1alpha1/taskdefinition_types.go @@ -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{}) +} diff --git a/apis/core/v1alpha1/zz_generated.deepcopy.go b/apis/core/v1alpha1/zz_generated.deepcopy.go index 85ec55a..9aa52d9 100644 --- a/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -147,3 +147,126 @@ func (in *ApplicationStatus) DeepCopy() *ApplicationStatus { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskDefinition) DeepCopyInto(out *TaskDefinition) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskDefinition. +func (in *TaskDefinition) DeepCopy() *TaskDefinition { + if in == nil { + return nil + } + out := new(TaskDefinition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TaskDefinition) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskDefinitionList) DeepCopyInto(out *TaskDefinitionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TaskDefinition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskDefinitionList. +func (in *TaskDefinitionList) DeepCopy() *TaskDefinitionList { + if in == nil { + return nil + } + out := new(TaskDefinitionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TaskDefinitionList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskDefinitionObservation) DeepCopyInto(out *TaskDefinitionObservation) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskDefinitionObservation. +func (in *TaskDefinitionObservation) DeepCopy() *TaskDefinitionObservation { + if in == nil { + return nil + } + out := new(TaskDefinitionObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskDefinitionParameters) DeepCopyInto(out *TaskDefinitionParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskDefinitionParameters. +func (in *TaskDefinitionParameters) DeepCopy() *TaskDefinitionParameters { + if in == nil { + return nil + } + out := new(TaskDefinitionParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskDefinitionSpec) DeepCopyInto(out *TaskDefinitionSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + out.ForProvider = in.ForProvider +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskDefinitionSpec. +func (in *TaskDefinitionSpec) DeepCopy() *TaskDefinitionSpec { + if in == nil { + return nil + } + out := new(TaskDefinitionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskDefinitionStatus) DeepCopyInto(out *TaskDefinitionStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + out.AtProvider = in.AtProvider +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskDefinitionStatus. +func (in *TaskDefinitionStatus) DeepCopy() *TaskDefinitionStatus { + if in == nil { + return nil + } + out := new(TaskDefinitionStatus) + in.DeepCopyInto(out) + return out +} diff --git a/apis/core/v1alpha1/zz_generated.managed.go b/apis/core/v1alpha1/zz_generated.managed.go index a50e857..2bc3a59 100644 --- a/apis/core/v1alpha1/zz_generated.managed.go +++ b/apis/core/v1alpha1/zz_generated.managed.go @@ -94,3 +94,79 @@ func (mg *Application) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDe func (mg *Application) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { mg.Spec.WriteConnectionSecretToReference = r } + +// GetCondition of this TaskDefinition. +func (mg *TaskDefinition) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this TaskDefinition. +func (mg *TaskDefinition) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this TaskDefinition. +func (mg *TaskDefinition) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this TaskDefinition. +func (mg *TaskDefinition) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +/* +GetProviderReference of this TaskDefinition. +Deprecated: Use GetProviderConfigReference. +*/ +func (mg *TaskDefinition) GetProviderReference() *xpv1.Reference { + return mg.Spec.ProviderReference +} + +// GetPublishConnectionDetailsTo of this TaskDefinition. +func (mg *TaskDefinition) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this TaskDefinition. +func (mg *TaskDefinition) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this TaskDefinition. +func (mg *TaskDefinition) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this TaskDefinition. +func (mg *TaskDefinition) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this TaskDefinition. +func (mg *TaskDefinition) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this TaskDefinition. +func (mg *TaskDefinition) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +/* +SetProviderReference of this TaskDefinition. +Deprecated: Use SetProviderConfigReference. +*/ +func (mg *TaskDefinition) SetProviderReference(r *xpv1.Reference) { + mg.Spec.ProviderReference = r +} + +// SetPublishConnectionDetailsTo of this TaskDefinition. +func (mg *TaskDefinition) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this TaskDefinition. +func (mg *TaskDefinition) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} diff --git a/apis/core/v1alpha1/zz_generated.managedlist.go b/apis/core/v1alpha1/zz_generated.managedlist.go index 797d7f1..67d2c90 100644 --- a/apis/core/v1alpha1/zz_generated.managedlist.go +++ b/apis/core/v1alpha1/zz_generated.managedlist.go @@ -27,3 +27,12 @@ func (l *ApplicationList) GetItems() []resource.Managed { } return items } + +// GetItems of this TaskDefinitionList. +func (l *TaskDefinitionList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} diff --git a/internal/clients/application_test.go b/internal/clients/application_test.go index 972e8fe..4188bd5 100644 --- a/internal/clients/application_test.go +++ b/internal/clients/application_test.go @@ -8,7 +8,7 @@ import ( "golang.org/x/net/context" ) -func createApplicationService(t *testing.T) ApplicationService { +func CreateApplicationService(t *testing.T) ApplicationService { jsonConfig := `{ "Uri": "http://localhost:9393/" }` @@ -21,7 +21,7 @@ func createApplicationService(t *testing.T) ApplicationService { return srv } -func createDefaultApplication(appType string, name string, version string) *core.ApplicationParameters { +func CreateDefaultApplication(appType string, name string, version string) *core.ApplicationParameters { return &core.ApplicationParameters{ Type: appType, Name: name, @@ -32,70 +32,70 @@ func createDefaultApplication(appType string, name string, version string) *core } } -func TestCreate(t *testing.T) { +func TestCreateApplication(t *testing.T) { skipIfIsShort(t) - srv := createApplicationService(t) - testApp := createDefaultApplication("task", "Test001", "v1.0.0") + srv := CreateApplicationService(t) + testApp := CreateDefaultApplication("task", "Test001", "v1.0.0") - createdApp := create(t, srv, testApp) + createdApp := CreateApplication(t, srv, testApp) - assertApplicationAreEqual(t, srv, createdApp, testApp) + AssertApplicationAreEqual(t, srv, createdApp, testApp) - delete(t, srv, testApp) + DeleteApplication(t, srv, testApp) } func TestDeleteNotExisting(t *testing.T) { skipIfIsShort(t) - srv := createApplicationService(t) - testApp := createDefaultApplication("task", "Test999", "v1.0.0") - delete(t, srv, testApp) + srv := CreateApplicationService(t) + testApp := CreateDefaultApplication("task", "Test999", "v1.0.0") + DeleteApplication(t, srv, testApp) } func TestUpdateNotExisting(t *testing.T) { skipIfIsShort(t) - srv := createApplicationService(t) - testApp := createDefaultApplication("task", "Test888", "v1.0.0") - update(t, srv, testApp) + srv := CreateApplicationService(t) + testApp := CreateDefaultApplication("task", "Test888", "v1.0.0") + UpdateApplication(t, srv, testApp) } func TestUpdate(t *testing.T) { skipIfIsShort(t) - srv := createApplicationService(t) - testAppV1 := createDefaultApplication("task", "Test002", "v1.0.0") - createdAppV1 := create(t, srv, testAppV1) - assertApplicationAreEqual(t, srv, createdAppV1, testAppV1) + srv := CreateApplicationService(t) + testAppV1 := CreateDefaultApplication("task", "Test002", "v1.0.0") + createdAppV1 := CreateApplication(t, srv, testAppV1) + AssertApplicationAreEqual(t, srv, createdAppV1, testAppV1) - testAppV2 := createDefaultApplication("task", "Test002", "v2.0.0") + testAppV2 := CreateDefaultApplication("task", "Test002", "v2.0.0") testAppV2.DefaultVersion = false - createdAppV2 := create(t, srv, testAppV2) - assertApplicationAreEqual(t, srv, createdAppV2, testAppV2) + createdAppV2 := CreateApplication(t, srv, testAppV2) + AssertApplicationAreEqual(t, srv, createdAppV2, testAppV2) testAppV1.DefaultVersion = false testAppV2.DefaultVersion = true - update(t, srv, testAppV1) - update(t, srv, testAppV2) + UpdateApplication(t, srv, testAppV1) + UpdateApplication(t, srv, testAppV2) foundAppV1, err := srv.DescribeApplication(context.Background(), testAppV1) if err != nil { t.Fatal(err) } - assertApplicationAreEqual(t, srv, foundAppV1, testAppV1) + AssertApplicationAreEqual(t, srv, foundAppV1, testAppV1) foundAppV2, err := srv.DescribeApplication(context.Background(), testAppV2) if err != nil { t.Fatal(err) } - assertApplicationAreEqual(t, srv, foundAppV2, testAppV2) + AssertApplicationAreEqual(t, srv, foundAppV2, testAppV2) - delete(t, srv, testAppV1) - delete(t, srv, testAppV2) + DeleteApplication(t, srv, testAppV1) + DeleteApplication(t, srv, testAppV2) } -func update(t *testing.T, srv ApplicationService, app *core.ApplicationParameters) { +func UpdateApplication(t *testing.T, srv ApplicationService, app *core.ApplicationParameters) { t.Helper() err := srv.UpdateApplication(context.Background(), app) if err != nil { @@ -103,7 +103,7 @@ func update(t *testing.T, srv ApplicationService, app *core.ApplicationParameter } } -func create(t *testing.T, srv ApplicationService, app *core.ApplicationParameters) *core.ApplicationObservation { +func CreateApplication(t *testing.T, srv ApplicationService, app *core.ApplicationParameters) *core.ApplicationObservation { t.Helper() err := srv.CreateApplication(context.Background(), app) if err != nil { @@ -121,7 +121,7 @@ func create(t *testing.T, srv ApplicationService, app *core.ApplicationParameter return createdApp } -func delete(t *testing.T, srv ApplicationService, app *core.ApplicationParameters) { +func DeleteApplication(t *testing.T, srv ApplicationService, app *core.ApplicationParameters) { t.Helper() err := srv.DeleteApplication(context.Background(), app) if err != nil { @@ -138,7 +138,7 @@ func delete(t *testing.T, srv ApplicationService, app *core.ApplicationParameter } } -func assertApplicationAreEqual(t *testing.T, srv ApplicationService, actual *core.ApplicationObservation, expected *core.ApplicationParameters) { +func AssertApplicationAreEqual(t *testing.T, srv ApplicationService, actual *core.ApplicationObservation, expected *core.ApplicationParameters) { t.Helper() mappedActual, err := srv.MapToApplicationCompare(actual) if err != nil { @@ -155,9 +155,3 @@ func assertApplicationAreEqual(t *testing.T, srv ApplicationService, actual *cor t.Fatal(diff) } } - -func skipIfIsShort(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode.") - } -} diff --git a/internal/clients/service.go b/internal/clients/service.go index 2325334..c36c566 100644 --- a/internal/clients/service.go +++ b/internal/clients/service.go @@ -46,3 +46,7 @@ func NewDataFlowService(configData []byte) (*DataFlowServiceImpl, error) { func NewApplicationService(configData []byte) (ApplicationService, error) { return NewDataFlowService(configData) } + +func NewTaskDefinitionService(configData []byte) (TaskDefinitionService, error) { + return NewDataFlowService(configData) +} diff --git a/internal/clients/service_test.go b/internal/clients/service_test.go new file mode 100644 index 0000000..5a6cb86 --- /dev/null +++ b/internal/clients/service_test.go @@ -0,0 +1,9 @@ +package clients + +import "testing" + +func skipIfIsShort(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } +} diff --git a/internal/clients/taskdefinition.go b/internal/clients/taskdefinition.go new file mode 100644 index 0000000..5e5a751 --- /dev/null +++ b/internal/clients/taskdefinition.go @@ -0,0 +1,116 @@ +package clients + +import ( + "context" + "encoding/json" + "errors" + + core "github.com/denniskniep/provider-springclouddataflow/apis/core/v1alpha1" + "github.com/denniskniep/spring-cloud-dataflow-sdk-go/v2/client/tasks" + kiota "github.com/microsoft/kiota-abstractions-go" +) + +type TaskDefinitionService interface { + DescribeTaskDefinition(ctx context.Context, app *core.TaskDefinitionParameters) (*core.TaskDefinitionObservation, error) + + CreateTaskDefinition(ctx context.Context, app *core.TaskDefinitionParameters) error + UpdateTaskDefinition(ctx context.Context, app *core.TaskDefinitionParameters) error + DeleteTaskDefinition(ctx context.Context, app *core.TaskDefinitionParameters) error + + MapToTaskDefinitionCompare(app interface{}) (*TaskDefinitionCompare, error) +} + +type TaskDefinitionCompare struct { + Name string `json:"name"` + Description string `json:"description"` + Definition string `json:"definition"` +} + +type TaskDefinitionDescribeResponse struct { + Name string `json:"name"` + Description string `json:"description"` + DslText string `json:"dslText"` + Composed bool `json:"composed"` + ComposedTaskElement bool `json:"composedTaskElement"` + Status string `json:"status"` +} + +func (s *DataFlowServiceImpl) MapToTaskDefinitionCompare(app interface{}) (*TaskDefinitionCompare, error) { + taskJson, err := json.Marshal(app) + if err != nil { + return nil, err + } + + var taskCompare = TaskDefinitionCompare{} + err = json.Unmarshal(taskJson, &taskCompare) + if err != nil { + return nil, err + } + + return &taskCompare, nil +} + +func (s *DataFlowServiceImpl) CreateTaskDefinition(ctx context.Context, task *core.TaskDefinitionParameters) error { + _, err := s.client.Tasks().Definitions().Post(ctx, &tasks.DefinitionsRequestBuilderPostRequestConfiguration{ + QueryParameters: &tasks.DefinitionsRequestBuilderPostQueryParameters{ + Name: &task.Name, + Description: &task.Description, + Definition: &task.Definition, + }, + }) + + if err != nil { + return err + } + + return nil +} + +func (s *DataFlowServiceImpl) UpdateTaskDefinition(ctx context.Context, task *core.TaskDefinitionParameters) error { + return errors.New("Update not implemented - all properties are immutable!") +} + +func (s *DataFlowServiceImpl) DescribeTaskDefinition(ctx context.Context, task *core.TaskDefinitionParameters) (*core.TaskDefinitionObservation, error) { + result, err := s.client.Tasks().Definitions().ByName(task.Name).Get(ctx, nil) + + var apiError *kiota.ApiError + if errors.As(err, &apiError) && apiError.ResponseStatusCode == 404 { + return nil, nil + } + + if err != nil { + return nil, err + } + + var response = TaskDefinitionDescribeResponse{} + err = json.Unmarshal(result, &response) + if err != nil { + return nil, err + } + + var observed = core.TaskDefinitionObservation{ + Name: response.Name, + Description: response.Description, + Definition: response.DslText, + Composed: response.Composed, + ComposedTaskElement: response.ComposedTaskElement, + Status: response.Status, + } + + return &observed, nil +} + +func (s *DataFlowServiceImpl) DeleteTaskDefinition(ctx context.Context, task *core.TaskDefinitionParameters) error { + _, err := s.client.Tasks().Definitions().ByName(task.Name).Delete(ctx, nil) + + var apiError *kiota.ApiError + if errors.As(err, &apiError) && apiError.ResponseStatusCode == 404 { + return nil + } + + if err != nil { + return err + } + + return nil +} diff --git a/internal/clients/taskdefinition_test.go b/internal/clients/taskdefinition_test.go new file mode 100644 index 0000000..912a23d --- /dev/null +++ b/internal/clients/taskdefinition_test.go @@ -0,0 +1,101 @@ +package clients + +import ( + "testing" + + core "github.com/denniskniep/provider-springclouddataflow/apis/core/v1alpha1" + "github.com/google/go-cmp/cmp" + "golang.org/x/net/context" +) + +func CreateTaskDefinitionService(t *testing.T) TaskDefinitionService { + jsonConfig := `{ + "Uri": "http://localhost:9393/" + }` + + srv, err := NewTaskDefinitionService([]byte(jsonConfig)) + if err != nil { + t.Fatal(err) + } + + return srv +} + +func CreateDefaultTaskDefinition(name string, description string, definition string) *core.TaskDefinitionParameters { + return &core.TaskDefinitionParameters{ + Name: name, + Description: description, + Definition: definition, + } +} + +func TestCreateTaskDefinition(t *testing.T) { + skipIfIsShort(t) + + srvApp := CreateApplicationService(t) + srvTask := CreateTaskDefinitionService(t) + + testApp := CreateDefaultApplication("task", "Test010", "v1.0.0") + _ = CreateApplication(t, srvApp, testApp) + + testTask := CreateDefaultTaskDefinition("MyTask01", "MyDesc", "Test010") + created := CreateTaskDefinition(t, srvTask, testTask) + + AssertTaskDefinitionAreEqual(t, srvTask, created, testTask) + + DeleteTaskDefinition(t, srvTask, testTask) + DeleteApplication(t, srvApp, testApp) +} + +func CreateTaskDefinition(t *testing.T, srv TaskDefinitionService, task *core.TaskDefinitionParameters) *core.TaskDefinitionObservation { + t.Helper() + err := srv.CreateTaskDefinition(context.Background(), task) + if err != nil { + t.Fatal(err) + } + + createdTask, err := srv.DescribeTaskDefinition(context.Background(), task) + if err != nil { + t.Fatal(err) + } + + if createdTask == nil { + t.Fatal("TaskDefinition was not found") + } + return createdTask +} + +func DeleteTaskDefinition(t *testing.T, srv TaskDefinitionService, task *core.TaskDefinitionParameters) { + t.Helper() + err := srv.DeleteTaskDefinition(context.Background(), task) + if err != nil { + t.Fatal(err) + } + + noApp, err := srv.DescribeTaskDefinition(context.Background(), task) + if err != nil { + t.Fatal(err) + } + + if noApp != nil { + t.Fatal("TaskDefinition was not deleted") + } +} + +func AssertTaskDefinitionAreEqual(t *testing.T, srv TaskDefinitionService, actual *core.TaskDefinitionObservation, expected *core.TaskDefinitionParameters) { + t.Helper() + mappedActual, err := srv.MapToTaskDefinitionCompare(actual) + if err != nil { + t.Fatal(err) + } + + mappedExpected, err := srv.MapToTaskDefinitionCompare(expected) + if err != nil { + t.Fatal(err) + } + + diff := cmp.Diff(mappedActual, mappedExpected) + if diff != "" { + t.Fatal(diff) + } +} diff --git a/internal/controller/springclouddataflow.go b/internal/controller/springclouddataflow.go index d5dcce4..fd6c3b5 100644 --- a/internal/controller/springclouddataflow.go +++ b/internal/controller/springclouddataflow.go @@ -22,6 +22,7 @@ import ( application "github.com/denniskniep/provider-springclouddataflow/internal/controller/application" "github.com/denniskniep/provider-springclouddataflow/internal/controller/config" + "github.com/denniskniep/provider-springclouddataflow/internal/controller/taskdefinition" ) // Setup creates all SpringCloudDataFlow controllers with the supplied logger and adds them to @@ -30,6 +31,7 @@ func Setup(mgr ctrl.Manager, o controller.Options) error { for _, setup := range []func(ctrl.Manager, controller.Options) error{ config.Setup, application.Setup, + taskdefinition.Setup, } { if err := setup(mgr, o); err != nil { return err diff --git a/internal/controller/taskdefinition/taskdefinition.go b/internal/controller/taskdefinition/taskdefinition.go new file mode 100644 index 0000000..9ffb368 --- /dev/null +++ b/internal/controller/taskdefinition/taskdefinition.go @@ -0,0 +1,258 @@ +package taskdefinition + +import ( + "context" + "strconv" + + "github.com/google/go-cmp/cmp" + "github.com/pkg/errors" + "k8s.io/apimachinery/pkg/types" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/controller" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/logging" + "github.com/crossplane/crossplane-runtime/pkg/meta" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + "github.com/crossplane/crossplane-runtime/pkg/resource" + + "github.com/denniskniep/provider-springclouddataflow/apis/core/v1alpha1" + apisv1alpha1 "github.com/denniskniep/provider-springclouddataflow/apis/v1alpha1" + "github.com/denniskniep/provider-springclouddataflow/internal/clients" + "github.com/denniskniep/provider-springclouddataflow/internal/features" +) + +const ( + errNotTaskDefinition = "managed resource is not a TaskDefinition custom resource" + errTrackPCUsage = "cannot track ProviderConfig usage" + errGetPC = "cannot get ProviderConfig" + errGetCreds = "cannot get credentials" + + errNewClient = "cannot create new Service" + errDescribe = "failed to describe TaskDefinition resource" + errCreate = "failed to create TaskDefinition resource" + errUpdate = "failed to update TaskDefinition resource" + errDelete = "failed to delete TaskDefinition resource" + errMapping = "failed to map TaskDefinition resource" +) + +// Setup adds a controller that reconciles TaskDefinition managed resources. +func Setup(mgr ctrl.Manager, o controller.Options) error { + o.Logger.Info("Setup Controller: TaskDefinition") + name := managed.ControllerName(v1alpha1.TaskDefinitionGroupKind) + + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.Features.Enabled(features.EnableAlphaExternalSecretStores) { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), apisv1alpha1.StoreConfigGroupVersionKind)) + } + + r := managed.NewReconciler(mgr, + resource.ManagedKind(v1alpha1.TaskDefinitionGroupVersionKind), + managed.WithExternalConnecter(&connector{ + kube: mgr.GetClient(), + usage: resource.NewProviderConfigUsageTracker(mgr.GetClient(), &apisv1alpha1.ProviderConfigUsage{}), + newServiceFn: clients.NewTaskDefinitionService, + logger: o.Logger.WithValues("controller", name)}), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithPollInterval(o.PollInterval), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithInitializers(), + managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())), + managed.WithConnectionPublishers(cps...)) + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(resource.DesiredStateChanged()). + For(&v1alpha1.TaskDefinition{}). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} + +// A connector is expected to produce an ExternalClient when its Connect method +// is called. +type connector struct { + kube client.Client + usage resource.Tracker + logger logging.Logger + newServiceFn func(creds []byte) (clients.TaskDefinitionService, error) +} + +// Connect typically produces an ExternalClient by: +// 1. Tracking that the managed resource is using a ProviderConfig. +// 2. Getting the managed resource's ProviderConfig. +// 3. Getting the credentials specified by the ProviderConfig. +// 4. Using the credentials to form a client. +func (c *connector) Connect(ctx context.Context, mg resource.Managed) (managed.ExternalClient, error) { + logger := c.logger.WithValues("method", "connect") + logger.Debug("Start Connect") + cr, ok := mg.(*v1alpha1.TaskDefinition) + if !ok { + return nil, errors.New(errNotTaskDefinition) + } + + if err := c.usage.Track(ctx, mg); err != nil { + return nil, errors.Wrap(err, errTrackPCUsage) + } + + pc := &apisv1alpha1.ProviderConfig{} + if err := c.kube.Get(ctx, types.NamespacedName{Name: cr.GetProviderConfigReference().Name}, pc); err != nil { + return nil, errors.Wrap(err, errGetPC) + } + + cd := pc.Spec.Credentials + data, err := resource.CommonCredentialExtractor(ctx, cd.Source, c.kube, cd.CommonCredentialSelectors) + if err != nil { + return nil, errors.Wrap(err, errGetCreds) + } + + svc, err := c.newServiceFn(data) + if err != nil { + return nil, errors.Wrap(err, errNewClient) + } + logger.Debug("Connected") + return &external{service: svc, logger: c.logger}, nil +} + +// An ExternalClient observes, then either creates, updates, or deletes an +// external resource to ensure it reflects the managed resource's desired state. +type external struct { + // A 'client' used to connect to the external resource API. In practice this + // would be something like an AWS SDK client. + service clients.TaskDefinitionService + logger logging.Logger +} + +func (c *external) Observe(ctx context.Context, mg resource.Managed) (managed.ExternalObservation, error) { + logger := c.logger.WithValues("method", "observe") + logger.Debug("Start observe") + cr, ok := mg.(*v1alpha1.TaskDefinition) + if !ok { + return managed.ExternalObservation{}, errors.New(errNotTaskDefinition) + } + + c.logger.Debug("ExternalName: '" + meta.GetExternalName(cr) + "'") + + uniqueId := createUniqueIdentifier(&cr.Spec.ForProvider) + + observed, err := c.service.DescribeTaskDefinition(ctx, &cr.Spec.ForProvider) + if err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, errDescribe) + } + + if observed == nil { + c.logger.Debug("Managed resource '" + uniqueId + "' does not exist") + return managed.ExternalObservation{ + ResourceExists: false, + ResourceUpToDate: false, + ConnectionDetails: managed.ConnectionDetails{}, + }, nil + } + + c.logger.Debug("Found '" + uniqueId + "'") + + // Update Status + cr.Status.AtProvider = *observed + cr.SetConditions(xpv1.Available().WithMessage("TaskDefinition exists")) + + observedCompareable, err := c.service.MapToTaskDefinitionCompare(observed) + if err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, errMapping) + } + + specCompareable, err := c.service.MapToTaskDefinitionCompare(&cr.Spec.ForProvider) + if err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, errMapping) + } + + diff := "" + resourceUpToDate := cmp.Equal(specCompareable, observedCompareable) + + // Compare Spec with observed + if !resourceUpToDate { + diff = cmp.Diff(specCompareable, observedCompareable) + } + c.logger.Debug("Managed resource '" + uniqueId + "' upToDate: " + strconv.FormatBool(resourceUpToDate) + "") + + return managed.ExternalObservation{ + ResourceExists: true, + ResourceUpToDate: resourceUpToDate, + Diff: diff, + ResourceLateInitialized: false, + ConnectionDetails: managed.ConnectionDetails{}, + }, nil +} + +func createUniqueIdentifier(app *v1alpha1.TaskDefinitionParameters) string { + return app.Name +} + +func (c *external) Create(ctx context.Context, mg resource.Managed) (managed.ExternalCreation, error) { + logger := c.logger.WithValues("method", "create") + logger.Debug("Start create") + cr, ok := mg.(*v1alpha1.TaskDefinition) + if !ok { + return managed.ExternalCreation{}, errors.New(errNotTaskDefinition) + } + + err := c.service.CreateTaskDefinition(ctx, &cr.Spec.ForProvider) + + if err != nil { + return managed.ExternalCreation{}, errors.Wrap(err, errCreate) + } + + uniqueId := createUniqueIdentifier(&cr.Spec.ForProvider) + meta.SetExternalName(cr, uniqueId) + c.logger.Debug("Managed resource '" + uniqueId + "' created") + + return managed.ExternalCreation{ + // Optionally return any details that may be required to connect to the + // external resource. These will be stored as the connection secret. + ConnectionDetails: managed.ConnectionDetails{}, + }, nil +} + +func (c *external) Update(ctx context.Context, mg resource.Managed) (managed.ExternalUpdate, error) { + logger := c.logger.WithValues("method", "update") + logger.Debug("Start update") + cr, ok := mg.(*v1alpha1.TaskDefinition) + if !ok { + return managed.ExternalUpdate{}, errors.New(errNotTaskDefinition) + } + + err := c.service.UpdateTaskDefinition(ctx, &cr.Spec.ForProvider) + + if err != nil { + return managed.ExternalUpdate{}, errors.Wrap(err, errUpdate) + } + + uniqueId := createUniqueIdentifier(&cr.Spec.ForProvider) + c.logger.Debug("Managed resource '" + uniqueId + "' updated") + return managed.ExternalUpdate{ + // Optionally return any details that may be required to connect to the + // external resource. These will be stored as the connection secret. + ConnectionDetails: managed.ConnectionDetails{}, + }, nil +} + +func (c *external) Delete(ctx context.Context, mg resource.Managed) error { + logger := c.logger.WithValues("method", "delete") + logger.Debug("Start delete") + cr, ok := mg.(*v1alpha1.TaskDefinition) + if !ok { + return errors.New(errNotTaskDefinition) + } + + err := c.service.DeleteTaskDefinition(ctx, &cr.Spec.ForProvider) + + if err != nil { + return errors.Wrap(err, errDelete) + } + + uniqueId := createUniqueIdentifier(&cr.Spec.ForProvider) + c.logger.Debug("Managed resource '" + uniqueId + "' deleted") + return nil +} diff --git a/package/crds/core.springclouddataflow.crossplane.io_applications.yaml b/package/crds/core.springclouddataflow.crossplane.io_applications.yaml index 737f20b..068becc 100644 --- a/package/crds/core.springclouddataflow.crossplane.io_applications.yaml +++ b/package/crds/core.springclouddataflow.crossplane.io_applications.yaml @@ -69,8 +69,13 @@ spec: a Application. properties: bootVersion: + description: BootVersion of the Application (immutable) type: string + x-kubernetes-validations: + - message: BootVersion is immutable + rule: self == oldSelf defaultVersion: + description: Is this Application the Default type: boolean name: description: Name of the Application (immutable) @@ -88,12 +93,20 @@ spec: - task type: string x-kubernetes-validations: - - message: Name is immutable + - message: Type is immutable rule: self == oldSelf uri: + description: Uri of the Application (immutable) type: string + x-kubernetes-validations: + - message: Uri is immutable + rule: self == oldSelf version: + description: Version of the Application (immutable) type: string + x-kubernetes-validations: + - message: Version is immutable + rule: self == oldSelf required: - bootVersion - defaultVersion diff --git a/package/crds/core.springclouddataflow.crossplane.io_taskdefinitions.yaml b/package/crds/core.springclouddataflow.crossplane.io_taskdefinitions.yaml new file mode 100644 index 0000000..634b787 --- /dev/null +++ b/package/crds/core.springclouddataflow.crossplane.io_taskdefinitions.yaml @@ -0,0 +1,360 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.1 + name: taskdefinitions.core.springclouddataflow.crossplane.io +spec: + group: core.springclouddataflow.crossplane.io + names: + categories: + - crossplane + - managed + - springclouddataflow + kind: TaskDefinition + listKind: TaskDefinitionList + plural: taskdefinitions + singular: taskdefinition + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: A TaskDefinition is an example API type. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: A TaskDefinitionSpec defines the desired state of a TaskDefinition. + properties: + deletionPolicy: + default: Delete + description: 'DeletionPolicy specifies what will happen to the underlying + external when this managed resource is deleted - either "Delete" + or "Orphan" the external resource. This field is planned to be deprecated + in favor of the ManagementPolicies field in a future release. Currently, + both could be set independently and non-default values would be + honored if the feature flag is enabled. See the design doc for more + information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223' + enum: + - Orphan + - Delete + type: string + forProvider: + description: TaskDefinitionParameters are the configurable fields + of a TaskDefinition. + properties: + definition: + description: The definition for the task, using Data Flow DSL + (immutable) + type: string + x-kubernetes-validations: + - message: Definition is immutable + rule: self == oldSelf + description: + description: Description of the task definition (immutable) + type: string + x-kubernetes-validations: + - message: Description is immutable + rule: self == oldSelf + name: + description: Name of the task definition (immutable) + type: string + x-kubernetes-validations: + - message: Name is immutable + rule: self == oldSelf + required: + - definition + - description + - name + type: object + managementPolicies: + default: + - '*' + description: 'THIS IS AN ALPHA FIELD. Do not use it in production. + It is not honored unless the relevant Crossplane feature flag is + enabled, and may be changed or removed without notice. ManagementPolicies + specify the array of actions Crossplane is allowed to take on the + managed and external resources. This field is planned to replace + the DeletionPolicy field in a future release. Currently, both could + be set independently and non-default values would be honored if + the feature flag is enabled. If both are custom, the DeletionPolicy + field will be ignored. See the design doc for more information: + https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md' + items: + description: A ManagementAction represents an action that the Crossplane + controllers can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + name: default + description: ProviderConfigReference specifies how the provider that + will be used to create, observe, update, and delete this managed + resource should be configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + providerRef: + description: 'ProviderReference specifies the provider that will be + used to create, observe, update, and delete this managed resource. + Deprecated: Please use ProviderConfigReference, i.e. `providerConfigRef`' + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: PublishConnectionDetailsTo specifies the connection secret + config which contains a name, metadata and a reference to secret + store config to which any connection details for this managed resource + should be written. Connection details frequently include the endpoint, + username, and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: SecretStoreConfigRef specifies which secret store + config should be used for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the annotations to be added to + connection secret. - For Kubernetes secrets, this will be + used as "metadata.annotations". - It is up to Secret Store + implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: Labels are the labels/tags to be added to connection + secret. - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store + types. + type: object + type: + description: Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: WriteConnectionSecretToReference specifies the namespace + and name of a Secret to which any connection details for this managed + resource should be written. Connection details frequently include + the endpoint, username, and password required to connect to the + managed resource. This field is planned to be replaced in a future + release in favor of PublishConnectionDetailsTo. Currently, both + could be set independently and connection details would be published + to both without affecting each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + status: + description: A TaskDefinitionStatus represents the observed state of a + TaskDefinition. + properties: + atProvider: + description: TaskDefinitionObservation are the observable fields of + a TaskDefinition. + properties: + composed: + type: boolean + composedTaskElement: + type: boolean + definition: + type: string + description: + type: string + name: + type: string + status: + type: string + required: + - composed + - composedTaskElement + - definition + - description + - name + - status + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time this condition + transitioned from one status to another. + format: date-time + type: string + message: + description: A Message containing details about this condition's + last transition from one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: Type of this condition. At most one of each condition + type may apply to a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {}