Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync main branch with Apache main branch #5

Merged
merged 5 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Deploy operator
run: |
make deploy IMG=${{ env.OPERATOR_IMAGE_NAME }}
kubectl wait pod -A -l control-plane=controller-manager --for condition=Ready
kubectl wait pod -A -l control-plane=sonataflow-operator --for condition=Ready

- name: Run tests
run: |
Expand Down
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ resources:
kind: SonataFlowPlatform
path: github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08
version: v1alpha08
- api:
crdVersion: v1
controller: true
domain: org
group: sonataflow
kind: SonataFlowClusterPlatform
path: github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08
version: v1alpha08
version: "3"
100 changes: 100 additions & 0 deletions api/v1alpha08/sonataflowclusterplatform_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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 v1alpha08

import (
"github.com/apache/incubator-kie-kogito-serverless-operator/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
// SonataFlowClusterPlatformKind is the Kind name of the SonataFlowClusterPlatform CR
SonataFlowClusterPlatformKind string = "SonataFlowClusterPlatform"
PlatformNotFoundReason string = "PlatformNotFound"
)

// SonataFlowClusterPlatformSpec defines the desired state of SonataFlowClusterPlatform
type SonataFlowClusterPlatformSpec struct {
PlatformRef SonataFlowPlatformRef `json:"platformRef"`
}

// SonataFlowPlatformRef defines which existing SonataFlowPlatform's supporting services should be used cluster-wide.
type SonataFlowPlatformRef struct {
// Name of the SonataFlowPlatform
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Platform_Name"
Name string `json:"name"`
// Namespace of the SonataFlowPlatform
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Platform_NS"
Namespace string `json:"namespace"`
}

// SonataFlowClusterPlatformStatus defines the observed state of SonataFlowClusterPlatform
type SonataFlowClusterPlatformStatus struct {
api.Status `json:",inline"`
// Version the operator version controlling this ClusterPlatform
//+operator-sdk:csv:customresourcedefinitions:type=status,displayName="version"
Version string `json:"version,omitempty"`
}

func (in *SonataFlowClusterPlatformStatus) GetTopLevelConditionType() api.ConditionType {
return api.SucceedConditionType
}

func (in *SonataFlowClusterPlatformStatus) IsReady() bool {
return in.GetTopLevelCondition().IsTrue()
}

func (in *SonataFlowClusterPlatformStatus) GetTopLevelCondition() *api.Condition {
return in.GetCondition(in.GetTopLevelConditionType())
}

func (in *SonataFlowClusterPlatformStatus) Manager() api.ConditionsManager {
return api.NewConditionManager(in, api.SucceedConditionType)
}

func (in *SonataFlowClusterPlatformStatus) IsDuplicated() bool {
cond := in.GetTopLevelCondition()
return cond.IsFalse() && cond.Reason == PlatformDuplicatedReason
}

// SonataFlowClusterPlatform is the Schema for the sonataflowclusterplatforms API
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:printcolumn:name="Platform_Name",type=string,JSONPath=`.spec.platformRef.name`
// +kubebuilder:printcolumn:name="Platform_NS",type=string,JSONPath=`.spec.platformRef.namespace`
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=='Succeed')].status`
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=='Succeed')].reason`
type SonataFlowClusterPlatform struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec SonataFlowClusterPlatformSpec `json:"spec,omitempty"`
Status SonataFlowClusterPlatformStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&SonataFlowClusterPlatform{}, &SonataFlowClusterPlatformList{})
}
34 changes: 34 additions & 0 deletions api/v1alpha08/sonataflowclusterplatform_types_support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 v1alpha08

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

// NewSonataFlowClusterPlatformList returns an empty list of ClusterPlatform objects
func NewSonataFlowClusterPlatformList() SonataFlowClusterPlatformList {
return SonataFlowClusterPlatformList{
TypeMeta: metav1.TypeMeta{
APIVersion: GroupVersion.String(),
Kind: SonataFlowClusterPlatformKind,
},
}
}
8 changes: 4 additions & 4 deletions api/v1alpha08/sonataflowplatform_services_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@

package v1alpha08

// ServicesPlatformSpec describes the desired service configuration for "prod" workflows.
// ServicesPlatformSpec describes the desired service configuration for workflows without the `sonataflow.org/profile: dev` annotation.
type ServicesPlatformSpec struct {
// Deploys the Data Index service for use by "prod" profile workflows.
// Deploys the Data Index service for use by workflows without the `sonataflow.org/profile: dev` annotation.
// +optional
DataIndex *ServiceSpec `json:"dataIndex,omitempty"`
// Deploys the Job service for use by "prod" profile workflows.
// Deploys the Job service for use by workflows without the `sonataflow.org/profile: dev` annotation.
// +optional
JobService *ServiceSpec `json:"jobService,omitempty"`
}

// ServiceSpec defines the desired state of a platform service
// +k8s:openapi-gen=true
type ServiceSpec struct {
// Determines whether "prod" profile workflows should be configured to use this service
// Determines whether workflows without the `sonataflow.org/profile: dev` annotation should be configured to use this service
// +optional
Enabled *bool `json:"enabled,omitempty"`
// Persists service to a datasource of choice. Ephemeral by default.
Expand Down
37 changes: 33 additions & 4 deletions api/v1alpha08/sonataflowplatform_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ type SonataFlowPlatformSpec struct {
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="DevMode"
DevMode DevModePlatformSpec `json:"devMode,omitempty"`
// Services attributes for deploying supporting applications like Data Index.
// Only workflows with the proper annotation will be configured to use these service(s).
// `sonataflow.org/profile: prod`
// Services attributes for deploying supporting applications like Data Index & Job Service.
// Only workflows without the `sonataflow.org/profile: dev` annotation will be configured to use these service(s).
// Setting this will override the use of any cluster-scoped services that might be defined via `SonataFlowClusterPlatform`.
// +optional
Services ServicesPlatformSpec `json:"services,omitempty"`
Services *ServicesPlatformSpec `json:"services,omitempty"`
}

// PlatformCluster is the kind of orchestration cluster the platform is installed into
Expand Down Expand Up @@ -79,6 +79,35 @@ type SonataFlowPlatformStatus struct {
// Info generic information related to the build
//+operator-sdk:csv:customresourcedefinitions:type=status,displayName="info"
Info map[string]string `json:"info,omitempty"`
// ClusterPlatformRef information related to the (optional) active SonataFlowClusterPlatform
ClusterPlatformRef *SonataFlowClusterPlatformRefStatus `json:"clusterPlatformRef,omitempty"`
}

// SonataFlowClusterPlatformRefStatus information related to the (optional) active SonataFlowClusterPlatform
// +k8s:openapi-gen=true
type SonataFlowClusterPlatformRefStatus struct {
// Name of the active SonataFlowClusterPlatform
Name string `json:"name,omitempty"`
// PlatformRef displays which SonataFlowPlatform has been referenced by the active SonataFlowClusterPlatform
PlatformRef SonataFlowPlatformRef `json:"platformRef,omitempty"`
// Services displays which cluster-wide services are being used by this SonataFlowPlatform
Services *PlatformServicesStatus `json:"services,omitempty"`
}

// PlatformServicesStatus displays which cluster-wide services are being used by a SonataFlowPlatform
// +k8s:openapi-gen=true
type PlatformServicesStatus struct {
// DataIndexRef displays information on the cluster-wide Data Index service
DataIndexRef *PlatformServiceRefStatus `json:"dataIndexRef,omitempty"`
// JobServiceRef displays information on the cluster-wide Job Service
JobServiceRef *PlatformServiceRefStatus `json:"jobServiceRef,omitempty"`
}

// PlatformServiceRefStatus displays information on a cluster-wide service
// +k8s:openapi-gen=true
type PlatformServiceRefStatus struct {
// Url displays the base url of a cluster-wide service
Url string `json:"url,omitempty"`
}

func (in *SonataFlowPlatformStatus) GetTopLevelConditionType() api.ConditionType {
Expand Down
Loading
Loading