config

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Type is the name of the setting controlling the component type i.e. builder image
	Type = "Type"
	// TypeDescription is human-readable description of the Type setting
	TypeDescription = "The type of component"
	// Name is the name of the setting controlling the component name
	Name = "Name"
	// NameDescription is human-readable description of the Name setting
	NameDescription = "The name of the component"
	// MinMemory is the name of the setting controlling the min memory a component consumes
	MinMemory = "MinMemory"
	// MinMemoryDescription is the description of the setting controlling the minimum memory
	MinMemoryDescription = "The minimum memory a component is provided"
	// MaxMemory is the name of the setting controlling the min memory a component consumes
	MaxMemory = "MaxMemory"
	// MaxMemoryDescription is the description of the setting controlling the maximum memory
	MaxMemoryDescription = "The maximum memory a component can consume"
	// Memory is the name of the setting controlling the memory a component consumes
	Memory = "Memory"
	// MemoryDescription is the description of the setting controlling the min and max memory to same value
	MemoryDescription = "The minimum and maximum memory a component can consume"
	// DebugPort is the port where the application is set to listen for debugger
	DebugPort = "DebugPort"
	// DebugPortDescription is the description for debug port
	DebugPortDescription = "The port on which the debugger will listen on the component"
	// Ignore is the name of the setting controlling the min memory a component consumes
	Ignore = "Ignore"
	// IgnoreDescription is the description of the setting controlling the use of .odoignore file
	IgnoreDescription = "Consider the .odoignore file for push and watch"
	// MinCPU is the name of the setting controlling minimum cpu
	MinCPU = "MinCPU"
	// MinCPUDescription is the description of the setting controlling the min CPU value
	MinCPUDescription = "The minimum CPU a component can consume"
	// MaxCPU is the name of the setting controlling the use of .odoignore file
	MaxCPU = "MaxCPU"
	//MaxCPUDescription is the description of the setting controlling the max CPU value
	MaxCPUDescription = "The maximum CPU a component can consume"
	// CPU is the name of the setting controlling the cpu a component consumes
	CPU = "CPU"
	// CPUDescription is the description of the setting controlling the min and max CPU to same value
	CPUDescription = "The minimum and maximum CPU a component can consume"
	// SourceLocation indicates path of the source e.g. location of the git repo
	SourceLocation = "SourceLocation"
	// SourceType indicates type of component source -- git/binary/local
	SourceType = "SourceType"
	// Ref indicates git ref for the component source
	Ref = "Ref"
	// Ports is the space separated list of user specified ports to be opened in the component
	Ports = "Ports"
	// Application indicates application of which component is part of
	Application = "Application"
	// Project indicates project the component is part of
	Project = "Project"
	// ProjectDescription is the description of project component setting
	ProjectDescription = "Project is the name of the project the component is part of"
	// ApplicationDescription is the description of app component setting
	ApplicationDescription = "Application is the name of application the component needs to be part of"
	// PortsDescription is the desctription of the ports component setting
	PortsDescription = "Ports to be opened in the component"
	// RefDescription is the description of ref setting
	RefDescription = "Git ref to use for creating component from git source"
	// SourceTypeDescription is the description of type setting
	SourceTypeDescription = "Type of component source - git/binary/local"
	// Storage is the name of the setting controlling storage
	Storage = "Storage"
	// StorageDescription is the description of the storage
	StorageDescription = "Storage of the component"
	// SourceLocationDescription is the human-readable description of path setting
	SourceLocationDescription = "The path indicates the location of binary file or git source"
	// URL
	URL = "URL"
	// URLDescription is the description of URL
	URLDescription = "URL to access the component"
)
View Source
const (

	// DefaultDebugPort is the default port used for debugging on remote pod
	DefaultDebugPort = 5858
)

Variables

This section is empty.

Functions

func AsLocallySupportedParameter

func AsLocallySupportedParameter(param string) (string, bool)

AsLocallySupportedParameter returns the parameter in lower case and a boolean indicating if it is a supported parameter

func FormatLocallySupportedParameters

func FormatLocallySupportedParameters() (result string)

FormatLocallySupportedParameters outputs supported parameters and their description

func GetLocallySupportedParameters

func GetLocallySupportedParameters() []string

GetLocallySupportedParameters returns the name of the supported global parameters

Types

type ComponentSettings

type ComponentSettings struct {
	// The builder image to use
	Type *string `yaml:"Type,omitempty"`

	// SourceLocation is path to binary in current/context dir, it can be the
	// git url in case of source type being git
	SourceLocation *string `yaml:"SourceLocation,omitempty"`

	// Ref is component source git ref but can be levaraged for more in future
	Ref *string `yaml:"Ref,omitempty"`

	// Type is type of component source: git/local/binary
	SourceType *SrcType `yaml:"SourceType,omitempty"`

	// Ports is a slice of ports to be exposed when a component is created
	// the format of the port is "PORT/PROTOCOL" e.g. "8080/TCP"
	Ports *[]string `yaml:"Ports,omitempty"`

	Application *string `yaml:"Application,omitempty"`

	Project *string `yaml:"Project,omitempty"`

	Name *string `yaml:"Name,omitempty"`

	MinMemory *string `yaml:"MinMemory,omitempty"`

	MaxMemory *string `yaml:"MaxMemory,omitempty"`

	// DebugPort controls the port used by the pod to run the debugging agent on
	DebugPort *int `yaml:"DebugPort,omitempty"`

	Storage *[]ComponentStorageSettings `yaml:"Storage,omitempty"`

	// Ignore if set to true then odoignore file should be considered
	Ignore *bool `yaml:"Ignore,omitempty"`

	MinCPU *string `yaml:"MinCPU,omitempty"`

	MaxCPU *string `yaml:"MaxCPU,omitempty"`

	Envs EnvVarList `yaml:"Envs,omitempty"`

	URL *[]ConfigURL `yaml:"Url,omitempty"`
}

ComponentSettings holds all component related information

type ComponentStorageSettings

type ComponentStorageSettings struct {
	Name string `yaml:"Name,omitempty"`
	Size string `yaml:"Size,omitempty"`
	Path string `yaml:"Path,omitempty"`
}

type ConfigURL

type ConfigURL struct {
	// Name of the URL
	Name string `yaml:"Name,omitempty"`
	// Port number for the url of the component, required in case of components which expose more than one service port
	Port int `yaml:"Port,omitempty"`
	// Indicates if the URL should be a secure https one
	Secure bool `yaml:"Secure,omitempty"`
}

ConfigURL holds URL related information

type EnvVar

type EnvVar struct {
	Name  string `yaml:"Name"`
	Value string `yaml:"Value"`
}

EnvVar represents an enviroment variable

func NewEnvVarFromString

func NewEnvVarFromString(envStr string) (EnvVar, error)

NewEnvVarFromString takes a string of format "name=value" and returns an Env variable struct

type EnvVarList

type EnvVarList []EnvVar

EnvVarList represents a list of environment variables

func NewEnvVarListFromDevfileEnv

func NewEnvVarListFromDevfileEnv(envList []common.Env) EnvVarList

NewEnvVarListFromDevfileEnv creates an EnvVarList from the list of envs present in a devfile.

func NewEnvVarListFromSlice

func NewEnvVarListFromSlice(envList []string) (EnvVarList, error)

NewEnvVarListFromSlice takes multiple env variables with format "name=value" and returns an EnvVarList

func RemoveEnvVarsFromList

func RemoveEnvVarsFromList(envVarList EnvVarList, keys []string) (EnvVarList, error)

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

func (EnvVarList) Merge

func (evl EnvVarList) Merge(other EnvVarList) EnvVarList

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

func (EnvVarList) ToDevfileEnv

func (evl EnvVarList) ToDevfileEnv() []common.Env

ToDevfileEnv converts the EnvVarList to the list of Envs supported by devfile

func (EnvVarList) ToStringSlice

func (evl EnvVarList) ToStringSlice() []string

ToStringSlice converts the EnvVarList into a slice of env var of kind "key=value"

type LocalConfig

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

LocalConfig holds all the config relavent to a specific Component.

func NewLocalConfig

func NewLocalConfig() LocalConfig

NewLocalConfig creates an empty LocalConfig struct with typeMeta populated

func (*LocalConfig) GetApplication

func (lc *LocalConfig) GetApplication() string

GetApplication returns the app, returns default if nil

func (*LocalConfig) GetDebugPort

func (lc *LocalConfig) GetDebugPort() int

GetDebugPort returns the DebugPort, returns default if nil

func (*LocalConfig) GetEnvs

func (lc *LocalConfig) GetEnvs() EnvVarList

GetEnvs returns the Envs, returns empty if nil

func (*LocalConfig) GetIgnore

func (lc *LocalConfig) GetIgnore() bool

GetIgnore returns the Ignore, returns default if nil

func (*LocalConfig) GetMaxCPU

func (lc *LocalConfig) GetMaxCPU() string

GetMaxCPU returns the MaxCPU, returns default if nil

func (*LocalConfig) GetMaxMemory

func (lc *LocalConfig) GetMaxMemory() string

GetMaxMemory returns the MaxMemory, returns default if nil

func (*LocalConfig) GetMinCPU

func (lc *LocalConfig) GetMinCPU() string

GetMinCPU returns the MinCPU, returns default if nil

func (*LocalConfig) GetMinMemory

func (lc *LocalConfig) GetMinMemory() string

GetMinMemory returns the MinMemory, returns default if nil

func (*LocalConfig) GetName

func (lc *LocalConfig) GetName() string

GetName returns the Name, returns default if nil

func (*LocalConfig) GetPorts

func (lc *LocalConfig) GetPorts() []string

GetPorts returns the ports, returns default if nil

func (*LocalConfig) GetProject

func (lc *LocalConfig) GetProject() string

GetProject returns the project, returns default if nil

func (*LocalConfig) GetRef

func (lc *LocalConfig) GetRef() string

GetRef returns the ref, returns default if nil

func (*LocalConfig) GetSourceLocation

func (lc *LocalConfig) GetSourceLocation() string

GetSourceLocation returns the sourcelocation, returns default if nil

func (*LocalConfig) GetSourceType

func (lc *LocalConfig) GetSourceType() SrcType

GetSourceType returns the source type, returns default if nil

func (*LocalConfig) GetStorage

func (lc *LocalConfig) GetStorage() []ComponentStorageSettings

GetStorage returns the Storage, returns empty if nil

func (*LocalConfig) GetType

func (lc *LocalConfig) GetType() string

GetType returns type of component (builder image name) in the config

func (*LocalConfig) GetURL

func (lc *LocalConfig) GetURL() []ConfigURL

GetURL returns the ConfigURL, returns default if nil

type LocalConfigInfo

type LocalConfigInfo struct {
	Filename string `yaml:"FileName,omitempty"`

	LocalConfig `yaml:",omitempty"`
	// contains filtered or unexported fields
}

LocalConfigInfo wraps the local config and provides helpers to serialize it.

func GetOneExistingConfigInfo

func GetOneExistingConfigInfo(componentName, applicationName, projectName string) LocalConfigInfo

func GetOneExistingConfigInfoStorage

func GetOneExistingConfigInfoStorage(componentName, applicationName, projectName, storeName, storeSize, storePath string) LocalConfigInfo

func GetOneGitExistingConfigInfo

func GetOneGitExistingConfigInfo(componentName, applicationName, projectName string) LocalConfigInfo

func GetOneNonExistingConfigInfo

func GetOneNonExistingConfigInfo() LocalConfigInfo

func New

func New() (*LocalConfigInfo, error)

New returns the localConfigInfo

func NewLocalConfigInfo

func NewLocalConfigInfo(cfgDir string) (*LocalConfigInfo, error)

NewLocalConfigInfo gets the LocalConfigInfo from local config file and creates the local config file in case it's not present then it

func (*LocalConfigInfo) ConfigFileExists

func (lci *LocalConfigInfo) ConfigFileExists() bool

ConfigFileExists if a config file exists or not

func (*LocalConfigInfo) DeleteConfigDirIfEmpty

func (lci *LocalConfigInfo) DeleteConfigDirIfEmpty() error

DeleteConfigDirIfEmpty Deletes the config directory if its empty

func (*LocalConfigInfo) DeleteConfigFile

func (lci *LocalConfigInfo) DeleteConfigFile() error

DeleteConfigFile deletes the odo-config.yaml file if it exists

func (*LocalConfigInfo) DeleteConfiguration

func (lci *LocalConfigInfo) DeleteConfiguration(parameter string) error

DeleteConfiguration is used to delete config from local odo config

func (*LocalConfigInfo) DeleteFromConfigurationList

func (lci *LocalConfigInfo) DeleteFromConfigurationList(parameter string, value string) error

DeleteFromConfigurationList is used to delete a value from a list from the local odo config parameter is the name of the config parameter value is the value to be deleted

func (*LocalConfigInfo) DeleteURL

func (lci *LocalConfigInfo) DeleteURL(parameter string) error

DeleteURL is used to delete config from local odo config

func (*LocalConfigInfo) GetComponentSettings

func (lci *LocalConfigInfo) GetComponentSettings() ComponentSettings

GetComponentSettings returns the componentSettings from local config

func (*LocalConfigInfo) GetEnvVars

func (lci *LocalConfigInfo) GetEnvVars() EnvVarList

GetEnvVars gets the env variables from the component settings

func (*LocalConfigInfo) GetMountPath

func (lci *LocalConfigInfo) GetMountPath(storageName string) string

func (*LocalConfigInfo) GetOSSourcePath

func (lci *LocalConfigInfo) GetOSSourcePath() (path string, err error)

GetOSSourcePath corrects the current sourcePath depending on local or binary configuration, if Git has been passed, we simply return the source location from LocalConfig this will get the correct source path whether on Windows, macOS or Linux.

This function also takes in the current working directory + context directory in order to correctly retrieve WHERE the source is located..

func (*LocalConfigInfo) IsSet

func (lci *LocalConfigInfo) IsSet(parameter string) bool

IsSet uses reflection to get the parameter from the localconfig struct, currently it only searches the componentSettings

func (*LocalConfigInfo) SetComponentSettings

func (lci *LocalConfigInfo) SetComponentSettings(cs ComponentSettings) error

SetComponentSettings sets the componentSettings from to the local config and writes to the file

func (*LocalConfigInfo) SetConfiguration

func (lci *LocalConfigInfo) SetConfiguration(parameter string, value interface{}) (err error)

SetConfiguration sets the common config settings like component type, min memory max memory etc. TODO: Use reflect to set parameters

func (*LocalConfigInfo) SetEnvVars

func (lci *LocalConfigInfo) SetEnvVars(envVars EnvVarList) error

SetEnvVars sets the env variables on the component settings

func (*LocalConfigInfo) StorageCreate

func (lci *LocalConfigInfo) StorageCreate(name, size, path string) (ComponentStorageSettings, error)

StorageCreate sets the storage related information in the local configuration

func (*LocalConfigInfo) StorageDelete

func (lci *LocalConfigInfo) StorageDelete(name string) error

func (*LocalConfigInfo) StorageExists

func (lci *LocalConfigInfo) StorageExists(storageName string) bool

func (*LocalConfigInfo) StorageList

func (lci *LocalConfigInfo) StorageList() ([]ComponentStorageSettings, error)

func (*LocalConfigInfo) ValidateStorage

func (lci *LocalConfigInfo) ValidateStorage(storageName, storagePath string) error

type SrcType

type SrcType string

SrcType is an enum to indicate the type of source of component -- local source/binary or git for the generation of app/component names

const (
	// GIT as source of component
	GIT SrcType = "git"
	// LOCAL Local source path as source of component
	LOCAL SrcType = "local"
	// BINARY Local Binary as source of component
	BINARY SrcType = "binary"
	// NONE indicates there's no information about the type of source of the component
	NONE SrcType = ""
)

func GetSrcType

func GetSrcType(ctStr string) (SrcType, error)

GetSrcType returns enum equivalent of passed component source type or error if unsupported type passed

Jump to

Keyboard shortcuts

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