Documentation ¶
Index ¶
- Constants
- func GetDeployComponents(devfileData data.DevfileData) (map[string]string, error)
- func GetImageBuildComponent(devfileData data.DevfileData, deployAssociatedComponents map[string]string) (devfilev1.Component, error)
- func ReadKubernetesYaml(src YamlSrc, fs *afero.Afero, devfileUtilsClient parserUtil.DevfileUtils) ([]interface{}, error)
- type DevfileObj
- func (d DevfileObj) AddEnvVars(containerEnvMap map[string][]v1.EnvVar) error
- func (d DevfileObj) GetMemory() string
- func (d DevfileObj) GetMetadataName() string
- func (d DevfileObj) HasPorts() bool
- func (d DevfileObj) RemoveEnvVars(containerEnvMap map[string][]string) (err error)
- func (d DevfileObj) RemovePorts(containerPortsMap map[string][]string) error
- func (d DevfileObj) SetMemory(memory string) error
- func (d DevfileObj) SetMetadataName(name string) error
- func (d DevfileObj) SetPorts(containerPortsMap map[string][]string) error
- func (d *DevfileObj) WriteYamlDevfile() error
- type ImageSelectorArgs
- type KubernetesResources
- type ParserArgs
- type YamlSrc
Constants ¶
const ( Name = "Name" Ports = "Ports" Memory = "Memory" PortsDescription = "Ports to be opened in all component containers" MemoryDescription = "The Maximum memory all the component containers can consume" NameDescription = "The name of the component" )
const ( OutputDevfileYamlPath = "devfile.yaml" K8sLikeComponentOriginalURIKey = "api.devfile.io/k8sLikeComponent-originalURI" )
Default filenames for create devfile
Variables ¶
This section is empty.
Functions ¶
func GetDeployComponents ¶ added in v2.2.0
func GetDeployComponents(devfileData data.DevfileData) (map[string]string, error)
GetDeployComponents gets the default deploy command associated components
func GetImageBuildComponent ¶ added in v2.2.0
func GetImageBuildComponent(devfileData data.DevfileData, deployAssociatedComponents map[string]string) (devfilev1.Component, error)
GetImageBuildComponent gets the image build component from the deploy associated components
func ReadKubernetesYaml ¶
func ReadKubernetesYaml(src YamlSrc, fs *afero.Afero, devfileUtilsClient parserUtil.DevfileUtils) ([]interface{}, error)
ReadKubernetesYaml reads a yaml Kubernetes file from either the Path, URL or Data provided. It returns all the parsed Kubernetes objects as an array of interface. Consumers interested in the Kubernetes resources are expected to Unmarshal it to the struct of the respective Kubernetes resource. If a Path is being passed, provide a filesystem, otherwise nil can be passed in. Pass in an optional client to use either the actual implementation or a mock implementation of the interface.
Types ¶
type DevfileObj ¶
type DevfileObj struct { // Ctx has devfile context info Ctx devfileCtx.DevfileCtx // Data has the devfile data Data data.DevfileData }
DevfileObj is the runtime devfile object
func Parse ¶
func Parse(path string) (d DevfileObj, err error)
Parse func populates the flattened devfile data, parses and validates the devfile integrity. Creates devfile context and runtime objects Deprecated, use ParseDevfile() instead
func ParseDevfile ¶
func ParseDevfile(args ParserArgs) (d DevfileObj, err error)
ParseDevfile func populates the devfile data, parses and validates the devfile integrity. Creates devfile context and runtime objects
func ParseFromData ¶
func ParseFromData(data []byte) (d DevfileObj, err error)
ParseFromData func parses and validates the devfile integrity. Creates devfile context and runtime objects Deprecated, use ParseDevfile() instead
func ParseFromURL ¶
func ParseFromURL(url string) (d DevfileObj, err error)
ParseFromURL func parses and validates the devfile integrity. Creates devfile context and runtime objects Deprecated, use ParseDevfile() instead
func ParseRawDevfile ¶
func ParseRawDevfile(path string) (d DevfileObj, err error)
ParseRawDevfile populates the raw devfile data without overriding and merging Deprecated, use ParseDevfile() instead
func (DevfileObj) AddEnvVars ¶
func (d DevfileObj) AddEnvVars(containerEnvMap map[string][]v1.EnvVar) error
AddEnvVars accepts a map of container name mapped to an array of the env vars to be set; it adds the envirnoment variables to a given container name, and writes to the devfile Example of containerEnvMap : {"runtime": {{Name: "Foo", Value: "Bar"}}}
func (DevfileObj) GetMemory ¶
func (d DevfileObj) GetMemory() string
GetMemory gets memoryLimit from devfile container
func (DevfileObj) GetMetadataName ¶
func (d DevfileObj) GetMetadataName() string
GetMetadataName gets metadata name from a devfile
func (DevfileObj) HasPorts ¶
func (d DevfileObj) HasPorts() bool
HasPorts checks if a devfile contains container endpoints
func (DevfileObj) RemoveEnvVars ¶
func (d DevfileObj) RemoveEnvVars(containerEnvMap map[string][]string) (err error)
RemoveEnvVars accepts a map of container name mapped to an array of environment variables to be removed; it removes the env vars from the specified container name and writes it to the devfile
func (DevfileObj) RemovePorts ¶
func (d DevfileObj) RemovePorts(containerPortsMap map[string][]string) error
RemovePorts accepts a map of container name mapped to an array of port numbers to be removed; it removes the container endpoints with the specified port numbers of the specified container, and writes to the devfile Example of containerPortsMap: {"runtime": {"8080", "9000"}, "wildfly": {"12956"}}
func (DevfileObj) SetMemory ¶
func (d DevfileObj) SetMemory(memory string) error
SetMemory sets memoryLimit in devfile container
func (DevfileObj) SetMetadataName ¶
func (d DevfileObj) SetMetadataName(name string) error
SetMetadataName set metadata name in a devfile
func (DevfileObj) SetPorts ¶
func (d DevfileObj) SetPorts(containerPortsMap map[string][]string) error
SetPorts accepts a map of container name mapped to an array of port numbers to be set; it converts ports to endpoints, sets the endpoint to a given container name, and writes to the devfile Example of containerPortsMap: {"runtime": {"8080", "9000"}, "wildfly": {"12956"}}
func (*DevfileObj) WriteYamlDevfile ¶
func (d *DevfileObj) WriteYamlDevfile() error
WriteYamlDevfile writes the content of the Devfile data to its absolute path on the filesystem.
type ImageSelectorArgs ¶ added in v2.2.1
type ImageSelectorArgs struct { // Registry is the registry base path under which images matching selectors will be built and pushed to. Required. // // Example: <local-registry>/<user-org> Registry string // Tag represents a tag identifier under which images matching selectors will be built and pushed to. // This should ideally be set to a unique identifier for each run of the caller tool. Tag string }
ImageSelectorArgs defines the structure to leverage for using image names as selectors after parsing the Devfile. The fields defined here will be used together to compute the final image names that will be built and pushed, and replaced in all matching Image, Container or Kubernetes/OpenShift components.
For Kubernetes/OpenShift components, replacement is done only in core Kubernetes resources (CronJob, DaemonSet, Deployment, Job, Pod, ReplicaSet, ReplicationController, StatefulSet) that are *inlined* in those components. Resources referenced via URIs will not be resolved. So you may want to also set ConvertKubernetesContentInUri to true in the parser args.
For example, if Registry is set to "<local-registry>/<user-org>" and Tag is set to "some-dynamic-unique-tag", all container and Kubernetes/OpenShift components matching a relative image name (say "my-image-name") of an Image component will be replaced in the resulting Devfile by: "<local-registry>/<user-org>/<devfile-name>-my-image-name:some-dynamic-unique-tag".
type KubernetesResources ¶
type KubernetesResources struct { Deployments []appsv1.Deployment Services []corev1.Service Routes []routev1.Route Ingresses []networkingv1.Ingress Others []interface{} }
KubernetesResources struct contains the Deployments, Services, Routes and Ingresses resources
func ParseKubernetesYaml ¶
func ParseKubernetesYaml(values []interface{}) (KubernetesResources, error)
ParseKubernetesYaml Unmarshals the interface array of the Kubernetes resources and returns it as a KubernetesResources struct. Only Deployment, Service, Route and Ingress are processed. Consumers interested in other Kubernetes resources are expected to parse the values interface array an Unmarshal it to their desired Kuberenetes struct
type ParserArgs ¶
type ParserArgs struct { // Path is a relative or absolute devfile path on disk. // It can also be a relative or absolute path to a folder containing one or more devfiles, // in which case the library will try to pick an existing one, based on the following priority order: // devfile.yaml > .devfile.yaml > devfile.yml > .devfile.yml Path string // URL is the URL address of the specific devfile. URL string // Data is the devfile content in []byte format. Data []byte // FlattenedDevfile defines if the returned devfileObj is flattened content (true) or raw content (false). // The value is default to be true. FlattenedDevfile *bool // ConvertKubernetesContentInUri defines if the kubernetes resources definition from uri will be converted to inlined in devObj(true) or not (false). // The value is default to be true. ConvertKubernetesContentInUri *bool // RegistryURLs is a list of registry hosts which parser should pull parent devfile from. // If registryUrl is defined in devfile, this list will be ignored. RegistryURLs []string // Token is a GitHub, GitLab, or Bitbucket personal access token used with a private git repo URL Token string // DefaultNamespace is the default namespace to use // If namespace is defined under devfile's parent kubernetes object, this namespace will be ignored. DefaultNamespace string // Context is the context used for making Kubernetes requests Context context.Context // K8sClient is the Kubernetes client instance used for interacting with a cluster K8sClient client.Client // ExternalVariables override variables defined in the Devfile ExternalVariables map[string]string // HTTPTimeout overrides the request and response timeout values for reading a parent devfile reference from the registry. If a negative value is specified, the default timeout will be used. HTTPTimeout *int // SetBooleanDefaults sets the boolean properties to their default values after a devfile been parsed. // The value is true by default. Clients can set this to false if they want to set the boolean properties themselves SetBooleanDefaults *bool // ImageNamesAsSelector sets the information that will be used to handle image names as selectors when parsing the Devfile. // Not setting this field or setting it to nil disables the logic of handling image names as selectors. ImageNamesAsSelector *ImageSelectorArgs // DownloadGitResources downloads the resources from Git repository if true DownloadGitResources *bool // DevfileUtilsClient exposes the interface for mock implementation. DevfileUtilsClient parserUtil.DevfileUtils }
ParserArgs is the struct to pass into parser functions which contains required info for parsing devfile. It accepts devfile path, devfile URL or devfile content in []byte format.
type YamlSrc ¶
type YamlSrc struct { // Path to the yaml file Path string // URL of the yaml file URL string // Token to access a private URL like a private repository Token string // Data is the yaml content in []byte format Data []byte }
YamlSrc specifies the src of the yaml in either Path, URL or Data format