Skip to content
Closed
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ COMPRESS ?= no
# CRD_OPTIONS ?= "crd:trivialVersions=true"
CRD_OPTIONS ?= "crd:allowDangerousTypes=true,crdVersions={v1}"
CODE_GENERATOR_IMAGE ?= ghcr.io/appscode/gengo:release-1.32
API_GROUPS ?= core:v1alpha1 identity:v1alpha1 management:v1alpha1 meta:v1alpha1 node:v1alpha1 ui:v1alpha1
API_GROUPS ?= core:v1alpha1 editor:v1alpha1 identity:v1alpha1 management:v1alpha1 meta:v1alpha1 node:v1alpha1 ui:v1alpha1

# Where to push the docker image.
REGISTRY ?= appscode
Expand Down
21 changes: 21 additions & 0 deletions apis/editor/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright AppsCode Inc. and Contributors

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 editor

const (
GroupName = "editor.ui.k8s.appscode.com"
)
30 changes: 30 additions & 0 deletions apis/editor/install/install.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright AppsCode Inc. and Contributors

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 install

import (
"kmodules.xyz/resource-metadata/apis/editor/v1alpha1"

"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
)

// Install registers the API group and adds types to a scheme
func Install(scheme *runtime.Scheme) {
utilruntime.Must(v1alpha1.AddToScheme(scheme))
utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion))
}
30 changes: 30 additions & 0 deletions apis/editor/install/roundtrip_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright AppsCode Inc. and Contributors

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 install

import (
"testing"

"k8s.io/apimachinery/pkg/api/apitesting/roundtrip"
)

func TestRoundTripTypes(t *testing.T) {
if testing.Short() {
t.Skip("skipping testing in short mode")
}
roundtrip.RoundTripTestForAPIGroup(t, Install, nil)
}
23 changes: 23 additions & 0 deletions apis/editor/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright AppsCode Inc. and Contributors

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 is the v1alpha1 version of the API.

// +k8s:deepcopy-gen=package,register
// +k8s:openapi-gen=true
// +k8s:defaulter-gen=TypeMeta
// +groupName=editor.ui.k8s.appscode.com
package v1alpha1
90 changes: 90 additions & 0 deletions apis/editor/v1alpha1/editor_render_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
Copyright AppsCode Inc. and Contributors

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"
"k8s.io/apimachinery/pkg/runtime"
releasesapi "x-helm.dev/apimachinery/apis/releases/v1alpha1"
)

const (
ResourceKindEditorRender = "EditorRender"
ResourceEditorRender = "editorrender"
ResourceEditorRenders = "editorrenders"
)

// EditorOutput selects which artifact an editor render/template request returns.
type EditorOutput string

const (
// EditorOutputModel returns the editor model (values).
EditorOutputModel EditorOutput = "model"
// EditorOutputManifest returns the rendered YAML manifest.
EditorOutputManifest EditorOutput = "manifest"
// EditorOutputResources returns the parsed CRDs + resources.
EditorOutputResources EditorOutput = "resources"
)

// EditorRender renders an editor model, manifest or resources from a set of
// options, without touching any existing installation. It is the read-only
// aggregated-API equivalent of the b3
// /clusters/{owner}/{cluster}/helm/options/{model,manifest,resources} endpoints.
//
// +genclient
// +genclient:nonNamespaced
// +genclient:onlyVerbs=create
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=editorrenders,singular=editorrender,scope=Cluster
type EditorRender struct {
metav1.TypeMeta `json:",inline"`
// Request describes what to render.
// +optional
Request *EditorRenderRequest `json:"request,omitempty"`
// Response holds the rendered output.
// +optional
Response *EditorRenderResponse `json:"response,omitempty"`
}

type EditorRenderRequest struct {
// ChartRef optionally selects the chart source. When unset, the resource
// editor chart resolved from the options metadata is used.
// +optional
ChartRef *releasesapi.ChartSourceFlatRef `json:"chartRef,omitempty"`
// Options is the editor options model (values) to render from.
// +optional
Options *runtime.RawExtension `json:"options,omitempty"`
// Output selects which artifact to render. Defaults to "resources".
// +optional
Output EditorOutput `json:"output,omitempty"`
// SkipCRDs omits CRDs from the resources output.
// +optional
SkipCRDs bool `json:"skipCRDs,omitempty"`
}

type EditorRenderResponse struct {
// Model is set when Output is "model": the generated editor model (values).
// +optional
Model *runtime.RawExtension `json:"model,omitempty"`
// Manifest is set when Output is "manifest": the rendered YAML manifest.
// +optional
Manifest string `json:"manifest,omitempty"`
// Resources is set when Output is "resources": the rendered CRDs + resources.
// +optional
Resources *releasesapi.ResourceOutput `json:"resources,omitempty"`
}
74 changes: 74 additions & 0 deletions apis/editor/v1alpha1/editor_template_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
Copyright AppsCode Inc. and Contributors

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"
"k8s.io/apimachinery/pkg/runtime"
releasesapi "x-helm.dev/apimachinery/apis/releases/v1alpha1"
)

const (
ResourceKindEditorTemplate = "EditorTemplate"
ResourceEditorTemplate = "editortemplate"
ResourceEditorTemplates = "editortemplates"
)

// EditorTemplate loads the editor model, manifest or resources for an existing
// installation identified by Metadata. It is the read-only aggregated-API
// equivalent of the b3
// /clusters/{owner}/{cluster}/helm/editor/{model,manifest,resources} endpoints.
//
// +genclient
// +genclient:nonNamespaced
// +genclient:onlyVerbs=create
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=editortemplates,singular=editortemplate,scope=Cluster
type EditorTemplate struct {
metav1.TypeMeta `json:",inline"`
// Request identifies the installation and what to load.
// +optional
Request *EditorTemplateRequest `json:"request,omitempty"`
// Response holds the loaded output.
// +optional
Response *EditorTemplateResponse `json:"response,omitempty"`
}

type EditorTemplateRequest struct {
// ChartRef optionally selects the chart source. When unset, the resource
// editor chart resolved from Metadata is used.
// +optional
ChartRef *releasesapi.ChartSourceFlatRef `json:"chartRef,omitempty"`
// Metadata identifies the installed release (resource id + release name/namespace).
Metadata releasesapi.Metadata `json:"metadata"`
// Output selects which artifact to load. Defaults to "resources".
// +optional
Output EditorOutput `json:"output,omitempty"`
}

type EditorTemplateResponse struct {
// Values is set when Output is "model": the editor model (values) of the install.
// +optional
Values *runtime.RawExtension `json:"values,omitempty"`
// Manifest is set when Output is "manifest": the rendered YAML manifest.
// +optional
Manifest string `json:"manifest,omitempty"`
// Resources is set when Output is "resources": the CRDs + resources.
// +optional
Resources *releasesapi.ResourceOutput `json:"resources,omitempty"`
}
Loading
Loading