|
| 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