const DebugEndpointNamePrefix = "debug"
func AddKubernetesComponentToDevfile(crd, name string, devfileObj parser.DevfileObj) (parser.DevfileObj, error)
AddKubernetesComponentToDevfile adds a resource definition to devfile object as an inlined Kubernetes component
func Build(ctx context.Context, devfileObj parser.DevfileObj, buildCmd string, handler Handler) error
Build executes the default Build command of the devfile. If buildCmd is empty, this looks for the default Build command in the Devfile. No error is returned and no operation is performed if the default command could not be found. An error is returned if buildCmd is not empty and has no corresponding command in the Devfile.
func Deploy(ctx context.Context, devfileObj parser.DevfileObj, handler Handler) error
Deploy executes the default deploy command of the devfile.
func ExecPostStartEvents(ctx context.Context, devfileObj parser.DevfileObj, handler Handler) error
func ExecPreStopEvents(ctx context.Context, devfileObj parser.DevfileObj, handler Handler) error
func ExecuteCommandByName(ctx context.Context, devfileObj parser.DevfileObj, cmdName string, handler Handler, ignoreCommandNotFound bool) error
ExecuteCommandByName executes the specified command cmdName in the Devfile. If ignoreCommandNotFound is true, nothing is executed if the command is not found and no error is returned.
func ExecuteCommandByNameAndKind(ctx context.Context, devfileObj parser.DevfileObj, cmdName string, kind v1alpha2.CommandGroupKind, handler Handler, ignoreCommandNotFound bool) error
ExecuteCommandByNameAndKind executes the specified command cmdName of the given kind in the Devfile. If cmdName is empty, it executes the default command for the given kind or returns an error if there is no default command. If ignoreCommandNotFound is true, nothing is executed if the command is not found and no error is returned.
func FindComponentByName(d data.DevfileData, n string) (v1alpha2.Component, bool, error)
FindComponentByName returns the Devfile component that matches the specified name.
func GetCommand( devfileObj parser.DevfileObj, commandName string, groupType v1alpha2.CommandGroupKind, ) (v1alpha2.Command, bool, error)
GetCommand iterates through the devfile commands and returns the devfile command with the specified name and group kind. If commandName is empty, it returns the default command for the group kind; or, if there is only one command for the specified kind, it will return that (even if it is not marked as the default). It returns an error if there is more than one default command.
func GetContainerComponentsForCommand(devfileObj parser.DevfileObj, cmd v1alpha2.Command) ([]string, error)
GetContainerComponentsForCommand returns the list of container components that would get used if the specified command runs.
func GetContainerEndpointMapping(containers []v1alpha2.Component, includeDebug bool) map[string][]v1alpha2.Endpoint
GetContainerEndpointMapping returns a map of container names and slice of its endpoints. Debug endpoints will be included only if includeDebug is true.
func GetDebugEndpointsForComponent(cmp v1alpha2.Component) ([]v1alpha2.Endpoint, error)
GetDebugEndpointsForComponent returns all Debug endpoints for the specified component. It returns an error if the component specified is not a container component.
func GetDevfileContainerEndpointMapping(devFileObj parser.DevfileObj, includeDebug bool) (map[string][]v1alpha2.Endpoint, error)
GetDevfileContainerEndpointMapping returns a map of container components names and slice of its endpoints, given a Devfile object in parameter. Debug endpoints will be included only if includeDebug is true.
func GetEndpointsFromDevfile(devfileObj parser.DevfileObj, ignoreExposures []v1alpha2.EndpointExposure) ([]v1alpha2.Endpoint, error)
GetEndpointsFromDevfile returns a slice of all endpoints in a devfile and ignores the endpoints with exposure values in ignoreExposures
func GetImageComponentsToPushAutomatically(devfileObj parser.DevfileObj) ([]v1alpha2.Component, error)
GetImageComponentsToPushAutomatically returns the list of Image components that can be automatically created on startup. The list returned is governed by the AutoBuild field in each component. All components with AutoBuild set to true are included, along with those with no AutoBuild set and not-referenced.
func GetK8sAndOcComponentsToPush(devfileObj parser.DevfileObj, allowApply bool) ([]v1alpha2.Component, error)
GetK8sAndOcComponentsToPush returns the list of Kubernetes and OpenShift components to push, The list returned is governed by the DeployByDefault field in each component. All components with DeployByDefault set to true are included, along with those with no DeployByDefault set and not-referenced. It takes an additional allowApply boolean, which set to true, will append the components referenced from apply commands to the list.
func GetK8sComponentAsUnstructuredList(devfileObj parser.DevfileObj, componentName string, context string, fs devfilefs.Filesystem) ([]unstructured.Unstructured, error)
GetK8sComponentAsUnstructuredList parses the Inlined/URI K8s of the Devfile K8s component and returns a list of unstructured.Unstructured objects; List is returned here because it is possible to define multiple K8s resources against a single Devfile K8s component
func GetK8sManifestsWithVariablesSubstituted(devfileObj parser.DevfileObj, devfileCmpName string, context string, fs devfilefs.Filesystem) (string, error)
GetK8sManifestsWithVariablesSubstituted returns the full content of either a Kubernetes or an Openshift Devfile component, either Inlined or referenced via a URI. No matter how the component is defined, it returns the content with all variables substituted using the global variables map defined in `devfileObj`. An error is returned if the content references an invalid variable key not defined in the Devfile object.
func GetReferencedLocalFiles(devfileObj parser.DevfileObj) (result []string, err error)
GetReferencedLocalFiles returns the local files referenced by the Devfile. This includes: - the non-inlined Kubernetes and Openshift components - the Dockerfiles of Image components - the parent devfile - resursively, the local files referenced by the parent Devfile The passed Devfile must be flattened
func HasDebugCommand(devfileData data.DevfileData) bool
func HasDeployCommand(devfileData data.DevfileData) bool
func HasPostStartEvents(devfileObj parser.DevfileObj) bool
func HasPreStopEvents(devfileObj parser.DevfileObj) bool
func HasRunCommand(devfileData data.DevfileData) bool
func IsComponentReferenced(allApplyCommands []v1alpha2.Command, cmpName string) bool
func IsDebugEndpoint(ep v1alpha2.Endpoint) bool
IsDebugEndpoint returns whether the specified endpoint represents a Debug endpoint, based on the following naming convention: it is considered a Debug endpoint if it's named "debug" or if its name starts with "debug-".
func IsDebugPort(name string) bool
IsDebugPort returns whether the specified string represents a Debug endpoint, based on the following naming convention: it is considered a Debug endpoint if it's named "debug" or if its name starts with "debug-".
func ListKubernetesComponents(devfileObj parser.DevfileObj, path string) (list []unstructured.Unstructured, err error)
ListKubernetesComponents lists all the kubernetes components from the devfile
func ListOpenShiftComponents(devfileObj parser.DevfileObj, path string) (list []unstructured.Unstructured, err error)
ListOpenShiftComponents lists all the openshift components from the devfile
func ValidateAndGetCommand(devfileObj parser.DevfileObj, commandName string, groupType v1alpha2.CommandGroupKind) (v1alpha2.Command, error)
ValidateAndGetCommand validates and returns the command specified if it is valid. It works just like GetCommand, except that it returns an error if it could not find the command.
If commandName is empty, it looks up the default command for the given kind.
A command is "valid" here if it was found given its name (if commandName is not empty), or (for a default command), if there is no other default command for the same kind.
func ValidateAndGetPushCommands( devfileObj parser.DevfileObj, devfileBuildCmd, devfileRunCmd string, ) (map[v1alpha2.CommandGroupKind]v1alpha2.Command, error)
ValidateAndGetPushCommands validates the build and the run commands, if provided through odo dev or else checks the devfile for devBuild and devRun. It returns the build and run commands if validated successfully, or an error otherwise.
ComponentNotExistError is returned when a component referenced in a command or component does not exist
type ComponentNotExistError struct {
// contains filtered or unexported fields
}
func NewComponentNotExistError(name string) ComponentNotExistError
func (e ComponentNotExistError) Error() string
ComponentTypeNotFoundError is returned when no component with the specified type has been found in Devfile
type ComponentTypeNotFoundError struct {
// contains filtered or unexported fields
}
func NewComponentTypeNotFoundError(componentType v1alpha2.ComponentType) ComponentTypeNotFoundError
func (e ComponentTypeNotFoundError) Error() string
type ComponentsWithSameNameError struct {
// contains filtered or unexported fields
}
func NewComponentsWithSameNameError(name string) ComponentsWithSameNameError
func (e ComponentsWithSameNameError) Error() string
type DevfileCommands struct { BuildCmd string RunCmd string DebugCmd string }
type DevfileEventType string
const ( // PreStop is a devfile event PreStop DevfileEventType = "preStop" )
type Handler interface { ApplyImage(image v1alpha2.Component) error ApplyKubernetes(kubernetes v1alpha2.Component, kind v1alpha2.CommandGroupKind) error ApplyOpenShift(openshift v1alpha2.Component, kind v1alpha2.CommandGroupKind) error ExecuteNonTerminatingCommand(ctx context.Context, command v1alpha2.Command) error ExecuteTerminatingCommand(ctx context.Context, command v1alpha2.Command) error }
MockHandler is a mock of Handler interface.
type MockHandler struct {
// contains filtered or unexported fields
}
func NewMockHandler(ctrl *gomock.Controller) *MockHandler
NewMockHandler creates a new mock instance.
func (m *MockHandler) ApplyImage(image v1alpha2.Component) error
ApplyImage mocks base method.
func (m *MockHandler) ApplyKubernetes(kubernetes v1alpha2.Component, kind v1alpha2.CommandGroupKind) error
ApplyKubernetes mocks base method.
func (m *MockHandler) ApplyOpenShift(openshift v1alpha2.Component, kind v1alpha2.CommandGroupKind) error
ApplyOpenShift mocks base method.
func (m *MockHandler) EXPECT() *MockHandlerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockHandler) ExecuteNonTerminatingCommand(ctx context.Context, command v1alpha2.Command) error
ExecuteNonTerminatingCommand mocks base method.
func (m *MockHandler) ExecuteTerminatingCommand(ctx context.Context, command v1alpha2.Command) error
ExecuteTerminatingCommand mocks base method.
MockHandlerMockRecorder is the mock recorder for MockHandler.
type MockHandlerMockRecorder struct {
// contains filtered or unexported fields
}
func (mr *MockHandlerMockRecorder) ApplyImage(image interface{}) *gomock.Call
ApplyImage indicates an expected call of ApplyImage.
func (mr *MockHandlerMockRecorder) ApplyKubernetes(kubernetes, kind interface{}) *gomock.Call
ApplyKubernetes indicates an expected call of ApplyKubernetes.
func (mr *MockHandlerMockRecorder) ApplyOpenShift(openshift, kind interface{}) *gomock.Call
ApplyOpenShift indicates an expected call of ApplyOpenShift.
func (mr *MockHandlerMockRecorder) ExecuteNonTerminatingCommand(ctx, command interface{}) *gomock.Call
ExecuteNonTerminatingCommand indicates an expected call of ExecuteNonTerminatingCommand.
func (mr *MockHandlerMockRecorder) ExecuteTerminatingCommand(ctx, command interface{}) *gomock.Call
ExecuteTerminatingCommand indicates an expected call of ExecuteTerminatingCommand.
MoreThanOneDefaultCommandFoundError is returned when several default commands of the specified kind exist
type MoreThanOneDefaultCommandFoundError struct {
// contains filtered or unexported fields
}
func NewMoreThanOneDefaultCommandFoundError(kind v1alpha2.CommandGroupKind) MoreThanOneDefaultCommandFoundError
func (e MoreThanOneDefaultCommandFoundError) Error() string
NoCommandForGroup indicates an error when no command was found for the given Group
type NoCommandForGroup struct { Group v1alpha2.CommandGroupKind }
func (n NoCommandForGroup) Error() string
NoCommandFoundError is returned when no command of the specified kind is found in devfile
type NoCommandFoundError struct {
// contains filtered or unexported fields
}
func NewNoCommandFoundError(kind v1alpha2.CommandGroupKind, name string) NoCommandFoundError
func (e NoCommandFoundError) Error() string
NoDefaultCommandFoundError is returned when several commands of the specified kind exist but no one is the default one
type NoDefaultCommandFoundError struct {
// contains filtered or unexported fields
}
func NewNoDefaultCommandFoundError(kind v1alpha2.CommandGroupKind) NoDefaultCommandFoundError
func (e NoDefaultCommandFoundError) Error() string