parser

package
v1.0.0-alpha.0...-0be9a8d Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const (
	OutputDevfileJsonPath = "devfile.json"
	OutputDevfileYamlPath = "devfile.yaml"
)

Default filenames for create devfile

Variables

This section is empty.

Functions

func GetContainerPortsFromStrings

func GetContainerPortsFromStrings(ports []string) ([]corev1.ContainerPort, error)

GetContainerPortsFromStrings generates ContainerPort values from the array of string port values ports is the array containing the string port values

func InArray

func InArray(arr []string, value string) bool

In checks if the value is in the array

func Merge

func Merge(original []v1.EnvVar, other []v1.EnvVar) []v1.EnvVar

Merge merges the other EnvVarlist with keeping last value for duplicate EnvVars and returns a new EnvVarList

func RemoveEnvVarsFromList

func RemoveEnvVarsFromList(envVarList []v1.EnvVar, keys []string) ([]v1.EnvVar, error)

RemoveEnvVarsFromList removes the env variables based on the keys provided and returns a new EnvVarList

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(otherList []v1.EnvVar) error

AddEnvVars adds environment variables to all the components in a devfile

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(keys []string) (err error)

RemoveEnvVars removes the environment variables which have the keys from all the components in a devfile

func (DevfileObj) RemovePorts

func (d DevfileObj) RemovePorts() error

RemovePorts removes all container endpoints from a devfile

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(ports ...string) error

SetPorts converts ports to endpoints, adds to a devfile

func (*DevfileObj) WriteJsonDevfile

func (d *DevfileObj) WriteJsonDevfile() error

WriteJsonDevfile creates a devfile.json file

func (*DevfileObj) WriteYamlDevfile

func (d *DevfileObj) WriteYamlDevfile() error

WriteYamlDevfile creates a devfile.yaml file

type ParserArgs

type ParserArgs struct {
	// Path is a relative or absolute devfile path.
	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
	// 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
	// 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
}

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.

Directories

Path Synopsis
v2

Jump to

Keyboard shortcuts

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