common

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: Apache-2.0 Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopSeparatorTableStyle = 1 << iota
	ColumnSeparatorTableStyle
	RowSeparatorTableStyle
	BottomSeparatorTableStyle
)

Variables

This section is empty.

Functions

func CompileTOSCA

func CompileTOSCA(url string, inputs map[string]ard.Value, writer io.Writer, urlContext *urlpkg.Context) error

func CopySSH added in v0.3.0

func CopySSH(host string, username string, key string, reader io.Reader, targetPath string, permissions *int64) error

func CreateEventRecorder

func CreateEventRecorder(kubernetes kubernetes.Interface, component string, log *logging.Logger) record.EventRecorder

func DecodeAllYAML

func DecodeAllYAML(code string) ([]ard.StringMap, error)

func DecodeYAMLTemplate

func DecodeYAMLTemplate(code string, data interface{}) (map[string]interface{}, error)

func ExecSSH added in v0.3.0

func ExecSSH(host string, username string, key string, stdin io.Reader, command ...string) (string, error)

func ExecScriptlet

func ExecScriptlet(clout *cloutpkg.Clout, scriptletName string, arguments map[string]string, urlContext *urlpkg.Context) (string, error)

func FindResourceForKind

func FindResourceForKind(discovery_ discoverypkg.DiscoveryInterface, gvk schema.GroupVersionKind, supportedVerbs ...string) (schema.GroupVersionResource, error)

func FindResourceForUnstructured

func FindResourceForUnstructured(discovery discoverypkg.DiscoveryInterface, object *unstructured.Unstructured, supportedVerbs ...string) (schema.GroupVersionResource, error)

func FindResourcesForKind

func FindResourcesForKind(discovery discoverypkg.DiscoveryInterface, gvk schema.GroupVersionKind, supportedVerbs ...string) ([]schema.GroupVersionResource, error)

func GetConfiguredNamespace

func GetConfiguredNamespace(configPath string, context string) (string, bool)

func GetControllerOf

func GetControllerOf(metaObject meta.Object) (schema.GroupVersionKind, string, error)

func GetFileHash

func GetFileHash(path string) (string, error)

func GetFirstPodIP

func GetFirstPodIP(context contextpkg.Context, kubernetes kubernetespkg.Interface, namespace string, appName string) (string, error)

func GetFirstPodName

func GetFirstPodName(context contextpkg.Context, kubernetes kubernetespkg.Interface, namespace string, appName string) (string, error)

func GetFirstServiceIP

func GetFirstServiceIP(context contextpkg.Context, kubernetes kubernetespkg.Interface, namespace string, appName string) (string, error)

func GetInternalRegistryURL

func GetInternalRegistryURL(kubernetesClient kubernetes.Interface) (string, error)

func GetMetaObject

func GetMetaObject(object interface{}, log *logging.Logger) (meta.Object, error)

func GetPodIPs

func GetPodIPs(context contextpkg.Context, kubernetes kubernetespkg.Interface, namespace string, appName string) ([]string, error)

func GetPodNames

func GetPodNames(context contextpkg.Context, kubernetes kubernetespkg.Interface, namespace string, appName string) ([]string, error)

func GetPods

func GetPods(context contextpkg.Context, kubernetes kubernetespkg.Interface, namespace string, appName string) (*core.PodList, error)

func GetServiceIPs

func GetServiceIPs(context contextpkg.Context, kubernetes kubernetespkg.Interface, namespace string, appName string) ([]string, error)

func GetServices

func GetServices(context contextpkg.Context, kubernetes kubernetespkg.Interface, namespace string, appName string) (*core.ServiceList, error)

func GetUnstructuredGVK

func GetUnstructuredGVK(object *unstructured.Unstructured) (schema.GroupVersionKind, error)

func Log

func Log(kubernetes kubernetespkg.Interface, namespace string, podName string, containerName string, tail int, follow bool) (io.ReadCloser, error)

func NewConfig

func NewConfig(configPath string, context string) (*rest.Config, error)

func NewConfigForContext

func NewConfigForContext(configPath string, context string) (*rest.Config, error)

func NewConfigFromFlags added in v0.3.0

func NewConfigFromFlags(masterUrl string, configPath string, context string, log *logging.Logger) (*rest.Config, error)

See: clientcmd.BuildConfigFromFlags

func NewSelfContainedConfig

func NewSelfContainedConfig(restConfig *rest.Config, namespace string) (*api.Config, error)

func NewUnstructuredFromYAMLTemplate

func NewUnstructuredFromYAMLTemplate(code string, data interface{}) (*unstructured.Unstructured, error)

func ParseGVK

func ParseGVK(apiVersion string, kind string) (schema.GroupVersionKind, error)

func PublishOnRegistry added in v0.3.0

func PublishOnRegistry(imageName string, url urlpkg.URL, spooler *spoolerpkg.Client) error

func PullLayerFromRegistry

func PullLayerFromRegistry(imageName string, writer io.Writer, spooler *spoolerpkg.Client) error

func ReadClout

func ReadClout(reader io.Reader, urlContext *urlpkg.Context) (*cloutpkg.Clout, error)

func ReaderSize

func ReaderSize(reader io.Reader) (int64, error)

func SetCobraFlagsFromEnvironment

func SetCobraFlagsFromEnvironment(prefix string, command *cobra.Command)

func SetControllerOfUnstructured

func SetControllerOfUnstructured(object *unstructured.Unstructured, controllerObject meta.Object) error

controllerObject must also support schema.ObjectKind interface

func SetFlagsFromEnvironment

func SetFlagsFromEnvironment(prefix string)

func SetupSignalHandler

func SetupSignalHandler() <-chan struct{}

SetupSignalHandler registered for SIGTERM and SIGINT. A stop channel is returned which is closed on one of these signals. If a second signal is caught, the program is terminated with exit code 1.

func Shell

func Shell(rest restpkg.Interface, config *restpkg.Config, namespace string, podName string, containerName string, command string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error

func SortedMapStringStringKeys added in v0.2.0

func SortedMapStringStringKeys(map_ map[string]string) []string

func TarAndPublishOnRegistry added in v0.3.0

func TarAndPublishOnRegistry(imageName string, url urlpkg.URL, spooler *spoolerpkg.Client) error

TODO: unused. unnecessary?

func WriteClout

func WriteClout(clout *cloutpkg.Clout, writer io.Writer) error

Types

type Dynamic

type Dynamic struct {
	Dynamic         dynamicpkg.Interface
	Discovery       discovery.DiscoveryInterface
	InformerFactory dynamicinformer.DynamicSharedInformerFactory
	Log             *logging.Logger
	// contains filtered or unexported fields
}

func NewDynamic

func NewDynamic(dynamic dynamicpkg.Interface, discovery discovery.DiscoveryInterface, namespace string, context context.Context) *Dynamic

func (*Dynamic) AddResourceEventHandler

func (self *Dynamic) AddResourceEventHandler(gvk schema.GroupVersionKind, stopChannel <-chan struct{}, handler cache.ResourceEventHandler) error

func (*Dynamic) AddUnstructuredResourceChangeHandler

func (self *Dynamic) AddUnstructuredResourceChangeHandler(gvk schema.GroupVersionKind, stopChannel <-chan struct{}, onChanged OnChangedFunc) error

func (*Dynamic) AddUnstructuredResourceEventHandlerFuncs

func (self *Dynamic) AddUnstructuredResourceEventHandlerFuncs(gvk schema.GroupVersionKind, stopChannel <-chan struct{}, onAdded OnAddedFunc, onUpdated OnUpdatedFunc, onDeleted OnDeletedFunc) error

func (*Dynamic) CreateControlledResource

func (self *Dynamic) CreateControlledResource(object *unstructured.Unstructured, controllerObject meta.Object, processors *Processors, stopChannel <-chan struct{}) (*unstructured.Unstructured, error)

controllerObject must also support schema.ObjectKind interface

func (*Dynamic) CreateResource

func (self *Dynamic) CreateResource(object *unstructured.Unstructured) (*unstructured.Unstructured, error)

func (*Dynamic) GetInformers

func (self *Dynamic) GetInformers(gvk schema.GroupVersionKind) ([]cache.SharedInformer, []cache.SharedInformer, error)

func (*Dynamic) GetResource

func (self *Dynamic) GetResource(gvk schema.GroupVersionKind, name string, namespace string) (*unstructured.Unstructured, error)

func (*Dynamic) UpdateResource

func (self *Dynamic) UpdateResource(object *unstructured.Unstructured) (*unstructured.Unstructured, error)

type GetControllerObjectFunc

type GetControllerObjectFunc = func(name string, namespace string) (interface{}, error)

type OnAddedFunc

type OnAddedFunc = func(object *unstructured.Unstructured) error

type OnChangedFunc

type OnChangedFunc = func(object *unstructured.Unstructured) error

type OnDeletedFunc

type OnDeletedFunc = func(object *unstructured.Unstructured) error

type OnUpdatedFunc

type OnUpdatedFunc = func(oldObject *unstructured.Unstructured, newObject *unstructured.Unstructured) error

type ProcessFunc

type ProcessFunc = func(object interface{}) (bool, error)

type Processor

type Processor struct {
	Name                string
	GVK                 schema.GroupVersionKind
	Informer            cache.SharedIndexInformer
	Workqueue           workqueue.RateLimitingInterface
	Period              time.Duration
	GetControllerObject GetControllerObjectFunc
	Process             ProcessFunc
	Log                 *logging.Logger
}

func NewProcessor

func NewProcessor(name string, informer cache.SharedIndexInformer, period time.Duration, get GetControllerObjectFunc, process ProcessFunc) *Processor

func (*Processor) EnqueueFor

func (self *Processor) EnqueueFor(object interface{})

func (*Processor) HasSynced

func (self *Processor) HasSynced() bool

cache.InformerSynced signature

func (*Processor) Start

func (self *Processor) Start(concurrency uint, stopChannel <-chan struct{})

type Processors

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

func NewProcessors

func NewProcessors() *Processors

func (*Processors) Add

func (self *Processors) Add(gvk schema.GroupVersionKind, processor *Processor)

func (*Processors) Control

func (self *Processors) Control(dynamic *Dynamic, controlledGvk schema.GroupVersionKind, stopChannel <-chan struct{}) error

func (*Processors) Get

func (self *Processors) Get(name string) (*Processor, bool)

func (*Processors) HasSynced

func (self *Processors) HasSynced() []cache.InformerSynced

func (*Processors) ShutDown

func (self *Processors) ShutDown()

func (*Processors) Start

func (self *Processors) Start(concurrency uint, stopChannel <-chan struct{})

func (*Processors) WaitForCacheSync

func (self *Processors) WaitForCacheSync(stopChannel <-chan struct{}) error

type Table

type Table struct {
	Rows     [][][]string
	Style    TableStyle
	MaxWidth int

	HeadingSeparator       string
	RowSeparator           string
	TopDividerSeparator    string
	TopDivider             string
	MiddleDividerSeparator string
	MiddleDivider          string
	BottomDividerSeparator string
	BottomDivider          string
}

func NewTable

func NewTable(width int, headings ...string) *Table

func (*Table) Add

func (self *Table) Add(cells ...string)

func (*Table) ColumnWidths

func (self *Table) ColumnWidths() (int, []int)

func (*Table) Print

func (self *Table) Print()

func (*Table) Wrap

func (self *Table) Wrap()

func (*Table) Write

func (self *Table) Write(writer io.Writer)

type TableStyle

type TableStyle uint8

type TarEncoder

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

func NewTarEncoder

func NewTarEncoder(reader io.Reader, size int64) *TarEncoder

func (*TarEncoder) Drain

func (self *TarEncoder) Drain()

func (*TarEncoder) Encode

func (self *TarEncoder) Encode() io.Reader

type UnstructuredResourceEventHandler

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

func NewUnstructuredResourceEventHandler

func NewUnstructuredResourceEventHandler(onAdded OnAddedFunc, onUpdated OnUpdatedFunc, onDeleted OnDeletedFunc) *UnstructuredResourceEventHandler

func (*UnstructuredResourceEventHandler) OnAdd

func (self *UnstructuredResourceEventHandler) OnAdd(object interface{})

cache.ResourceEventHandler interface

func (*UnstructuredResourceEventHandler) OnDelete

func (self *UnstructuredResourceEventHandler) OnDelete(object interface{})

cache.ResourceEventHandler interface

func (*UnstructuredResourceEventHandler) OnUpdate

func (self *UnstructuredResourceEventHandler) OnUpdate(oldObject interface{}, newObject interface{})

cache.ResourceEventHandler interface

Jump to

Keyboard shortcuts

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