github.com/oam-dev/kubevela@v1.9.11/pkg/addon/type.go (about) 1 /* 2 Copyright 2021 The KubeVela Authors. 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 addon 18 19 import ( 20 "github.com/getkin/kin-openapi/openapi3" 21 22 "github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1" 23 "github.com/oam-dev/kubevela/pkg/utils/schema" 24 ) 25 26 // UIData contains all information represent an addon for UI 27 type UIData struct { 28 Meta 29 30 APISchema *openapi3.Schema `json:"schema"` 31 UISchema []*schema.UIParameter `json:"uiSchema"` 32 33 // Detail is README.md in an addon 34 Detail string `json:"detail,omitempty"` 35 36 Definitions []ElementFile `json:"definitions"` 37 CUEDefinitions []ElementFile `json:"CUEDefinitions"` 38 ConfigTemplates []ElementFile `json:"configTemplates"` 39 Parameters string `json:"parameters"` 40 GlobalParameters string `json:"globalParameters"` 41 RegistryName string `json:"registryName"` 42 43 AvailableVersions []string `json:"availableVersions"` 44 } 45 46 // InstallPackage contains all necessary files that can be installed for an addon 47 type InstallPackage struct { 48 Meta 49 50 // Definitions and CUEDefinitions are converted as OAM X-Definitions, they will only in control plane cluster 51 Definitions []ElementFile `json:"definitions"` 52 CUEDefinitions []ElementFile `json:"CUEDefinitions"` 53 54 ConfigTemplates []ElementFile `json:"configTemplates"` 55 56 // YAMLViews and CUEViews are the instances of velaql, they will only in control plane cluster 57 YAMLViews []ElementFile `json:"YAMLViews"` 58 CUEViews []ElementFile `json:"CUEViews"` 59 // DefSchemas are UI schemas read by VelaUX, it will only be installed in control plane clusters 60 DefSchemas []ElementFile `json:"defSchemas,omitempty"` 61 62 Parameters string `json:"parameters"` 63 64 // CUETemplates and YAMLTemplates are resources needed to be installed in managed clusters 65 CUETemplates []ElementFile `json:"CUETemplates"` 66 YAMLTemplates []ElementFile `json:"YAMLTemplates,omitempty"` 67 AppTemplate *v1beta1.Application `json:"appTemplate"` 68 AppCueTemplate ElementFile `json:"appCueTemplate,omitempty"` 69 Notes ElementFile `json:"notes,omitempty"` 70 } 71 72 // WholeAddonPackage contains all infos of an addon 73 type WholeAddonPackage struct { 74 InstallPackage 75 76 APISchema *openapi3.Schema `json:"schema"` 77 78 // Detail is README.md in an addon 79 Detail string `json:"detail,omitempty"` 80 AvailableVersions []string `json:"availableVersions"` 81 RegistryName string `json:"registryName"` 82 } 83 84 // Meta defines the format for a single addon 85 type Meta struct { 86 Name string `json:"name" validate:"required"` 87 Version string `json:"version"` 88 Description string `json:"description"` 89 Icon string `json:"icon"` 90 URL string `json:"url,omitempty"` 91 Tags []string `json:"tags,omitempty"` 92 // UXPlugins used for velaux plugins download/install with the use of addon registry. 93 UXPlugins map[string]string `json:"uxPlugins,omitempty"` 94 DeployTo *DeployTo `json:"deployTo,omitempty"` 95 Dependencies []*Dependency `json:"dependencies,omitempty"` 96 NeedNamespace []string `json:"needNamespace,omitempty"` 97 Invisible bool `json:"invisible"` 98 SystemRequirements *SystemRequirements `json:"system,omitempty"` 99 // Annotations used for addon maintainers to add their own description or extensions to metadata. 100 Annotations map[string]string `json:"annotations,omitempty"` 101 } 102 103 // DeployTo defines where the addon to deploy to 104 type DeployTo struct { 105 // This field keep the compatible for older case 106 LegacyRuntimeCluster bool `json:"runtime_cluster,omitempty"` 107 DisableControlPlane bool `json:"disableControlPlane"` 108 RuntimeCluster bool `json:"runtimeCluster"` 109 } 110 111 // Dependency defines the other addons it depends on 112 type Dependency struct { 113 Name string `json:"name,omitempty"` 114 Version string `json:"version,omitempty"` 115 } 116 117 // ElementFile can be addon's definition or addon's component 118 type ElementFile struct { 119 Data string 120 Name string 121 } 122 123 // SystemRequirements is this addon need version 124 type SystemRequirements struct { 125 VelaVersion string `json:"vela,omitempty"` 126 KubernetesVersion string `json:"kubernetes,omitempty"` 127 }