Documentation
¶
Index ¶
- Constants
- Variables
- func GetCapabilitiesFromCluster(ctx context.Context, namespace string, c common.Args, selector labels.Selector) ([]types.Capability, error)
- func GetComponentsFromCluster(ctx context.Context, namespace string, c common.Args, selector labels.Selector) ([]types.Capability, []error, error)
- func GetDescription(annotation map[string]string) string
- func GetInstalledCapabilityWithCapName(capT types.CapType, capName string) (types.Capability, error)
- func GetSubDir(dir string, capT types.CapType) string
- func GetTraitsFromCluster(ctx context.Context, namespace string, c common.Args, selector labels.Selector) ([]types.Capability, []error, error)
- func HandleDefinition(name, crdName string, annotation map[string]string, ...) (types.Capability, error)
- func HandleTemplate(in *runtime.RawExtension, schematic *commontypes.Schematic, name string) (types.Capability, error)
- func LoadAllInstalledCapability(userNamespace string, c common.Args) ([]types.Capability, error)
- func LoadCapabilityByName(name string, userNamespace string, c common.Args) (types.Capability, error)
- func LoadCapabilityFromSyncedCenter(mapper discoverymapper.DiscoveryMapper, dir string) ([]types.Capability, error)
- func LoadInstalledCapabilityWithType(userNamespace string, c common.Args, capT types.CapType) ([]types.Capability, error)
- func ParseAndSyncCapability(mapper discoverymapper.DiscoveryMapper, data []byte) (types.Capability, error)
- func RemoveLegacyTemps(retainedTemps []types.Capability, dir string) int
- func SinkTemp2Local(templates []types.Capability, dir string) int
- func StoreRepos(repos []CapCenterConfig) error
- func SyncDefinitionToLocal(ctx context.Context, c common.Args, capabilityName string, ns string) (*types.Capability, error)
- func SyncDefinitionsToLocal(ctx context.Context, c common.Args, localDefinitionDir string) ([]types.Capability, []string, error)
- func WalkParameterSchema(parameters *openapi3.Schema, name string, depth int)
- type BoolType
- type CapCenterConfig
- type CenterClient
- type ConsoleReference
- type GithubCenter
- type GithubContent
- type HELMReference
- type HELMSchema
- type Int64Type
- type MarkdownReference
- type ParseReference
- type Reference
- type ReferenceParameter
- type RemoteCapabilities
- type RemoteCapability
- type StringType
Constants ¶
const ( // BaseRefPath is the target path for reference docs BaseRefPath = "docs/en/developers/references" // ReferenceSourcePath is the location for source reference ReferenceSourcePath = "hack/references" // ComponentDefinitionTypePath is the URL path for component typed capability ComponentDefinitionTypePath = "component-types" // WorkloadTypePath is the URL path for workload typed capability WorkloadTypePath = "workload-types" // TraitPath is the URL path for trait typed capability TraitPath = "traits" )
const ( // TerraformVariableName is the name for Terraform Variable TerraformVariableName = "variable" // TerraformWriteConnectionSecretToRefName is the name for Terraform WriteConnectionSecretToRef TerraformWriteConnectionSecretToRefName = "writeConnectionSecretToRef" // TerraformVariableType is the type for Terraform Variable TerraformVariableType = "[variable](#variable)" // TerraformWriteConnectionSecretToRefType is the type for Terraform WriteConnectionSecretToRef TerraformWriteConnectionSecretToRefType = "[writeConnectionSecretToRef](#writeConnectionSecretToRef)" )
const DescriptionUndefined = "description not defined"
DescriptionUndefined indicates the description is not defined
const TypeGithub = "github"
TypeGithub represents github
const TypeUnknown = "unknown"
TypeUnknown represents parse failed
Variables ¶
var BaseOpenAPIV3Template = `` /* 198-byte string literal not displayed */
BaseOpenAPIV3Template is Standard OpenAPIV3 Template
var ConfigurationYamlSample = map[string]string{
"autoscale": `
name: testapp
services:
express-server:
...
autoscale:
min: 1
max: 4
cron:
startAt: "14:00"
duration: "2h"
days: "Monday, Thursday"
replicas: 2
timezone: "America/Los_Angeles"
cpuPercent: 10
`,
"metrics": `
name: my-app-name
services:
my-service-name:
...
metrics:
format: "prometheus"
port: 8080
path: "/metrics"
scheme: "http"
enabled: true
`,
"rollout": `
servcies:
express-server:
...
rollout:
replicas: 2
stepWeight: 50
interval: "10s"
`,
"route": `
name: my-app-name
services:
my-service-name:
...
route:
domain: example.com
issuer: tls
rules:
- path: /testapp
rewriteTarget: /
`,
"scaler": `
name: my-app-name
services:
my-service-name:
...
scaler:
replicas: 100
`,
"task": `
name: my-app-name
services:
my-service-name:
type: task
image: perl
count: 10
cmd: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
`,
"webservice": `
name: my-app-name
services:
my-service-name:
type: webservice # could be skipped
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": `
name: my-app-name
services:
my-service-name:
type: worker
image: oamdev/testapp:v1
cmd: ["node", "server.js"]
`,
}
ConfigurationYamlSample stores the configuration yaml sample for capabilities
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 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 GetDescription ¶
GetDescription get description from annotation
func GetInstalledCapabilityWithCapName ¶
func GetInstalledCapabilityWithCapName(capT types.CapType, capName string) (types.Capability, error)
GetInstalledCapabilityWithCapName will get cap by alias
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 HandleDefinition ¶
func HandleDefinition(name, crdName string, annotation 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 ¶
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 LoadCapabilityFromSyncedCenter ¶
func LoadCapabilityFromSyncedCenter(mapper discoverymapper.DiscoveryMapper, dir string) ([]types.Capability, error)
LoadCapabilityFromSyncedCenter will load capability from dir
func LoadInstalledCapabilityWithType ¶
func LoadInstalledCapabilityWithType(userNamespace string, c common.Args, capT types.CapType) ([]types.Capability, error)
LoadInstalledCapabilityWithType will load cap list by type
func ParseAndSyncCapability ¶
func ParseAndSyncCapability(mapper discoverymapper.DiscoveryMapper, data []byte) (types.Capability, error)
ParseAndSyncCapability will convert config from remote center to capability
func RemoveLegacyTemps ¶
func RemoveLegacyTemps(retainedTemps []types.Capability, dir string) int
RemoveLegacyTemps will remove capability definitions under `dir` but not included in `retainedTemps`.
func SinkTemp2Local ¶
func SinkTemp2Local(templates []types.Capability, dir string) int
SinkTemp2Local will sink template to local file
func StoreRepos ¶
func StoreRepos(repos []CapCenterConfig) error
StoreRepos will store cap center repo locally
func SyncDefinitionToLocal ¶
func SyncDefinitionToLocal(ctx context.Context, c common.Args, capabilityName string, ns string) (*types.Capability, error)
SyncDefinitionToLocal sync definitions to local
Types ¶
type CapCenterConfig ¶
type CapCenterConfig struct {
Name string `json:"name"`
Address string `json:"address"`
Token string `json:"token"`
}
CapCenterConfig is used to store cap center config in file
func LoadRepos ¶
func LoadRepos() ([]CapCenterConfig, error)
LoadRepos will load all cap center repos TODO(wonderflow): we can make default(built-in) repo configurable, then we should make default inside the answer
type CenterClient ¶
type CenterClient interface {
SyncCapabilityFromCenter() error
}
CenterClient defines an interface for cap center client
func NewCenterClient ¶
func NewCenterClient(ctx context.Context, name, address, token string) (CenterClient, error)
NewCenterClient create a client from type
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 ¶ added in v1.0.4
func (ref *ConsoleReference) GenerateCUETemplateProperties(capability *types.Capability) ([]ConsoleReference, error)
GenerateCUETemplateProperties get all properties of a capability
func (*ConsoleReference) GenerateTerraformCapabilityProperties ¶ added in v1.0.4
func (ref *ConsoleReference) GenerateTerraformCapabilityProperties(capability *types.Capability) ([]ConsoleReference, error)
GenerateTerraformCapabilityProperties generates Capability properties for Terraform ComponentDefinition application developers need to set two sections `variable` and `writeConnectionSecretToRef` in an application
type GithubCenter ¶
type GithubCenter struct {
// contains filtered or unexported fields
}
GithubCenter implementation of cap center
func NewGithubCenter ¶
func NewGithubCenter(ctx context.Context, token, centerName string, r *GithubContent) (*GithubCenter, error)
NewGithubCenter will create client by github center implementation
func (*GithubCenter) SyncCapabilityFromCenter ¶
func (g *GithubCenter) SyncCapabilityFromCenter() error
SyncCapabilityFromCenter will sync capability from github cap center TODO(wonderflow): currently we only sync by create, we also need to delete which not exist remotely.
type GithubContent ¶
type GithubContent struct {
Owner string `json:"owner"`
Repo string `json:"repo"`
Path string `json:"path"`
Ref string `json:"ref"`
}
GithubContent for cap center
type HELMReference ¶ added in v1.0.4
type HELMReference struct {
Name string
Parameters []ReferenceParameter
Depth int
}
HELMReference contains parameters info of HelmCategory type capability
type HELMSchema ¶ added in v1.0.4
HELMSchema is a struct contains *openapi3.Schema style parameter
type MarkdownReference ¶
type MarkdownReference struct {
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) error
CreateMarkdown creates markdown based on capabilities
func (*MarkdownReference) GenerateReferenceDocs ¶
func (ref *MarkdownReference) GenerateReferenceDocs(ctx context.Context, baseRefPath string) error
GenerateReferenceDocs generates reference docs
type ParseReference ¶
ParseReference is used to include the common function `parseParameter`
func (*ParseReference) GenerateHELMProperties ¶ added in v1.0.4
func (ref *ParseReference) GenerateHELMProperties(ctx context.Context, capability *types.Capability) ([]HELMReference, []ConsoleReference, error)
GenerateHELMProperties get all properties of a HelmCategory 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"`
// Depth marks the depth for calling of function `parseParameters`
Depth *int `json:"depth"`
}
ReferenceParameter is the parameter section of CUE template
type RemoteCapabilities ¶
type RemoteCapabilities []RemoteCapability
RemoteCapabilities is slice of cap center