Skip to content

Commit ca63b19

Browse files
committed
feat: define CRD Dataset and VersionedDataset
Signed-off-by: bjwswang <[email protected]>
1 parent 8de4d5a commit ca63b19

32 files changed

+1318
-7
lines changed

PROJECT

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Code generated by tool. DO NOT EDIT.
2-
# This file is used to track the info used to scaffold your project
3-
# and allow the plugins properly work.
4-
# More info: https://book.kubebuilder.io/reference/project-config.html
51
componentConfig: true
62
domain: kubeagi.k8s.com.cn
73
layout:
@@ -58,4 +54,22 @@ resources:
5854
kind: Embedders
5955
path: github.com/kubeagi/arcadia/api/v1alpha1
6056
version: v1alpha1
57+
- api:
58+
crdVersion: v1
59+
namespaced: true
60+
controller: true
61+
domain: kubeagi.k8s.com.cn
62+
group: arcadia
63+
kind: Dataset
64+
path: github.com/kubeagi/arcadia/api/v1alpha1
65+
version: v1alpha1
66+
- api:
67+
crdVersion: v1
68+
namespaced: true
69+
controller: true
70+
domain: kubeagi.k8s.com.cn
71+
group: arcadia
72+
kind: VersionedDataset
73+
path: github.com/kubeagi/arcadia/api/v1alpha1
74+
version: v1alpha1
6175
version: "3"

api/v1alpha1/condition.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type ConditionReason string
4242

4343
// Some common Condition reasons.
4444
const (
45+
ReasonPublished ConditionReason = "Published"
4546
ReasonAvailable ConditionReason = "Available"
4647
ReasonUnavailable ConditionReason = "Unavailable"
4748
ReasonCreating ConditionReason = "Creating"

api/v1alpha1/dataset.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright 2023 KubeAGI.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
type DatasetContentType string
20+
21+
const (
22+
DatasetContentTypeText DatasetContentType = "text"
23+
DatasetContentTypeImage DatasetContentType = "image"
24+
DatasetContentTypeVoice DatasetContentType = "voice"
25+
DatasetContentTypeVideo DatasetContentType = "video"
26+
)
27+
28+
var (
29+
// LabelDatasetScene defines the content type of this dataset
30+
LabelDatasetContentType = Group + "/content-type"
31+
// LabelDatasetBestCase defines the best case to use this dataset
32+
LabelDatasetBestCase = Group + "/best-case"
33+
)

api/v1alpha1/dataset_types.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
Copyright 2023 KubeAGI.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// DatasetSpec defines the desired state of Dataset
27+
type DatasetSpec struct {
28+
// Creator defines dataset creator(AUTO-FILLED by webhook)
29+
Creator string `json:"creator,omitempty"`
30+
31+
// DisplayName defines dataset display name
32+
DiplayName string `json:"displayName"`
33+
34+
// ContentType defines dataset
35+
ContentType string `json:"contentType"`
36+
37+
// bestCase defines the best case to use this dataset
38+
BestCase string `json:"bestCase,omitempty"`
39+
}
40+
41+
// DatasetStatus defines the observed state of Dataset
42+
type DatasetStatus struct {
43+
// ConditionedStatus is the current status
44+
ConditionedStatus `json:",inline"`
45+
}
46+
47+
//+kubebuilder:object:root=true
48+
//+kubebuilder:subresource:status
49+
//+kubebuilder:printcolumn:name="display-name",type=string,JSONPath=`.spec.displayName`
50+
//+kubebuilder:printcolumn:name="type",type=string,JSONPath=`.spec.contentType`
51+
52+
// Dataset is the Schema for the datasets API
53+
type Dataset struct {
54+
metav1.TypeMeta `json:",inline"`
55+
metav1.ObjectMeta `json:"metadata,omitempty"`
56+
57+
Spec DatasetSpec `json:"spec,omitempty"`
58+
Status DatasetStatus `json:"status,omitempty"`
59+
}
60+
61+
//+kubebuilder:object:root=true
62+
63+
// DatasetList contains a list of Dataset
64+
type DatasetList struct {
65+
metav1.TypeMeta `json:",inline"`
66+
metav1.ListMeta `json:"metadata,omitempty"`
67+
Items []Dataset `json:"items"`
68+
}
69+
70+
func init() {
71+
SchemeBuilder.Register(&Dataset{}, &DatasetList{})
72+
}

api/v1alpha1/datasource_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type DatasourceSpec struct {
2929
Creator string `json:"creator,omitempty"`
3030

3131
// DisplayName defines datasource display name
32-
DiplayName string `json:"displayName,omitempty"`
32+
DiplayName string `json:"displayName"`
3333

3434
// Description defines datasource description
3535
Description string `json:"description,omitempty"`

api/v1alpha1/versioneddataset.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright 2023 KubeAGI.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
var (
20+
LabelVersionedDatasetVersion = Group + "/version"
21+
)
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
Copyright 2023 KubeAGI.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
type File struct {
27+
// From defines the datasource which provides this `File`
28+
From *TypedObjectReference `json:"from"`
29+
// Path defines the detail path to get this `File`
30+
Path string `json:"path"`
31+
}
32+
33+
type FileStatus struct {
34+
// UploadCondition records the status of file upload
35+
UploadCondition Condition `json:"uploadCondition,omitempty"`
36+
// ProcessCondition records the status of data processing
37+
ProcessCondition Condition `json:"processCondition,omitempty"`
38+
}
39+
40+
// VersionedDatasetSpec defines the desired state of VersionedDataset
41+
type VersionedDatasetSpec struct {
42+
// Dataset which this `VersionedDataset` belongs to
43+
Dataset *TypedObjectReference `json:"dataset"`
44+
45+
// Version
46+
Version string `json:"version"`
47+
48+
// Files included in this `VersionedDataset`
49+
Files []File `json:"files,omitempty"`
50+
}
51+
52+
// VersionedDatasetStatus defines the observed state of VersionedDataset
53+
type VersionedDatasetStatus struct {
54+
// ConditionedStatus is the current status
55+
ConditionedStatus `json:",inline"`
56+
57+
// FilesStatus contains the status to all files in VersionedDatasetSpec
58+
FilesStatus []FileStatus `json:"filesStatus,omitempty"`
59+
}
60+
61+
//+kubebuilder:object:root=true
62+
//+kubebuilder:subresource:status
63+
//+kubebuilder:printcolumn:name="dataset",type=string,JSONPath=`.spec.dataset.name`
64+
//+kubebuilder:printcolumn:name="version",type=string,JSONPath=`.spec.version`
65+
66+
// VersionedDataset is the Schema for the versioneddatasets API
67+
type VersionedDataset struct {
68+
metav1.TypeMeta `json:",inline"`
69+
metav1.ObjectMeta `json:"metadata,omitempty"`
70+
71+
Spec VersionedDatasetSpec `json:"spec,omitempty"`
72+
Status VersionedDatasetStatus `json:"status,omitempty"`
73+
}
74+
75+
//+kubebuilder:object:root=true
76+
77+
// VersionedDatasetList contains a list of VersionedDataset
78+
type VersionedDatasetList struct {
79+
metav1.TypeMeta `json:",inline"`
80+
metav1.ListMeta `json:"metadata,omitempty"`
81+
Items []VersionedDataset `json:"items"`
82+
}
83+
84+
func init() {
85+
SchemeBuilder.Register(&VersionedDataset{}, &VersionedDatasetList{})
86+
}

0 commit comments

Comments
 (0)