common

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: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AddonObservabilityApplication is the application name for Addon Observability
	AddonObservabilityApplication = "addon-observability"
	// AddonObservabilityGrafanaSvc is grafana service name for Addon Observability
	AddonObservabilityGrafanaSvc = "grafana"
)
View Source
const CreateCustomNamespace = "create new namespace"

CreateCustomNamespace display the create namespace message

Variables

View Source
var (
	// Scheme defines the default KubeVela schema
	Scheme = k8sruntime.NewScheme()
)

Functions

func AskToChooseOneEnvResource

func AskToChooseOneEnvResource(app *v1beta1.Application) (*common.ClusterObjectReference, error)

AskToChooseOneEnvResource will ask users to select one applied resource of the application if more than one resource is a map for component to applied resources return the selected ClusterObjectReference

func AskToChooseOneNamespace

func AskToChooseOneNamespace(c client.Client, envMeta *types.EnvMeta) error

AskToChooseOneNamespace ask for choose one namespace as env

func AskToChooseOnePods

func AskToChooseOnePods(podNames []string) (string, error)

AskToChooseOnePods will ask users to select one pods of the resource if more than one

func AskToChooseOnePortForwardEndpoint

func AskToChooseOnePortForwardEndpoint(app *v1beta1.Application) (*common.ClusterObjectReference, error)

AskToChooseOnePortForwardEndpoint will ask user to select one applied resource as port forward endpoint

func AskToChooseOneService

func AskToChooseOneService(svcNames []string) (string, error)

AskToChooseOneService will ask users to select one service of the application if more than one

func ClusterObject2Map

func ClusterObject2Map(refs []common.ClusterObjectReference) map[string]string

ClusterObject2Map convert ClusterObjectReference to a readable map

func GenOpenAPI

func GenOpenAPI(inst *cue.Instance) ([]byte, error)

GenOpenAPI generates OpenAPI json schema from cue.Instance

func GenerateUnstructuredObj

func GenerateUnstructuredObj(name, ns string, gvk schema.GroupVersionKind) *unstructured.Unstructured

GenerateUnstructuredObj generate UnstructuredObj

func GetCUEParameterValue

func GetCUEParameterValue(cueStr string, pd *packages.PackageDiscover) (cue.Value, error)

GetCUEParameterValue converts definitions to cue format

func GetClient

func GetClient() (client.Client, error)

GetClient will K8s client in args

func HTTPGet

func HTTPGet(ctx context.Context, url string) ([]byte, error)

HTTPGet will send GET http request with context

func NewK8sClient

func NewK8sClient() (client.Client, error)

NewK8sClient init a local k8s client which add oamcore scheme

func ParseTerraformVariables

func ParseTerraformVariables(configuration string) (map[string]*tfconfig.Variable, map[string]*tfconfig.Output, error)

ParseTerraformVariables get variables from Terraform Configuration

func ReadYamlToObject

func ReadYamlToObject(path string, object k8sruntime.Object) error

ReadYamlToObject will read a yaml K8s object to runtime.Object

func RealtimePrintCommandOutput

func RealtimePrintCommandOutput(cmd *exec.Cmd, logFile string) error

RealtimePrintCommandOutput prints command output in real time If logFile is "", it will prints the stdout, or it will write to local file

func RefineParameterInstance

func RefineParameterInstance(inst *cue.Instance) (*cue.Instance, error)

RefineParameterInstance refines cue instance to merely include `parameter` identifier

func SetGlobalClient

func SetGlobalClient(clt client.Client) error

SetGlobalClient will set a client for one cli command

func SetSpecObjIntoUnstructuredObj

func SetSpecObjIntoUnstructuredObj(spec interface{}, u *unstructured.Unstructured) error

SetSpecObjIntoUnstructuredObj set UnstructuredObj spec field

Types

type Args

type Args struct {
	Schema *runtime.Scheme
	// contains filtered or unexported fields
}

Args is args for controller-runtime client

func InitBaseRestConfig

func InitBaseRestConfig() (Args, error)

InitBaseRestConfig will return reset config for create controller runtime client

func (*Args) GetClient

func (a *Args) GetClient() (client.Client, error)

GetClient get client if exist

func (*Args) GetConfig

func (a *Args) GetConfig() (*rest.Config, error)

GetConfig get config, if not exist, will create

func (*Args) GetDiscoveryClient

func (a *Args) GetDiscoveryClient() (*discovery.DiscoveryClient, error)

GetDiscoveryClient return a discovery client from cli args

func (*Args) GetDiscoveryMapper

func (a *Args) GetDiscoveryMapper() (discoverymapper.DiscoveryMapper, error)

GetDiscoveryMapper get discoveryMapper client if exist, create if not exist.

func (*Args) GetPackageDiscover

func (a *Args) GetPackageDiscover() (*packages.PackageDiscover, error)

GetPackageDiscover get PackageDiscover client if exist, create if not exist.

func (*Args) SetClient

func (a *Args) SetClient(c client.Client)

SetClient set custom client

func (*Args) SetConfig

func (a *Args) SetConfig(c *rest.Config) error

SetConfig insert kubeconfig into Args

type ResourceLocation

type ResourceLocation struct {
	Cluster   string
	Namespace string
}

ResourceLocation indicates the resource location

Jump to

Keyboard shortcuts

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