plugins

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DescriptionUndefined = "description not defined"

nolint

View Source
const TypeGithub = "github"

TypeGithub represents github

View Source
const TypeUnknown = "unknown"

TypeUnknown represents parse failed

Variables

This section is empty.

Functions

func GetCapabilitiesFromCluster

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

GetCapabilitiesFromCluster will get capability from K8s cluster

func GetDescription added in v0.0.8

func GetDescription(annotation map[string]string) string

GetDescription get description from annotation

func GetInstalledCapabilityWithCapName added in v0.2.0

func GetInstalledCapabilityWithCapName(capT types.CapType, capName string) (types.Capability, error)

GetInstalledCapabilityWithCapName will get cap by alias

func GetSubDir

func GetSubDir(dir string, capT types.CapType) string

GetSubDir will get dir for capability

func GetTraitsFromCluster

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

GetTraitsFromCluster will get capability from K8s cluster

func GetWorkloadsFromCluster

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

GetWorkloadsFromCluster will get capability from K8s cluster

func HandleDefinition

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

HandleDefinition will handle definition to capability

func HandleTemplate

func HandleTemplate(in *runtime.RawExtension, name, syncDir string) (types.Capability, error)

HandleTemplate will handle definition template to capability

func LoadAllInstalledCapability

func LoadAllInstalledCapability() ([]types.Capability, error)

LoadAllInstalledCapability will list all capability

func LoadCapabilityByName

func LoadCapabilityByName(name string) (types.Capability, error)

LoadCapabilityByName will load capability from local by name

func LoadCapabilityFromSyncedCenter

func LoadCapabilityFromSyncedCenter(dir string) ([]types.Capability, error)

LoadCapabilityFromSyncedCenter will load capability from dir

func LoadInstalledCapabilityWithType

func LoadInstalledCapabilityWithType(capT types.CapType) ([]types.Capability, error)

LoadInstalledCapabilityWithType will load cap list by type

func ParseAndSyncCapability

func ParseAndSyncCapability(data []byte, syncDir string) (types.Capability, error)

ParseAndSyncCapability will convert config from remote center to capability

func RemoveLegacyTemps added in v0.0.7

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

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 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

func Parse

func Parse(addr string) (string, *GithubContent, error)

Parse will parse config from address

type RemoteCapabilities

type RemoteCapabilities []RemoteCapability

RemoteCapabilities is slice of cap center

type RemoteCapability

type RemoteCapability struct {
	// Name MUST be xxx.yaml
	Name string `json:"name"`
	URL  string `json:"downloadUrl"`
	Sha  string `json:"sha"`
	// Type MUST be file
	Type string `json:"type"`
}

RemoteCapability defines the capability discovered from remote cap center

Jump to

Keyboard shortcuts

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