serverlib

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultChosenAllSvc = "ALL SERVICES"
	FlagNotSet          = "FlagNotSet"
	FlagIsInvalid       = "FlagIsInvalid"
	FlagIsValid         = "FlagIsValid"
)

nolint:golint

View Source
const (
	// StatusChecking means in checking loop
	StatusChecking = "checking"
	// StatusDone means check has done
	StatusDone = "done"
)

Variables

This section is empty.

Functions

func AddCapabilityCenter

func AddCapabilityCenter(capName, capURL, capToken string) error

AddCapabilityCenter will add a cap center

func AddCapabilityIntoCluster

func AddCapabilityIntoCluster(c client.Client, mapper discoverymapper.DiscoveryMapper, capability string) (string, error)

AddCapabilityIntoCluster will add a capability into K8s cluster, it is equal to apply a definition yaml and run `vela workloads/traits`

func AddOrUpdateTrait

func AddOrUpdateTrait(env *types.EnvMeta, appName string, componentName string, flagSet *pflag.FlagSet, template types.Capability) (*application.Application, error)

AddOrUpdateTrait attach trait to workload

func BaseComplete

func BaseComplete(envName string, workloadName string, appName string, flagSet *pflag.FlagSet, workloadType string) (*application.Application, error)

BaseComplete will construct an Application from cli parameters.

func BaseRun

func BaseRun(staging bool, app *application.Application, kubeClient client.Client, env *types.EnvMeta, io cmdutil.IOStreams) (string, error)

BaseRun will check if it's a stating operation before run

func ConvertApplyTo

func ConvertApplyTo(applyTo []string, workloads []types.Capability) []string

ConvertApplyTo will convert applyTo slice to workload capability name if CRD matches

func GetCapabilityFromCenter

func GetCapabilityFromCenter(repoName, addonName string) (types.Capability, error)

GetCapabilityFromCenter will list all synced capabilities from cap center and return the specified one

func GetServicesWhenDescribingApplication

func GetServicesWhenDescribingApplication(cmd *cobra.Command, app *application.Application) ([]string, error)

GetServicesWhenDescribingApplication gets the target services list either from cli `--svc` flag or from survey

func GetStatusFromObject

func GetStatusFromObject(resource *unstructured.Unstructured) (string, error)

GetStatusFromObject get Unstructured object status

func GetTraitDefinition

func GetTraitDefinition(workloadName *string, traitType string) (types.Capability, error)

GetTraitDefinition will get trait capability with applyTo converted

func GetUnstructured

func GetUnstructured(ctx context.Context, c client.Client, ns string, resourceRef runtimev1alpha1.TypedReference) (*unstructured.Unstructured, error)

GetUnstructured get object by GVK.

func InstallCapability

func InstallCapability(client client.Client, mapper discoverymapper.DiscoveryMapper, centerName, capabilityName string, ioStreams cmdutil.IOStreams) error

InstallCapability will add a cap into K8s cluster and install it's controller(helm charts)

func ListApplicationConfigurations

func ListApplicationConfigurations(ctx context.Context, c client.Reader, opt Option) (corev1alpha2.ApplicationConfigurationList, error)

ListApplicationConfigurations lists all OAM ApplicationConfiguration

func ListApplications

func ListApplications(ctx context.Context, c client.Client, opt Option) ([]apis.ApplicationMeta, error)

ListApplications lists all applications

func ListCapabilities

func ListCapabilities(capabilityCenterName string) ([]types.Capability, error)

ListCapabilities will list all caps from specified center

func ListCapabilityCenters

func ListCapabilityCenters() ([]apis.CapabilityCenterMeta, error)

ListCapabilityCenters will list all capabilities from center

func ListComponents

func ListComponents(ctx context.Context, c client.Client, opt Option) ([]apis.ComponentMeta, error)

ListComponents will list all components for dashboard

func ListTraitDefinitions

func ListTraitDefinitions(workloadName *string) ([]types.Capability, error)

ListTraitDefinitions will list all definition include traits and workloads

func LoadIfExist

func LoadIfExist(envName string, workloadName string, appGroup string) (*application.Application, error)

LoadIfExist will load Application from local dir

func Parse

func Parse(applyTo string) string

Parse will parse applyTo(with format apigroup/Version.Kind) to crd name by just calculate the plural of kind word. TODO we should use discoverymapper instead of calculate plural

func PrepareDetachTrait

func PrepareDetachTrait(envName string, traitType string, componentName string, appName string) (*application.Application, error)

PrepareDetachTrait will detach trait in local AppFile

func RemoveCapability

func RemoveCapability(client client.Client, capabilityName string, ioStreams cmdutil.IOStreams) error

RemoveCapability will remove a capability from cluster. 1. remove definition 2. uninstall chart 3. remove local files

func RemoveCapabilityCenter

func RemoveCapabilityCenter(centerName string) (string, error)

RemoveCapabilityCenter will remove a cap center from local

func RemoveCapabilityFromCluster

func RemoveCapabilityFromCluster(client client.Client, capabilityName string) (string, error)

RemoveCapabilityFromCluster will remove a capability from cluster. 1. remove definition 2. uninstall chart 3. remove local files

func RetrieveApplicationStatusByName

func RetrieveApplicationStatusByName(ctx context.Context, c client.Client, applicationName string, namespace string) (apis.ApplicationMeta, error)

RetrieveApplicationStatusByName will get app status

func RetrieveComponent

func RetrieveComponent(ctx context.Context, c client.Client, applicationName, componentName, namespace string) (apis.ComponentMeta, error)

RetrieveComponent will get component status

func SyncCapabilityCenter

func SyncCapabilityCenter(capabilityCenterName string) error

SyncCapabilityCenter will sync capabilities from center to local

func SyncCapabilityFromCenter

func SyncCapabilityFromCenter(capName, capURL, capToken string) error

SyncCapabilityFromCenter will sync all capabilities from center

func TraitOperationRun

func TraitOperationRun(ctx context.Context, c client.Client, env *types.EnvMeta, appObj *application.Application,
	staging bool, io cmdutil.IOStreams) (string, error)

TraitOperationRun will check if it's a stage operation before run

func ValidateAndMutateForCore

func ValidateAndMutateForCore(traitType, workloadName string, flags *pflag.FlagSet, env *types.EnvMeta) error

ValidateAndMutateForCore was built in validate and mutate function for core workloads and traits

Types

type AutoscalerChecker

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

AutoscalerChecker checks 'autoscale' trait

func (*AutoscalerChecker) Check

Check should understand autoscale trait status

type CheckStatus

type CheckStatus string

CheckStatus defines the type of checking status

type Checker

type Checker interface {
	Check(ctx context.Context, reference runtimev1alpha1.TypedReference, compName string, appConfig *v1alpha2.ApplicationConfiguration, app *application.Application) (CheckStatus, string, error)
}

Checker defines the interface of checker

func GetChecker

func GetChecker(traitType string, c client.Client) Checker

GetChecker will get Trait checker for 'vela status'

type DefaultChecker

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

DefaultChecker defines the default checker

func (*DefaultChecker) Check

Check default check object if exist and print the configs

type DeleteOptions

type DeleteOptions struct {
	AppName  string
	CompName string
	Client   client.Client
	Env      *types.EnvMeta
}

DeleteOptions is options for delete

func (*DeleteOptions) DeleteApp

func (o *DeleteOptions) DeleteApp() (string, error)

DeleteApp will delete app including server side

func (*DeleteOptions) DeleteComponent

func (o *DeleteOptions) DeleteComponent(io cmdutil.IOStreams) (string, error)

DeleteComponent will delete one component including server side.

type MetricChecker

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

MetricChecker check for 'metrics' core trait

func (*MetricChecker) Check

Check metrics

type Option

type Option struct {
	// Optional filter, if specified, only components in such app will be listed
	AppName string

	Namespace string
}

Option is option work with dashboard api server

type RouteChecker

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

RouteChecker check for 'route' core trait

func (*RouteChecker) Check

Check understand route status

type RunOptions

type RunOptions struct {
	Env          *types.EnvMeta
	WorkloadName string
	KubeClient   client.Client
	App          *application.Application
	AppName      string
	Staging      bool
	util.IOStreams
}

RunOptions include all options for run

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳