github.com/oam-dev/kubevela@v1.9.11/apis/types/capability.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 types 18 19 import ( 20 "cuelang.org/go/cue" 21 ) 22 23 // Source record the source of Capability 24 type Source struct { 25 RepoName string `json:"repoName"` 26 ChartName string `json:"chartName,omitempty"` 27 } 28 29 // CRDInfo record the CRD info of the Capability 30 type CRDInfo struct { 31 APIVersion string `json:"apiVersion"` 32 Kind string `json:"kind"` 33 } 34 35 // CapType defines the type of capability 36 type CapType string 37 38 const ( 39 // TypeComponentDefinition represents OAM ComponentDefinition 40 TypeComponentDefinition CapType = "componentDefinition" 41 // TypeWorkload represents OAM Workload 42 TypeWorkload CapType = "workload" 43 // TypeTrait represents OAM Trait 44 TypeTrait CapType = "trait" 45 // TypeWorkflowStep represent OAM Workflow 46 TypeWorkflowStep CapType = "workflowstep" 47 // TypePolicy represent OAM Policy 48 TypePolicy CapType = "policy" 49 ) 50 51 // CapabilityConfigMapNamePrefix is the prefix for capability ConfigMap name 52 const CapabilityConfigMapNamePrefix = "schema-" 53 54 const ( 55 // OpenapiV3JSONSchema is the key to store OpenAPI v3 JSON schema in ConfigMap 56 OpenapiV3JSONSchema string = "openapi-v3-json-schema" 57 // UISchema is the key to store ui custom schema 58 UISchema string = "ui-schema" 59 // VelaQLConfigmapKey is the key to store velaql view 60 VelaQLConfigmapKey string = "template" 61 ) 62 63 // CapabilityCategory defines the category of a capability 64 type CapabilityCategory string 65 66 // categories of capability schematic 67 const ( 68 TerraformCategory CapabilityCategory = "terraform" 69 70 CUECategory CapabilityCategory = "cue" 71 ) 72 73 // Parameter defines a parameter for cli from capability template 74 type Parameter struct { 75 Name string `json:"name"` 76 Short string `json:"short,omitempty"` 77 Required bool `json:"required,omitempty"` 78 Default interface{} `json:"default,omitempty"` 79 Usage string `json:"usage,omitempty"` 80 Ignore bool `json:"ignore,omitempty"` 81 Type cue.Kind `json:"type,omitempty"` 82 Alias string `json:"alias,omitempty"` 83 JSONType string `json:"jsonType,omitempty"` 84 } 85 86 // Capability defines the content of a capability 87 type Capability struct { 88 Name string `json:"name"` 89 Type CapType `json:"type"` 90 CueTemplate string `json:"template,omitempty"` 91 CueTemplateURI string `json:"templateURI,omitempty"` 92 Parameters []Parameter `json:"parameters,omitempty"` 93 CrdName string `json:"crdName,omitempty"` 94 Status string `json:"status,omitempty"` 95 Description string `json:"description,omitempty"` 96 Example string `json:"example,omitempty"` 97 Labels map[string]string `json:"labels,omitempty"` 98 Category CapabilityCategory `json:"category,omitempty"` 99 100 // trait only 101 AppliesTo []string `json:"appliesTo,omitempty"` 102 103 // Namespace represents it's a system-level or user-level capability. 104 Namespace string `json:"namespace,omitempty"` 105 106 // Plugin Source 107 Source *Source `json:"source,omitempty"` 108 109 // Terraform 110 TerraformConfiguration string `json:"terraformConfiguration,omitempty"` 111 ConfigurationType string `json:"configurationType,omitempty"` 112 Path string `json:"path,omitempty"` 113 }