Skip to content

Commit ba39a81

Browse files
committed
Add EditorTemplate to editor.ui.k8s.appscode.com/v1alpha1
EditorTemplate is a read-only, create-only action resource that loads the editor model, manifest and resources for an existing installation identified by its metadata. It wraps kubepack.dev/lib-app/pkg/editor.LoadResourceEditorModel (chart_template.go loadEditorModel2) and is served by kube-ui-server under a new editor.ui.k8s.appscode.com API group. Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent f84247f commit ba39a81

19 files changed

Lines changed: 21465 additions & 1 deletion

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ COMPRESS ?= no
2323
# CRD_OPTIONS ?= "crd:trivialVersions=true"
2424
CRD_OPTIONS ?= "crd:allowDangerousTypes=true,crdVersions={v1}"
2525
CODE_GENERATOR_IMAGE ?= ghcr.io/appscode/gengo:release-1.32
26-
API_GROUPS ?= core:v1alpha1 identity:v1alpha1 management:v1alpha1 meta:v1alpha1 node:v1alpha1 ui:v1alpha1
26+
API_GROUPS ?= core:v1alpha1 editor:v1alpha1 identity:v1alpha1 management:v1alpha1 meta:v1alpha1 node:v1alpha1 ui:v1alpha1
2727

2828
# Where to push the docker image.
2929
REGISTRY ?= appscode

apis/editor/doc.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright AppsCode Inc. and Contributors
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 editor
18+
19+
const (
20+
GroupName = "editor.ui.k8s.appscode.com"
21+
)

apis/editor/install/install.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
Copyright AppsCode Inc. and Contributors
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 install
18+
19+
import (
20+
"kmodules.xyz/resource-metadata/apis/editor/v1alpha1"
21+
22+
"k8s.io/apimachinery/pkg/runtime"
23+
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
24+
)
25+
26+
// Install registers the API group and adds types to a scheme
27+
func Install(scheme *runtime.Scheme) {
28+
utilruntime.Must(v1alpha1.AddToScheme(scheme))
29+
utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion))
30+
}

apis/editor/v1alpha1/doc.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright AppsCode Inc. and Contributors
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 is the v1alpha1 version of the API.
18+
19+
// +k8s:deepcopy-gen=package,register
20+
// +k8s:openapi-gen=true
21+
// +k8s:defaulter-gen=TypeMeta
22+
// +groupName=editor.ui.k8s.appscode.com
23+
package v1alpha1
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
Copyright AppsCode Inc. and Contributors
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+
"k8s.io/apimachinery/pkg/runtime"
22+
releasesapi "x-helm.dev/apimachinery/apis/releases/v1alpha1"
23+
)
24+
25+
const (
26+
ResourceKindEditorTemplate = "EditorTemplate"
27+
ResourceEditorTemplate = "editortemplate"
28+
ResourceEditorTemplates = "editortemplates"
29+
)
30+
31+
// EditorTemplate loads the editor model, manifest and resources for an existing
32+
// installation identified by its metadata. It is the aggregated-API equivalent
33+
// of kubepack.dev/lib-app/pkg/editor.LoadResourceEditorModel (see
34+
// chart_template.go loadEditorModel2).
35+
//
36+
// +genclient
37+
// +genclient:nonNamespaced
38+
// +genclient:onlyVerbs=create
39+
// +k8s:openapi-gen=true
40+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
41+
// +kubebuilder:object:root=true
42+
// +kubebuilder:resource:scope=Cluster
43+
type EditorTemplate struct {
44+
metav1.TypeMeta `json:",inline"`
45+
// Request identifies the installation to load.
46+
// +optional
47+
Request *EditorTemplateRequest `json:"request,omitempty"`
48+
// Response holds the loaded editor template.
49+
// +optional
50+
Response *EditorTemplateResponse `json:"response,omitempty"`
51+
}
52+
53+
type EditorTemplateRequest struct {
54+
releasesapi.ModelMetadata `json:",inline"`
55+
// ChartRef optionally selects the chart source. When unset, the resource
56+
// editor chart resolved from the metadata resource is used.
57+
// +optional
58+
ChartRef *releasesapi.ChartSourceFlatRef `json:"chartRef,omitempty"`
59+
}
60+
61+
type EditorTemplateResponse struct {
62+
// Manifest is the rendered manifest of the existing installation.
63+
// +optional
64+
Manifest string `json:"manifest,omitempty"`
65+
// Values is the editor model (values) of the existing installation.
66+
// +optional
67+
Values *runtime.RawExtension `json:"values,omitempty"`
68+
// Resources holds the individual resources of the existing installation.
69+
// +optional
70+
Resources []EditorTemplateResource `json:"resources,omitempty"`
71+
}
72+
73+
type EditorTemplateResource struct {
74+
// +optional
75+
Filename string `json:"filename,omitempty"`
76+
// +optional
77+
Key string `json:"key,omitempty"`
78+
// +optional
79+
Data *runtime.RawExtension `json:"data,omitempty"`
80+
}

0 commit comments

Comments
 (0)