Skip to content

Commit

Permalink
feat: define CRD Dataset and VersionedDataset
Browse files Browse the repository at this point in the history
Signed-off-by: bjwswang <bjwswang@gmail.com>
  • Loading branch information
bjwswang committed Oct 31, 2023
1 parent 8de4d5a commit ca63b19
Show file tree
Hide file tree
Showing 32 changed files with 1,318 additions and 7 deletions.
22 changes: 18 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
componentConfig: true
domain: kubeagi.k8s.com.cn
layout:
Expand Down Expand Up @@ -58,4 +54,22 @@ resources:
kind: Embedders
path: github.com/kubeagi/arcadia/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: kubeagi.k8s.com.cn
group: arcadia
kind: Dataset
path: github.com/kubeagi/arcadia/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: kubeagi.k8s.com.cn
group: arcadia
kind: VersionedDataset
path: github.com/kubeagi/arcadia/api/v1alpha1
version: v1alpha1
version: "3"
1 change: 1 addition & 0 deletions api/v1alpha1/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type ConditionReason string

// Some common Condition reasons.
const (
ReasonPublished ConditionReason = "Published"
ReasonAvailable ConditionReason = "Available"
ReasonUnavailable ConditionReason = "Unavailable"
ReasonCreating ConditionReason = "Creating"
Expand Down
33 changes: 33 additions & 0 deletions api/v1alpha1/dataset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2023 KubeAGI.
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

type DatasetContentType string

const (
DatasetContentTypeText DatasetContentType = "text"
DatasetContentTypeImage DatasetContentType = "image"
DatasetContentTypeVoice DatasetContentType = "voice"
DatasetContentTypeVideo DatasetContentType = "video"
)

var (
// LabelDatasetScene defines the content type of this dataset
LabelDatasetContentType = Group + "/content-type"
// LabelDatasetBestCase defines the best case to use this dataset
LabelDatasetBestCase = Group + "/best-case"
)
72 changes: 72 additions & 0 deletions api/v1alpha1/dataset_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
Copyright 2023 KubeAGI.
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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// DatasetSpec defines the desired state of Dataset
type DatasetSpec struct {
// Creator defines dataset creator(AUTO-FILLED by webhook)
Creator string `json:"creator,omitempty"`

// DisplayName defines dataset display name
DiplayName string `json:"displayName"`

// ContentType defines dataset
ContentType string `json:"contentType"`

// bestCase defines the best case to use this dataset
BestCase string `json:"bestCase,omitempty"`
}

// DatasetStatus defines the observed state of Dataset
type DatasetStatus struct {
// ConditionedStatus is the current status
ConditionedStatus `json:",inline"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="display-name",type=string,JSONPath=`.spec.displayName`
//+kubebuilder:printcolumn:name="type",type=string,JSONPath=`.spec.contentType`

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

Spec DatasetSpec `json:"spec,omitempty"`
Status DatasetStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&Dataset{}, &DatasetList{})
}
2 changes: 1 addition & 1 deletion api/v1alpha1/datasource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type DatasourceSpec struct {
Creator string `json:"creator,omitempty"`

// DisplayName defines datasource display name
DiplayName string `json:"displayName,omitempty"`
DiplayName string `json:"displayName"`

// Description defines datasource description
Description string `json:"description,omitempty"`
Expand Down
21 changes: 21 additions & 0 deletions api/v1alpha1/versioneddataset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2023 KubeAGI.
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

var (
LabelVersionedDatasetVersion = Group + "/version"
)
86 changes: 86 additions & 0 deletions api/v1alpha1/versioneddataset_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
Copyright 2023 KubeAGI.
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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

type File struct {
// From defines the datasource which provides this `File`
From *TypedObjectReference `json:"from"`
// Path defines the detail path to get this `File`
Path string `json:"path"`
}

type FileStatus struct {
// UploadCondition records the status of file upload
UploadCondition Condition `json:"uploadCondition,omitempty"`
// ProcessCondition records the status of data processing
ProcessCondition Condition `json:"processCondition,omitempty"`
}

// VersionedDatasetSpec defines the desired state of VersionedDataset
type VersionedDatasetSpec struct {
// Dataset which this `VersionedDataset` belongs to
Dataset *TypedObjectReference `json:"dataset"`

// Version
Version string `json:"version"`

// Files included in this `VersionedDataset`
Files []File `json:"files,omitempty"`
}

// VersionedDatasetStatus defines the observed state of VersionedDataset
type VersionedDatasetStatus struct {
// ConditionedStatus is the current status
ConditionedStatus `json:",inline"`

// FilesStatus contains the status to all files in VersionedDatasetSpec
FilesStatus []FileStatus `json:"filesStatus,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="dataset",type=string,JSONPath=`.spec.dataset.name`
//+kubebuilder:printcolumn:name="version",type=string,JSONPath=`.spec.version`

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

Spec VersionedDatasetSpec `json:"spec,omitempty"`
Status VersionedDatasetStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&VersionedDataset{}, &VersionedDatasetList{})
}
Loading

0 comments on commit ca63b19

Please sign in to comment.