plugins

package
v0.0.0-...-2c539bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2022 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BaseRefPath is the target path for reference docs
	BaseRefPath = "docs/en/end-user"
	// KubeVelaIOTerraformPath is the target path for kubevela.io terraform docs
	KubeVelaIOTerraformPath = "../kubevela.io/docs/end-user/components/cloud-services/terraform"
	// KubeVelaIOTerraformPathZh is the target path for kubevela.io terraform docs in Chinese
	KubeVelaIOTerraformPathZh = "../kubevela.io/i18n/zh/docusaurus-plugin-content-docs/current/end-user/components/cloud-services/terraform"
	// ReferenceSourcePath is the location for source reference
	ReferenceSourcePath = "hack/references"
	// ComponentDefinitionTypePath is the URL path for component typed capability
	ComponentDefinitionTypePath = "components"
	// WorkloadTypePath is the URL path for workload typed capability
	WorkloadTypePath = "workload-types"
	// TraitPath is the URL path for trait typed capability
	TraitPath = "traits"
	// WorkflowStepPath is the URL path for workflow step typed capability
	WorkflowStepPath = "workflowsteps"
)
View Source
const DescriptionUndefined = "description not defined"

DescriptionUndefined indicates the description is not defined

Variables

View Source
var BaseOpenAPIV3Template = `` /* 198-byte string literal not displayed */

BaseOpenAPIV3Template is Standard OpenAPIV3 Template

View Source
var ConfigurationYamlSample = map[string]string{
	"annotations": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: myapp
spec:
  components:
    - name: express-server
      type: webservice
      properties:
        image: crccheck/hello-world
        port: 8000
      traits:
        - type: labels
          properties:
            "release": "stable"
        - type: annotations
          properties:
            "description": "web application"
`,

	"ingress": `
kind: Application
metadata:
  name: first-vela-app
spec:
  components:
    - name: express-server
      type: webservice
      properties:
        image: crccheck/hello-world
        port: 8000
      traits:
        - type: ingress
          properties:
            domain: testsvc.example.com
            http:
              "/": 8000
`,

	"labels": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: myapp
spec:
  components:
    - name: express-server
      type: webservice
      properties:
        image: crccheck/hello-world
        port: 8000
      traits:
        - type: labels
          properties:
            "release": "stable"
        - type: annotations
          properties:
            "description": "web application"
`,

	"metrics": `
...
    format: "prometheus"
    port: 8080
    path: "/metrics"
    scheme:  "http"
    enabled: true
`,

	"route": `
...
    domain: example.com
    issuer: tls
    rules:
      - path: /testapp
        rewriteTarget: /
`,

	"scaler": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: website
spec:
  components:
    - name: frontend
      type: webservice
      properties:
        image: nginx
      traits:
        - type: scaler
          properties:
            replicas: 2
        - type: sidecar
          properties:
            name: "sidecar-test"
            image: "fluentd"
    - name: backend
      type: worker
      properties:
        image: busybox
        cmd:
          - sleep
          - '1000'
`,

	"sidecar": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: vela-app-with-sidecar
spec:
  components:
    - name: log-gen-worker
      type: worker
      properties:
        image: busybox
        cmd:
          - /bin/sh
          - -c
          - >
            i=0;
            while true;
            do
              echo "$i: $(date)" >> /var/log/date.log;
              i=$((i+1));
              sleep 1;
            done
        volumes:
          - name: varlog
            mountPath: /var/log
            type: emptyDir
      traits:
        - type: sidecar
          properties:
            name: count-log
            image: busybox
            cmd: [ /bin/sh, -c, 'tail -n+1 -f /var/log/date.log']
            volumes:
              - name: varlog
                path: /var/log
`,

	"task": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: app-worker
spec:
  components:
    - name: mytask
      type: task
      properties:
        image: perl
	    count: 10
	    cmd: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
`,

	"volumes": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: app-worker
spec:
  components:
    - name: myworker
      type: worker
      properties:
        image: "busybox"
        cmd:
          - sleep
          - "1000"
      traits:
        - type: aws-ebs-volume
          properties:
            name: "my-ebs"
            mountPath: "/myebs"
            volumeID: "my-ebs-id"
`,

	"webservice": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: website
spec:
  components:
    - name: frontend
      type: webservice
      properties:
        image: oamdev/testapp:v1
        cmd: ["node", "server.js"]
        port: 8080
        cpu: "0.1"
        env:
          - name: FOO
            value: bar
          - name: FOO
            valueFrom:
              secretKeyRef:
                name: bar
                key: bar
`,

	"worker": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: app-worker
spec:
  components:
    - name: myworker
      type: worker
      properties:
        image: "busybox"
        cmd:
          - sleep
          - "1000"
`,

	"alibaba-vpc": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: app-vpc-sample
spec:
  components:
    - name: sample-vpc
      type: alibaba-vpc
      properties:
        vpc_cidr: "172.16.0.0/12"

        writeConnectionSecretToRef:
          name: vpc-conn
`,

	"alibaba-rds": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: rds-cloud-source
spec:
  components:
    - name: sample-db
      type: alibaba-rds
      properties:
        instance_name: sample-db
        account_name: oamtest
        password: U34rfwefwefffaked
        writeConnectionSecretToRef:
          name: db-conn
`,

	"alibaba-ack": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: ack-cloud-source
spec:
  components:
    - name: ack-cluster
      type: alibaba-ack
      properties:
        writeConnectionSecretToRef:
          name: ack-conn
          namespace: vela-system
`,
	"alibaba-eip": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: provision-cloud-resource-eip
spec:
  components:
    - name: sample-eip
      type: alibaba-eip
      properties:
        writeConnectionSecretToRef:
          name: eip-conn
`,

	"alibaba-oss": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: oss-cloud-source
spec:
  components:
    - name: sample-oss
      type: alibaba-oss
      properties:
        bucket: vela-website
        acl: private
        writeConnectionSecretToRef:
          name: oss-conn
`,

	"alibaba-redis": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: redis-cloud-source
spec:
  components:
    - name: sample-redis
      type: alibaba-redis
      properties:
        instance_name: oam-redis
        account_name: oam
        password: Xyfff83jfewGGfaked
        writeConnectionSecretToRef:
          name: redis-conn
`,

	"aws-s3": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: s3-cloud-source
spec:
  components:
    - name: sample-s3
      type: aws-s3
      properties:
        bucket: vela-website-20211019
        acl: private

        writeConnectionSecretToRef:
          name: s3-conn
`,

	"azure-database-mariadb": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: mariadb-backend
spec:
  components:
    - name: mariadb-backend
      type: azure-database-mariadb
      properties:
        resource_group: "kubevela-group"
        location: "West Europe"
        server_name: "kubevela"
        db_name: "backend"
        username: "acctestun"
        password: "H@Sh1CoR3!Faked"
        writeConnectionSecretToRef:
          name: azure-db-conn
          namespace: vela-system
`,

	"azure-storage-account": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: storage-account-dev
spec:
  components:
    - name: storage-account-dev
      type: azure-storage-account
      properties:
        create_rsg: false
        resource_group_name: "weursgappdev01"
        location: "West Europe"
        name: "appdev01"
        tags: |
          {
            ApplicationName       = "Application01"
            Terraform             = "Yes"
          } 
        static_website: |
          [{
            index_document = "index.html"
            error_404_document = "index.html"
          }]

        writeConnectionSecretToRef:
          name: storage-account-dev
          namespace: vela-system
`,

	"alibaba-sls-project": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: app-sls-project-sample
spec:
  components:
    - name: sample-sls-project
      type: alibaba-sls-project
      properties:
        name: kubevela-1112
        description: "Managed by KubeVela"

        writeConnectionSecretToRef:
          name: sls-project-conn
`,

	"alibaba-sls-store": `
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: app-sls-store-sample
spec:
  components:
    - name: sample-sls-store
      type: alibaba-sls-store
      properties:
        store_name: kubevela-1111
        store_retention_period: 30
        store_shard_count: 2
        store_max_split_shard_count: 2

        writeConnectionSecretToRef:
          name: sls-store-conn
`,
}

ConfigurationYamlSample stores the configuration yaml sample for capabilities

View Source
var Definitions = map[string]map[Language]string{
	"Description": {
		Zh: "描述",
		En: "Description",
	},
	"Samples": {
		Zh: "示例",
		En: "Samples",
	},
	"Specification": {
		Zh: "参数说明",
		En: "Specification",
	},
	"AlibabaCloud": {
		Zh: "阿里云",
		En: "Alibaba Cloud",
	},
	"AWS": {
		Zh: "AWS",
		En: "AWS",
	},
	"Azure": {
		Zh: "Azure",
		En: "Azure",
	},
	"Name": {
		Zh: "名称",
		En: "Name",
	},
	"Type": {
		Zh: "类型",
		En: "Type",
	},
	"Required": {
		Zh: "是否必须",
		En: "Required",
	},
	"Default": {
		Zh: "默认值",
		En: "Default",
	},
	"WriteConnectionSecretToRefIntroduction": {
		Zh: "如果设置了 `writeConnectionSecretToRef`,一个 Kubernetes Secret 将会被创建,并且,它的数据里有这些键(key):",
		En: "If `writeConnectionSecretToRef` is set, a secret will be generated with these keys as below:",
	},
	"Outputs": {
		Zh: "输出",
		En: "Outputs",
	},
	"Properties": {
		Zh: "属性",
		En: "Properties",
	},
	"Terraform_configuration_for_Alibaba_Cloud_ACK_cluster": {
		Zh: "用于部署阿里云 ACK 集群的组件说明",
		En: "Terraform configuration for Alibaba Cloud ACK cluster",
	},
	"Terraform_configuration_for_Alibaba_Cloud_Serverless_Kubernetes_(ASK)": {
		Zh: "用于部署阿里云 Serverless Kubernetes (ASK) 的组件说明",
		En: "Terraform configuration for Alibaba Cloud Serverless Kubernetes (ASK)",
	},
	"Terraform_configuration_for_Alibaba_Cloud_Elastic_IP": {
		Zh: "用于部署阿里云弹性 IP 的组件说明",
		En: "Terraform configuration for Alibaba Cloud Elastic IP",
	},
	"Terraform_configuration_for_Alibaba_Cloud_OSS_object": {
		Zh: "用于部署阿里云 OSS 的组件说明",
		En: "Terraform configuration for Alibaba Cloud OSS",
	},
	"Terraform_configuration_for_Alibaba_Cloud_RDS_object": {
		Zh: "用于部署阿里云 RDS 的组件说明",
		En: "Terraform configuration for Alibaba Cloud RDS",
	},
	"Terraform_configuration_for_Alibaba_Cloud_Redis": {
		Zh: "用于部署阿里云 Redis 的组件说明",
		En: "Terraform configuration for Alibaba Cloud Redis",
	},
	"Terraform_configuration_for_Alibaba_Cloud_SLS_Project": {
		Zh: "用于部署阿里云 SLS Project 的组件说明",
		En: "Terraform configuration for Alibaba Cloud SLS Project",
	},
	"Terraform_configuration_for_Alibaba_Cloud_SLS_Store": {
		Zh: "用于部署阿里云 SLS Store 的组件说明",
		En: "Terraform configuration for Alibaba Cloud SLS Store",
	},
	"Terraform_configuration_for_Alibaba_Cloud_VPC": {
		Zh: "用于部署阿里云 VPC 的组件说明",
		En: "Terraform configuration for Alibaba Cloud VPC",
	},
	"Terraform_configuration_for_Alibaba_Cloud_VSwitch": {
		Zh: "用于部署阿里云 VSwitch 的组件说明",
		En: "Terraform configuration for Alibaba Cloud VSwitch",
	},
	"Terraform_configuration_for_AWS_S3": {
		Zh: "用于部署 AWS S3 的组件说明",
		En: "Terraform configuration for AWS S3",
	},
	"Terraform_configuration_for_Azure_Database_Mariadb": {
		Zh: "用于部署 Azure mariadb 数据库的组件说明",
		En: "Terraform configuration for Azure Database Mariadb",
	},
	"Terraform_configuration_for_Azure_Blob_Storage_Account": {
		Zh: "用于部署 Azure Blob Storage 账号的的组件说明",
		En: "Terraform configuration for Azure Blob Storage Account",
	},
}

Definitions are all the words and phrases for internationalization in cli and docs

Functions

func GetCapabilitiesFromCluster

func GetCapabilitiesFromCluster(ctx context.Context, namespace string, c common.Args, selector labels.Selector) ([]types.Capability, error)

GetCapabilitiesFromCluster will get capability from K8s cluster

func GetCapabilityByComponentDefinitionObject

func GetCapabilityByComponentDefinitionObject(componentDef v1beta1.ComponentDefinition, referenceName string) (*types.Capability, error)

GetCapabilityByComponentDefinitionObject gets capability by ComponentDefinition object

func GetCapabilityByName

func GetCapabilityByName(ctx context.Context, c common.Args, capabilityName string, ns string, pd *packages.PackageDiscover) (*types.Capability, error)

GetCapabilityByName gets capability by definition name

func GetCapabilityByTraitDefinitionObject

func GetCapabilityByTraitDefinitionObject(traitDef v1beta1.TraitDefinition) (*types.Capability, error)

GetCapabilityByTraitDefinitionObject gets capability by TraitDefinition object

func GetCapabilityByWorkflowStepDefinitionObject

func GetCapabilityByWorkflowStepDefinitionObject(wfStepDef v1beta1.WorkflowStepDefinition, pd *packages.PackageDiscover) (*types.Capability, error)

GetCapabilityByWorkflowStepDefinitionObject gets capability by WorkflowStepDefinition object

func GetComponentsFromCluster

func GetComponentsFromCluster(ctx context.Context, namespace string, c common.Args, selector labels.Selector) ([]types.Capability, []error, error)

GetComponentsFromCluster will get capability from K8s cluster

func GetComponentsFromClusterWithValidateOption

func GetComponentsFromClusterWithValidateOption(ctx context.Context, namespace string, c common.Args, selector labels.Selector, validateFlag bool) ([]types.Capability, []error, error)

GetComponentsFromClusterWithValidateOption will get capability from K8s cluster with an option whether to valid Components

func GetDescription

func GetDescription(annotation map[string]string) string

GetDescription get description from annotation

func GetNamespacedCapabilitiesFromCluster

func GetNamespacedCapabilitiesFromCluster(ctx context.Context, namespace string, c common.Args, selector labels.Selector) ([]types.Capability, error)

GetNamespacedCapabilitiesFromCluster will get capability from K8s cluster in the specified namespace and default namespace If the definition could be found from `namespace`, try to find in namespace `types.DefaultKubeVelaNS`

func GetTraitsFromCluster

func GetTraitsFromCluster(ctx context.Context, namespace string, c common.Args, selector labels.Selector) ([]types.Capability, []error, error)

GetTraitsFromCluster will get capability from K8s cluster

func GetTraitsFromClusterWithValidateOption

func GetTraitsFromClusterWithValidateOption(ctx context.Context, namespace string, c common.Args, selector labels.Selector, validateFlag bool) ([]types.Capability, []error, error)

GetTraitsFromClusterWithValidateOption will get capability from K8s cluster with an option whether to valid Traits

func HandleDefinition

func HandleDefinition(name, crdName string, annotation, labels map[string]string, extension *runtime.RawExtension, tp types.CapType,
	applyTo []string, schematic *commontypes.Schematic, pd *packages.PackageDiscover) (types.Capability, error)

HandleDefinition will handle definition to capability

func HandleTemplate

func HandleTemplate(in *runtime.RawExtension, schematic *commontypes.Schematic, name string, pd *packages.PackageDiscover) (types.Capability, error)

HandleTemplate will handle definition template to capability

func LoadAllInstalledCapability

func LoadAllInstalledCapability(userNamespace string, c common.Args) ([]types.Capability, error)

LoadAllInstalledCapability will list all capability

func LoadCapabilityByName

func LoadCapabilityByName(name string, userNamespace string, c common.Args) (types.Capability, error)

LoadCapabilityByName will load capability from local by name

func LoadInstalledCapabilityWithType

func LoadInstalledCapabilityWithType(userNamespace string, c common.Args, capT types.CapType) ([]types.Capability, error)

LoadInstalledCapabilityWithType will load cap list by type

func ParseLocalFile

func ParseLocalFile(localFilePath string) (*types.Capability, error)

ParseLocalFile parse the local file and get name, configuration from local ComponentDefinition file

func WalkParameterSchema

func WalkParameterSchema(parameters *openapi3.Schema, name string, depth int)

WalkParameterSchema will extract properties from *openapi3.Schema

Types

type BoolType

type BoolType = bool

BoolType is bool type

type CommonReference

type CommonReference struct {
	Name       string
	Parameters []ReferenceParameter
	Depth      int
}

CommonReference contains parameters info of HelmCategory and KubuCategory type capability at present

type CommonSchema

type CommonSchema struct {
	Name    string
	Schemas *openapi3.Schema
}

CommonSchema is a struct contains *openapi3.Schema style parameter

type ConsoleReference

type ConsoleReference struct {
	ParseReference
	TableName   string             `json:"tableName"`
	TableObject *tablewriter.Table `json:"tableObject"`
}

ConsoleReference is the struct for capability information in console

func (*ConsoleReference) GenerateCUETemplateProperties

func (ref *ConsoleReference) GenerateCUETemplateProperties(capability *types.Capability, pd *packages.PackageDiscover) ([]ConsoleReference, error)

GenerateCUETemplateProperties get all properties of a capability

func (*ConsoleReference) GenerateTerraformCapabilityProperties

func (ref *ConsoleReference) GenerateTerraformCapabilityProperties(capability types.Capability) ([]ConsoleReference, error)

GenerateTerraformCapabilityProperties generates Capability properties for Terraform ComponentDefinition in Cli console

type Int64Type

type Int64Type = int64

Int64Type is int64 type

type Language

type Language string

Language is used to define the language

const (
	// En is English, the default language
	En Language = "English"
	// Zh is Chinese
	Zh Language = "Chinese"
)

type MarkdownReference

type MarkdownReference struct {
	DefinitionName string `json:"definitionName"`
	ParseReference
}

MarkdownReference is the struct for capability information in

func (*MarkdownReference) CreateMarkdown

func (ref *MarkdownReference) CreateMarkdown(ctx context.Context, caps []types.Capability, baseRefPath, referenceSourcePath string, pd *packages.PackageDiscover) error

CreateMarkdown creates markdown based on capabilities

func (*MarkdownReference) GenerateReferenceDocs

func (ref *MarkdownReference) GenerateReferenceDocs(ctx context.Context, c common.Args, baseRefPath string, namespace string) error

GenerateReferenceDocs generates reference docs

func (*MarkdownReference) GenerateTerraformCapabilityPropertiesAndOutputs

func (ref *MarkdownReference) GenerateTerraformCapabilityPropertiesAndOutputs(capability types.Capability) (string, error)

GenerateTerraformCapabilityPropertiesAndOutputs generates Capability properties and outputs for Terraform ComponentDefinition

type ParseReference

type ParseReference struct {
	Client client.Client
	I18N   Language `json:"i18n"`
}

ParseReference is used to include the common function `parseParameter`

func (*ParseReference) GenerateHelmAndKubeProperties

func (ref *ParseReference) GenerateHelmAndKubeProperties(ctx context.Context, capability *types.Capability) ([]CommonReference, []ConsoleReference, error)

GenerateHelmAndKubeProperties get all properties of a Helm/Kube Category type capability

type Reference

type Reference interface {
	// contains filtered or unexported methods
}

Reference is the struct for capability information

type ReferenceParameter

type ReferenceParameter struct {
	types.Parameter `json:",inline,omitempty"`
	// PrintableType is same to `parameter.Type` which could be printable
	PrintableType string `json:"printableType"`
}

ReferenceParameter is the parameter section of CUE template

type ReferenceParameterTable

type ReferenceParameterTable struct {
	Name       string
	Parameters []ReferenceParameter
	Depth      *int
}

ReferenceParameterTable stores the information of a bunch of ReferenceParameter in a table style

type StringType

type StringType = string

StringType is string type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL