docgen

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Markdown marks the format name of docs
	Markdown = "markdown"
	// Console marks the format name of docs
	Console = "console"
)
View Source
const (
	// Specification marks the title of parameter in reference docs
	Specification = "Specification"
	// Description marks the title of description in reference docs
	Description = "Description"
	// Scope marks the title of scope in reference docs
	Scope = "Scope"
	// Examples marks the title of example in reference doc
	Examples = "Examples"
	// Base is the title of base in reference doc
	Base = "Underlying Kubernetes Resources"
)
View Source
const AllComponentTypes = "*"

AllComponentTypes means trait can be applied to all component types

View Source
const DescriptionUndefined = "description not defined"

DescriptionUndefined indicates the description is not defined

Variables

View Source
var (
	// En is english, the default language
	En = I18n{/* contains filtered or unexported fields */}
	// Zh is Chinese
	Zh = I18n{/* contains filtered or unexported fields */}
)
View Source
var BaseOpenAPIV3Template = `` /* 198-byte string literal not displayed */

BaseOpenAPIV3Template is Standard OpenAPIV3 Template

View Source
var DefinitionDocDescription = map[string]string{}

DefinitionDocDescription stores the description for capabilities

View Source
var DefinitionDocParameters = map[string]string{}

DefinitionDocParameters stores the parameters for capabilities, it will override the generated one

View Source
var DefinitionDocSamples = map[string]string{}

DefinitionDocSamples stores the configuration yaml sample for capabilities

Functions

func GenerateConsoleDocument added in v1.6.0

func GenerateConsoleDocument(title string, schema *openapi3.Schema) (string, error)

GenerateConsoleDocument generate the document shown on the console.

func GenerateProviderMarkdown added in v1.9.0

func GenerateProviderMarkdown(provider io.Reader, w io.Writer) error

GenerateProviderMarkdown generates markdown documentation for a provider.

func GenerateProvidersMarkdown added in v1.9.0

func GenerateProvidersMarkdown(ctx context.Context, providers []io.Reader, w io.Writer) error

GenerateProvidersMarkdown generates markdown documentation for providers.

func GetBaseResourceKinds added in v1.6.0

func GetBaseResourceKinds(cueStr string, mapper meta.RESTMapper) (string, error)

GetBaseResourceKinds helps get resource.group string of components' base resource

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) (*types.Capability, error)

GetCapabilityByName gets capability by definition name

func GetCapabilityByPolicyDefinitionObject

func GetCapabilityByPolicyDefinitionObject(def v1beta1.PolicyDefinition) (*types.Capability, error)

GetCapabilityByPolicyDefinitionObject gets capability by PolicyDefinition object

func GetCapabilityByTraitDefinitionObject

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

GetCapabilityByTraitDefinitionObject gets capability by TraitDefinition object

func GetCapabilityByWorkflowStepDefinitionObject

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

GetCapabilityByWorkflowStepDefinitionObject gets capability by WorkflowStepDefinition object

func GetCapabilityFromDefinitionRevision

func GetCapabilityFromDefinitionRevision(ctx context.Context, c common.Args, ns, defName string, r int64) (*types.Capability, error)

GetCapabilityFromDefinitionRevision gets capabilities from the underlying Definition in DefinitionRevisions

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 GetExample

func GetExample(annotation map[string]string) string

GetExample get example markdown from annotation specified url

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 GetPolicies

func GetPolicies(ctx context.Context, namespace string, c common.Args) ([]types.Capability, []error, error)

GetPolicies will get Policy from K8s cluster

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 GetWorkflowSteps

func GetWorkflowSteps(ctx context.Context, namespace string, c common.Args) ([]types.Capability, []error, error)

GetWorkflowSteps will get WorkflowStepDefinition list

func HandleDefinition

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

HandleDefinition will handle definition to capability

func HandleTemplate

func HandleTemplate(in *runtime.RawExtension, schematic *commontypes.Schematic, name string) (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 LoadI18nData

func LoadI18nData(path string)

LoadI18nData will load i18n data for the package

func LoadInstalledCapabilityWithType

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

LoadInstalledCapabilityWithType will load cap list by type

func ParseCapabilityFromUnstructured

func ParseCapabilityFromUnstructured(mapper meta.RESTMapper, obj unstructured.Unstructured) (types.Capability, error)

ParseCapabilityFromUnstructured will convert Unstructured to Capability

func ParseLocalFile

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

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

func ParseLocalFiles

func ParseLocalFiles(localFilePath string, c common.Args) ([]*types.Capability, error)

ParseLocalFiles parse the local files in directory 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) (string, []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

func (*ConsoleReference) Show

func (ref *ConsoleReference) Show(ctx context.Context, c common.Args, ioStreams cmdutil.IOStreams, capabilityName string, ns string, _ int64) error

Show will show capability reference in console

type FromCluster

type FromCluster struct {
	Namespace string `json:"namespace"`
	Rev       int64  `json:"revision"`
}

FromCluster is the struct for input Namespace

type FromLocal

type FromLocal struct {
	Paths []string `json:"paths"`
}

FromLocal is the struct for input Definition Path

type I18n

type I18n struct {
	// contains filtered or unexported fields
}

I18n will automatically get translated data

func (*I18n) Get

func (i *I18n) Get(str string) string

Get translate for the string

func (*I18n) Language

func (i *I18n) Language() Language

Language return the language used in i18n instance

type Int64Type

type Int64Type = int64

Int64Type is int64 type

type Language

type Language string

Language is used to define the language

const (
	// LangEn is english, the default language
	LangEn Language = "English"
	// LangZh is Chinese
	LangZh Language = "Chinese"
)

type MarkdownReference

type MarkdownReference struct {
	Filter          func(types.Capability) bool
	AllInOne        bool
	ForceExample    bool
	CustomDocHeader string
	ParseReference
}

MarkdownReference is the struct for capability information in

func (*MarkdownReference) CreateMarkdown

func (ref *MarkdownReference) CreateMarkdown(ctx context.Context, caps []types.Capability, baseRefPath string, catalog bool) error

CreateMarkdown creates markdown based on capabilities

func (*MarkdownReference) GenerateMarkdownForCap

func (ref *MarkdownReference) GenerateMarkdownForCap(_ context.Context, c types.Capability, containSuffix bool) (string, error)

GenerateMarkdownForCap will generate markdown for one capability nolint:gocyclo

func (*MarkdownReference) GenerateReferenceDocs

func (ref *MarkdownReference) GenerateReferenceDocs(ctx context.Context, c common.Args, baseRefPath 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           *I18n        `json:"i18n"`
	Remote         *FromCluster `json:"remote"`
	Local          *FromLocal   `json:"local"`
	DefinitionName string       `json:"definitionName"`
	DisplayFormat  string
}

ParseReference is used to include the common function `parseParameter`

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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