component

package
v1.0.0-beta3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const ComponentSourceTypeAnnotation = "app.kubernetes.io/component-source-type"

Variables

View Source
var ErrUserRequestedWatchExit = fmt.Errorf("safely exiting from filesystem watch based on user request")

ErrUserRequestedWatchExit is returned when the user stops the watch loop

Functions

func ApplyConfig added in v1.0.0

func ApplyConfig(client *occlient.Client, componentConfig config.LocalConfigInfo, stdout io.Writer, cmpExist bool) (err error)

ApplyConfig applies the component config onto component dc Parameters:

	client: occlient instance
	appName: Name of application of which the component is a part
	componentName: Name of the component which is being patched with config
	componentConfig: Component configuration
 	cmpExist: true if components exists in the cluster

Returns:

err: Errors if any else nil

func ApplyConfigCreateURL added in v1.0.0

func ApplyConfigCreateURL(client *occlient.Client, componentConfig config.LocalConfigInfo) error

ApplyConfigCreateURL applies url config onto component

func Build added in v0.0.5

func Build(client *occlient.Client, componentName string, applicationName string, wait bool, stdout io.Writer, show bool) error

Build component from BuildConfig. If 'wait' is true than it waits for build to successfully complete. If 'wait' is false than this function won't return error even if build failed. 'show' will determine whether or not the log will be shown to the user (while building)

func CheckComponentMandatoryParams added in v1.0.0

func CheckComponentMandatoryParams(componentSettings config.ComponentSettings) error

CheckComponentMandatoryParams checks mandatory parammeters for component

func CreateComponent added in v1.0.0

func CreateComponent(client *occlient.Client, componentConfig config.LocalConfigInfo, context string, stdout io.Writer) (err error)

CreateComponent creates component as per the passed component settings

Parameters:
	client: occlient instance
	componentConfig: the component configuration that holds all details of component
	context: the component context indicating the location of component config and hence its source as well
	stdout: io.Writer instance to write output to
Returns:
	err: errors if any

func CreateFromGit

func CreateFromGit(client *occlient.Client, params occlient.CreateArgs) error

CreateFromGit inputPorts is the array containing the string port values inputPorts is the array containing the string port values envVars is the array containing the environment variables

func CreateFromPath added in v0.0.5

func CreateFromPath(client *occlient.Client, params occlient.CreateArgs) error

CreateFromPath create new component with source or binary from the given local path sourceType indicates the source type of the component and can be either local or binary envVars is the array containing the environment variables

func Delete

func Delete(client *occlient.Client, componentName string, applicationName string) error

Delete whole component

func Deploy added in v1.0.0

func Deploy(client *occlient.Client, params occlient.CreateArgs, desiredRevision int64) error

Deploy deploys the component it starts a new deployment and wait for the new dc to be available desiredRevision is the desired version of the deployment config to wait for

func Exists added in v0.0.4

func Exists(client *occlient.Client, componentName, applicationName string) (bool, error)

Exists checks whether a component with the given name exists in the current application or not componentName is the component name to perform check for The first returned parameter is a bool indicating if a component with the given name already exists or not The second returned parameter is the error that might occurs while execution

func GetComponentDir added in v0.0.15

func GetComponentDir(path string, paramType config.SrcType) (string, error)

GetComponentDir returns source repo name Parameters:

path: git url or source path or binary path
paramType: One of CreateType as in GIT/LOCAL/BINARY

Returns: directory name

func GetComponentLinkedSecretNames added in v0.0.18

func GetComponentLinkedSecretNames(client *occlient.Client, componentName string, applicationName string) (secretNames []string, err error)

GetComponentLinkedSecretNames provides a slice containing the names of the secrets that are present in envFrom

func GetComponentPorts added in v0.0.10

func GetComponentPorts(client *occlient.Client, componentName string, applicationName string) (ports []string, err error)

GetComponentPorts provides slice of ports used by the component in the form port_no/protocol

func GetComponentSource added in v0.0.3

func GetComponentSource(client *occlient.Client, componentName string, applicationName string) (string, string, error)

GetComponentSource what source type given component uses The first returned string is component source type ("git" or "local" or "binary") The second returned string is a source (url to git repository or local path or path to binary) we retrieve the source type by looking up the DeploymentConfig that's deployed

func GetComponentType added in v0.0.3

func GetComponentType(client *occlient.Client, componentName string, applicationName string) (string, error)

GetComponentType returns type of component in given application and project

func GetDefaultComponentName added in v0.0.15

func GetDefaultComponentName(componentPath string, componentPathType config.SrcType, componentType string, existingComponentList ComponentList) (string, error)

GetDefaultComponentName generates a unique component name Parameters: desired default component name(w/o prefix) and slice of existing component names Returns: Unique component name and error if any

func GetLogs added in v0.0.6

func GetLogs(client *occlient.Client, componentName string, applicationName string, follow bool, stdout io.Writer) error

GetLogs follow the DeploymentConfig logs if follow is set to true

func PushLocal added in v0.0.3

func PushLocal(client *occlient.Client, componentName string, applicationName string, path string, out io.Writer, files []string, delFiles []string, isForcePush bool, globExps []string, show bool) error

PushLocal push local code to the cluster and trigger build there. During copying binary components, path represent base directory path to binary and files contains path of binary During copying local source components, path represent base directory path whereas files is empty During `odo watch`, path represent base directory path whereas files contains list of changed Files Parameters:

componentName is name of the component to update sources to
applicationName is the name of the application of which the component is a part
path is base path of the component source/binary
files is list of changed files captured during `odo watch` as well as binary file path
delFiles is the list of files identified as deleted
isForcePush indicates if the sources to be updated are due to a push in which case its a full source directory push or only push of identified sources
globExps are the glob expressions which are to be ignored during the push
show determines whether or not to show the log (passed in by po.show argument within /cmd)

Returns

Error if any

func Update added in v0.0.4

func Update(client *occlient.Client, componentSettings config.LocalConfigInfo, newSource string, stdout io.Writer) error

Update updates the requested component Parameters:

client: occlient instance
componentSettings: Component configuration
newSource: Location of component source resolved to absolute path
stdout: io pipe to write logs to

Returns:

errors if any

func ValidateComponentCreateRequest added in v1.0.0

func ValidateComponentCreateRequest(client *occlient.Client, componentSettings config.ComponentSettings, isCmpExistsCheck bool) (err error)

ValidateComponentCreateRequest validates request for component creation and returns errors if any Parameters:

componentSettings: Component settings
isCmpExistsCheck: boolean to indicate whether or not error out if component with same name already exists

Returns:

errors if any

func WatchAndPush added in v0.0.4

func WatchAndPush(client *occlient.Client, out io.Writer, parameters WatchParameters) error

WatchAndPush watches path, if something changes in that path it calls PushLocal ignores .git/* by default inspired by https://github.com/openshift/origin/blob/e785f76194c57bd0e1674c2f2776333e1e0e4e78/pkg/oc/cli/cmd/rsync/rsync.go#L257 Parameters:

client: occlient instance
out: io Writer instance
parameters: WatchParameters

Types

type Component added in v0.0.19

type Component struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ComponentSpec   `json:"spec,omitempty"`
	Status            ComponentStatus `json:"status,omitempty"`
}

Component

func GetComponent added in v0.0.20

func GetComponent(client *occlient.Client, componentName string, applicationName string, projectName string) (component Component, err error)

GetComponent provides component definition

type ComponentList added in v0.0.19

type ComponentList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Component `json:"items"`
}

ComponentList is list of components

func List added in v0.0.3

func List(client *occlient.Client, applicationName string) (ComponentList, error)

List lists components in active application

func ListIfPathGiven added in v1.0.0

func ListIfPathGiven(client *occlient.Client, paths []string) (ComponentList, error)

ListIfPathGiven lists all available component in given path directory

type ComponentSpec added in v0.0.19

type ComponentSpec struct {
	Type    string          `json:"type,omitempty"`
	Source  string          `json:"source,omitempty"`
	URL     []string        `json:"url,omitempty"`
	Storage []string        `json:"storage,omitempty"`
	Env     []corev1.EnvVar `json:"env,omitempty"`
}

ComponentSpec is spec of components

type ComponentStatus added in v0.0.19

type ComponentStatus struct {
	Context          string              `json:"context,omitempty"`
	State            string              `json:"state"`
	LinkedComponents map[string][]string `json:"linkedComponents,omitempty"`
	LinkedServices   []string            `json:"linkedServices,omitempty"`
}

ComponentStatus is Status of components

type WatchParameters added in v0.0.17

type WatchParameters struct {
	// Name of component that is to be watched
	ComponentName string
	// Name of application, the component is part of
	ApplicationName string
	// The path to the source of component(local or binary)
	Path string
	// List/Slice of files/folders in component source, the updates to which need not be pushed to component deployed pod
	FileIgnores []string
	// Custom function that can be used to push detected changes to remote pod. For more info about what each of the parameters to this function, please refer, pkg/component/component.go#PushLocal
	WatchHandler func(*occlient.Client, string, string, string, io.Writer, []string, []string, bool, []string, bool) error
	// This is a channel added to signal readiness of the watch command to the external channel listeners
	StartChan chan bool
	// This is a channel added to terminate the watch command gracefully without passing SIGINT. "Stop" message on this channel terminates WatchAndPush function
	ExtChan chan bool
	// Interval of time before pushing changes to remote(component) pod
	PushDiffDelay int
	// Parameter whether or not to show build logs
	Show bool
}

WatchParameters is designed to hold the controllables and attributes that the watch function works on

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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