Documentation
¶
Index ¶
- Constants
- func DefaultQuit(w http.ResponseWriter, ExitMessage string)
- func InArray(v interface{}, in interface{}) (ok bool, i int)
- func PingHandler(w http.ResponseWriter, _ *http.Request)
- type DockerContainer
- func (d *DockerContainer) AddEnv(key, value string)
- func (d *DockerContainer) AddHiddenEnv(key, value string)
- func (d *DockerContainer) AddOpts(opts ...string)
- func (d *DockerContainer) AddVolume(volume string)
- func (d *DockerContainer) ContainerHasChanged() (changed bool)
- func (d *DockerContainer) Init(name string)
- func (d *DockerContainer) Inspect(name string, data string) (ret string, _ error)
- func (d *DockerContainer) Logs(dopts []string, out func(string)) error
- func (d *DockerContainer) Name() string
- func (d *DockerContainer) Pull(dopts []string) error
- func (d *DockerContainer) Remove() error
- func (d *DockerContainer) Run(cmd string, args []string) error
- func (d *DockerContainer) SetImageName(image string)
- func (d *DockerContainer) Start(dopts []string) error
- func (d *DockerContainer) Status() (string, error)
- func (d *DockerContainer) Stop(dopts []string) error
- type DockerService
- type DockerStruct
- type Driver
- func (p *Driver) CheckServiceUp() bool
- func (p *Driver) DefineDockerDood() (err error)
- func (p *Driver) DefineDockerForjjMounts() error
- func (p *Driver) DefineDockerProxyParameters()
- func (p *Driver) GetDockerDoodParameters() (mount, become []string, err error)deprecated
- func (p *Driver) PluginBase(mount string)
- func (p *Driver) PluginDefLoad(yaml_data []byte) error
- func (p *Driver) PluginDockerBin(thePath string) error
- func (p *Driver) PluginInit(instance string) error
- func (p *Driver) PluginLoadFrom(name string, runtime *YamlPluginRuntime) error
- func (p *Driver) PluginRunAction(action string, d *PluginReqData) (*PluginResult, error)
- func (p *Driver) PluginSetDeployment(path string)
- func (p *Driver) PluginSetDeploymentMount(path string)
- func (p *Driver) PluginSetDeploymentName(name string)
- func (p *Driver) PluginSetSource(path string)
- func (p *Driver) PluginSetSourceMount(path string)
- func (p *Driver) PluginSetVersion(version string)
- func (p *Driver) PluginSetWorkspace(path string)
- func (p *Driver) PluginSetWorkspaceMount(path string)
- func (p *Driver) PluginSocketPath(path string)
- func (p *Driver) PluginStartService() (err error)
- func (p *Driver) PluginStopService()
- func (p *Driver) RunningFromDebugger()
- func (p *Driver) ServiceAddEnv(name, value string, hidden bool)
- func (p *Driver) SetDefaultMounts()
- type ForjjPluginApp
- type InstanceExtentKeys
- type InstanceKeys
- type ObjectInstances
- type PluginData
- type PluginOption
- type PluginRepo
- type PluginRepoRemoteUrl
- type PluginReqData
- type PluginResult
- type PluginService
- type PluginTask
- type Plugins
- type ValueStruct
- func (v *ValueStruct) Equal(value *ValueStruct) bool
- func (v *ValueStruct) Evaluate(data interface{}) error
- func (v *ValueStruct) Get() (value interface{})
- func (v *ValueStruct) GetString() string
- func (v *ValueStruct) GetStringSlice() []string
- func (v ValueStruct) MarshalJSON() ([]byte, error)
- func (v ValueStruct) MarshalYAML() (interface{}, error)
- func (v *ValueStruct) Set(value interface{}) (ret *ValueStruct)
- func (v *ValueStruct) SetIfFound(value interface{}, found bool) (ret *ValueStruct, ret_bool bool)
- func (v *ValueStruct) SetString(value string)
- func (v *ValueStruct) Type() string
- func (v *ValueStruct) UnmarshalYAML(unmarchal func(interface{}) error) error
- type YamlFlag
- type YamlFlagOptions
- type YamlObject
- type YamlObjectGroup
- type YamlObjectList
- type YamlPlugin
- type YamlPluginComm
- type YamlPluginRuntime
- type YamlPluginTasksObjects
Constants ¶
const ( FilesSource = "source" FilesDeploy = "deploy" )
const Latest = "latest"
const ObjectApp = "app"
const SocketPathLimit = 108 // See syscall.RawSockaddrUnix.Path in ztypes_linux_amd64.go - Linux limit
Variables ¶
This section is empty.
Functions ¶
func DefaultQuit ¶
func DefaultQuit(w http.ResponseWriter, ExitMessage string)
func PingHandler ¶
func PingHandler(w http.ResponseWriter, _ *http.Request)
Predefined Ping handler.
Types ¶
type DockerContainer ¶
type DockerContainer struct {
// contains filtered or unexported fields
}
DockerContainer is the named container information
func (*DockerContainer) AddEnv ¶
func (d *DockerContainer) AddEnv(key, value string)
AddEnv add an environment variable to the container via -e key=value
func (*DockerContainer) AddHiddenEnv ¶
func (d *DockerContainer) AddHiddenEnv(key, value string)
AddHiddenEnv add an environment variable to the container via -e key and the environment variable to the docker run command.
func (*DockerContainer) AddOpts ¶
func (d *DockerContainer) AddOpts(opts ...string)
AddOpts add some docker options (passed before the image name)
func (*DockerContainer) AddVolume ¶
func (d *DockerContainer) AddVolume(volume string)
AddVolume add a volume for a docker container
func (*DockerContainer) ContainerHasChanged ¶
func (d *DockerContainer) ContainerHasChanged() (changed bool)
ContainerHasChanged simply return true is the container
func (*DockerContainer) Init ¶
func (d *DockerContainer) Init(name string)
Init initialize the DockerContainer structure.
func (*DockerContainer) Inspect ¶
func (d *DockerContainer) Inspect(name string, data string) (ret string, _ error)
Inspect the named container.
func (*DockerContainer) Logs ¶
func (d *DockerContainer) Logs(dopts []string, out func(string)) error
Logs printout the log to the out function.
func (*DockerContainer) Name ¶
func (d *DockerContainer) Name() string
Name return the container name to use.
func (*DockerContainer) Pull ¶
func (d *DockerContainer) Pull(dopts []string) error
Pull the container image
func (*DockerContainer) Run ¶
func (d *DockerContainer) Run(cmd string, args []string) error
Run the container
func (*DockerContainer) SetImageName ¶
func (d *DockerContainer) SetImageName(image string)
SetImageName define the image name to use for the container.
func (*DockerContainer) Start ¶
func (d *DockerContainer) Start(dopts []string) error
Start the named container
func (*DockerContainer) Status ¶
func (d *DockerContainer) Status() (string, error)
Status get container status field
func (*DockerContainer) Stop ¶
func (d *DockerContainer) Stop(dopts []string) error
Stop stop the named container
type DockerStruct ¶
type Driver ¶
type Driver struct { // Driver define an instance of a driver Result *PluginResult // Json data structured returned. Yaml *YamlPlugin // Yaml data definition // in docker run syntax, -v Source_path:SourceMount Source_path string // Plugin source path from Forjj point of view SourceMount string // Where the driver will have his source code. // in docker run syntax, -v Workspace_path:WorkspaceMount Workspace_path string // Plugin Workspace path from Forjj point of view WorkspaceMount string // where the driver has his workspace. // in docker run syntax, -v DeployPath:DestMount DeployPath string // Plugin Deployment path DestMount string // Where the driver will have his generated code. DeployName string // Plugin Deployment name in path Version string // Plugin version to load // contains filtered or unexported fields }
func NewDriver ¶
func NewDriver(plugin *YamlPlugin) (p *Driver)
func (*Driver) CheckServiceUp ¶
func (*Driver) DefineDockerDood ¶
DefineDockerDood detect and/or define DooD required parameters if the plugin requires it.
It uses goforjj/runcontext module to define and share for new DooD containers the DooD setup.
It manages 2 different context:
- DOCKER_DOOD. It regroups options to enable DooD with docker socket, docker static binary and docker group ID Those data are set in the new container that forjj will create thanks to addVolume/Env/Opts functions given and "DOCKER_DOOD" will be the last docker env variable which contains all docker run options for the same, shared in the new container to be started by forjj. It requires the container to start as root , in order to update/create the docker group in the container if missing if the container have to be used as a user (non root) it must be created/assigned in the docker image.
- DOCKER_DOOD_BECOME. It regroups options to enable impersonation in the container. The container started as root will ask the container to update few things and become the wanted user with a specific UID/GID given. The container have to update the wanted user UID and GID
func (*Driver) DefineDockerForjjMounts ¶
DefineDockerForjjMounts create a share of forjj driver mounts
func (*Driver) DefineDockerProxyParameters ¶
func (p *Driver) DefineDockerProxyParameters()
DefineDockerProxyParameters return the list of Proxy parameters Shared as DOCKER_DOOD_PROXY
func (*Driver) GetDockerDoodParameters
deprecated
func (*Driver) PluginBase ¶
PluginBase define the source Base mount to use for DooD mount
func (*Driver) PluginDefLoad ¶
PluginDefLoad Load yaml raw data in YamlPlugin data structure
func (*Driver) PluginDockerBin ¶
func (*Driver) PluginInit ¶
PluginInit Initialize Plugin with Definition data.
func (*Driver) PluginLoadFrom ¶
func (p *Driver) PluginLoadFrom(name string, runtime *YamlPluginRuntime) error
PluginLoadFrom do a load of the plugin Def Runtime section This information is saved by forjj to avoid reloding the plugin.yaml A plugin already loaded is not refreshed. NOTE: Workspace_path, Source_path and SourceMount must be set in PluginDef to make it work. TODO: Add a Plugin refresh? Not sure if forjj could do it or not differently...
func (*Driver) PluginRunAction ¶
func (p *Driver) PluginRunAction(action string, d *PluginReqData) (*PluginResult, error)
PluginRunAction Function which will execute the action requested. If the plugin is a REST API, communicate with real basic REST API protocol Basic RESTFul means : GET/POST, simple unique route, no version, payload with everything. If needed in a next iteration, we can move the API to match fully the RESTFul API with forjj objects/actions. else start a shell or a container to get the json data.
func (*Driver) PluginSetDeployment ¶
PluginSetDeployment set Deploy path from forjj perspective
func (*Driver) PluginSetDeploymentMount ¶
PluginSetDeploymentMount set Deploy path from forjj perspective
func (*Driver) PluginSetDeploymentName ¶
func (*Driver) PluginSetSource ¶
PluginSetSource Set plugin source path from forjj perspective. Created later by docker_start_service
func (*Driver) PluginSetSourceMount ¶
PluginSetSourceMount Set plugin source path mount where source will be mounted in the plugin container.
func (*Driver) PluginSetVersion ¶
func (*Driver) PluginSetWorkspace ¶
PluginSetWorkspace set workspace path from forjj perspective
func (*Driver) PluginSetWorkspaceMount ¶
PluginSetWorkspaceMount set workspace path from forjj perspective
func (*Driver) PluginSocketPath ¶
PluginSocketPath Declare the socket path. It will be created later by function socket_prepare
func (*Driver) PluginStartService ¶
PluginStartService This function start the service as daemon and register it If the service is already started, just use it.
func (*Driver) PluginStopService ¶
func (p *Driver) PluginStopService()
PluginStopService To stop the plugin service if the service was started before by goforjj
func (*Driver) RunningFromDebugger ¶
func (p *Driver) RunningFromDebugger()
func (*Driver) ServiceAddEnv ¶
ServiceAddEnv add environment variable to the service runner
func (*Driver) SetDefaultMounts ¶
func (p *Driver) SetDefaultMounts()
SetDefaultMounts defines container (src/deploy/workspace) mounts to default path
type ForjjPluginApp ¶
type ForjjPluginApp struct { App *kingpin.Application // The kingpin Application structure for CLI flags management. IsInfra *bool // True when creating infra repositories Tasks map[string]PluginTask Flags map[string]*string // Values for global flags }
type InstanceExtentKeys ¶
type InstanceExtentKeys map[string]*ValueStruct
InstanceExtentKeys is the collection of key/values which is stored as "extent" in InstanceKeys.
type InstanceKeys ¶
type InstanceKeys map[string]interface{}
InstanceKeys is a collection of key/values or under key "extent" a collection of key/values (intanceExtentKeys)
type ObjectInstances ¶
type ObjectInstances map[string]InstanceKeys
ObjectInstances is a collection of instanceKeys
type PluginData ¶
type PluginData struct { Repos map[string]PluginRepo `json:",omitempty"` // List of repository data Services PluginService `json:",omitempty"` // web service url. ex: https://github.hpe.com Status string // Status message CommitMessage string `json:",omitempty"` // Action commit message for Create/Update ErrorMessage string // Found only if error detected Files map[string][]string `json:",omitempty"` // List of files managed by the plugin Options map[string]PluginOption `json:",omitempty"` // List of options needed at maintain use case, returned from create/update. Usually used to provide credentials. }
REST API json data
func (*PluginData) AddFile ¶
func (d *PluginData) AddFile(where, file string)
AddFile add a file the list of files Forjj will take care in GIT.
func (*PluginData) Errorf ¶
func (o *PluginData) Errorf(s string, args ...interface{}) string
Errorf to store error message made by all other functions and return it to the API caller
func (*PluginData) StatusAdd ¶
func (o *PluginData) StatusAdd(n string, args ...interface{}) string
StatusAdd Add status information to the API caller.
type PluginOption ¶
type PluginRepo ¶
type PluginRepo struct { Name string // name of the repository Exist bool // True if the repo exist. Remotes map[string]PluginRepoRemoteUrl // k: remote name, v: remote url BranchConnect map[string]string // k: local branch name, v: remote/branch Owner string `json:",omitempty"` // Owner name return by the plugin. }
func NewRepo ¶
func NewRepo() *PluginRepo
func (*PluginRepo) GetOrigin ¶
func (r *PluginRepo) GetOrigin(forGit bool) string
func (*PluginRepo) GetUpstream ¶
func (r *PluginRepo) GetUpstream(forGit bool) string
GetUpstream Currently get the 'upstream' if exist or 'origin' url
type PluginRepoRemoteUrl ¶
type PluginReqData ¶
type PluginReqData struct { // Collection of Forjj flags requested by the plugin or given by default by Forjj Forj map[string]string ForjExtent map[string]string `json:",omitempty"` // Extended Forjj flags // Define the list of Forjj objects data transmitted. object_type, instance, action. Objects map[string]ObjectInstances Creds map[string]string `json:",omitempty"` // Contains credentials requested by the plugin for a specific action. }
PluginReqData define the API data request to send to forjj plugins
func NewReqData ¶
func NewReqData() (r *PluginReqData)
NewReqData return an empty API request structure.
func (*PluginReqData) AddObjectActions ¶
func (r *PluginReqData) AddObjectActions(objectType, objectName string, keys InstanceKeys, extent InstanceExtentKeys, creds map[string]string)
AddObjectActions add in the request, the collection of keys/values or extent/keys/values for each objects/instances
func (*PluginReqData) SetForjFlag ¶
func (r *PluginReqData) SetForjFlag(key, value string, cred, extent bool)
SetForjFlag initialize forj part of the request with key/value or extent key/value.
type PluginResult ¶
type PluginResult struct { Data PluginData State_code int // 200 OK }
Shell json data
func (*PluginResult) JsonPrint ¶
func (p *PluginResult) JsonPrint() error
JsonPrint to print out json data
type PluginService ¶
type PluginTask ¶
type PluginTask struct { Cmd *kingpin.CmdClause Flags map[string]*string // Values for commands flags. }
Defines default internal structure to enhance in the plugin.
type Plugins ¶
type Plugins struct {
// contains filtered or unexported fields
}
Plugins define a structure to store all plugins loaded.
func (*Plugins) Load ¶
func (ps *Plugins) Load(instanceName, pluginName, pluginType string, loader map[string]func(*YamlPlugin) (yaml_data []byte, err error)) (driver *Driver, err error)
Load the instance plugin and return the driver object All plugin instances can share the same plugin. So that a plugin definition is loaded only once. But each driver are instance unique.
type ValueStruct ¶
type ValueStruct struct {
// contains filtered or unexported fields
}
ValueStruct Represents a flag value. Can be of type string or []string
func NewValueStruct ¶
func NewValueStruct(value interface{}) (ret *ValueStruct)
NewValueStruct Create a ValueStruct data from the input given. Support string and []string
func (*ValueStruct) Equal ¶
func (v *ValueStruct) Equal(value *ValueStruct) bool
Equal return true, if value compared are equal. The equality depends on internal type: - string : string equality - []string : same list of elements and each elements are at the same position
func (*ValueStruct) Evaluate ¶
func (v *ValueStruct) Evaluate(data interface{}) error
func (*ValueStruct) Get ¶
func (v *ValueStruct) Get() (value interface{})
func (*ValueStruct) GetString ¶
func (v *ValueStruct) GetString() string
func (*ValueStruct) GetStringSlice ¶
func (v *ValueStruct) GetStringSlice() []string
func (ValueStruct) MarshalJSON ¶
func (v ValueStruct) MarshalJSON() ([]byte, error)
func (ValueStruct) MarshalYAML ¶
func (v ValueStruct) MarshalYAML() (interface{}, error)
func (*ValueStruct) Set ¶
func (v *ValueStruct) Set(value interface{}) (ret *ValueStruct)
Set the Value given to ValueStruct. Support string and []string
func (*ValueStruct) SetIfFound ¶
func (v *ValueStruct) SetIfFound(value interface{}, found bool) (ret *ValueStruct, ret_bool bool)
func (*ValueStruct) SetString ¶
func (v *ValueStruct) SetString(value string)
func (*ValueStruct) Type ¶
func (v *ValueStruct) Type() string
func (*ValueStruct) UnmarshalYAML ¶
func (v *ValueStruct) UnmarshalYAML(unmarchal func(interface{}) error) error
type YamlFlag ¶
type YamlFlag struct { Options YamlFlagOptions `yaml:",inline"` Help string FormatRegexp string `yaml:"format-regexp"` Actions []string `yaml:"only-for-actions"` // Define how flags are going to be declared to forjj cli as flags CliExport bool `yaml:"cli-exported"` // true if the object flag must be exported to the forjj cli. Used by objects only. CliCmdActions []string `yaml:"cli-exported-to-actions"` // List of actions to export the flag to. Used for `application` object type only. Type string `yaml:"of-type"` FlagScope string `yaml:"flag-scope"` // 'object' by default. Flag is not prefixed by instance name. // 'instance' Flag is prefixed by instance name if certain condition. FieldScope string `yaml:"fields-scope"` // 'object' by default. Means field is added at Object level. // contains filtered or unexported fields }
data structure in /objects/<Object Name>/flags/<flag name>
flags: <flag name>: help: string - Help attached to the flag required: bool - true if this flag is required.
func (*YamlFlag) IsExtentFlag ¶
IsExtentFlag is True if the flag was defined as extent.
type YamlFlagOptions ¶
type YamlFlagOptions struct { Required bool Hidden bool // Used by the plugin. Default string // Used by the plugin. Secure bool // true if the data must be securely stored, ie not in the git repo. The flag must be defined in 'common' or 'maintain' flag group. Envar string // Environment variable name to use. }
type YamlObject ¶
type YamlObject struct { Actions []string `yaml:"default-actions"` // Collection of actions for the group given. Help string FlagsScope string `yaml:"flags-scope"` // 'object' by default. flag name is NOT prefixed // 'instance' flag name is prefixed by instance name. FieldsScope string `yaml:"fields-scope"` // 'global' by default. Means field is added at Object level. // 'instance' Means fields is added at object instance level. Identified_by_flag string // Multiple object configuration. each instance will have a key from a flag value Groups map[string]YamlObjectGroup Flags map[string]YamlFlag Lists map[string]YamlObjectList }
YamlObject data structure in /objects/<Object Name>
flags: <flag name>: help: string - Help attached to the object actions: collection of forjj actions (add/update/rename/remove/list)
func (*YamlObject) FlagsRange ¶
func (o *YamlObject) FlagsRange(action string) (res map[string]YamlFlag)
func (*YamlObject) HasValidKey ¶
func (o *YamlObject) HasValidKey(key string) bool
type YamlObjectGroup ¶
type YamlObjectGroup struct { Actions []string `yaml:"default-actions"` // Collection of actions for the group given. Flags map[string]YamlFlag }
data structure in /objects/<Object Name>/groups/<group_name>
type YamlObjectList ¶
type YamlObjectList struct { Sep string `yaml:"separator"` Help string ExtRegexp string `yaml:"defined-by"` }
data structure in /objects/<Object Name>/lists/<list_name>
type YamlPlugin ¶
type YamlPlugin struct { Name string `yaml:"plugin"` Version string `yaml:",omitempty"` Description string `yaml:",omitempty"` CreatedFile string `yaml:"created_flag_file"` ExtendRelPath string `yaml:"extend_relative_path,omitempty"` Runtime YamlPluginRuntime YamlPluginTasksObjects `yaml:",inline"` // contains filtered or unexported fields }
Data structure in / --- plugin: string - Driver name (Name) version: string - driver version description: string - driver description runtime: struct - See YamlPluginRuntime actions: hash of struct - See YamlPluginDef - must be common/create/update/maintain as hash keys only.
func NewYamlPlugin ¶
func NewYamlPlugin() (ret *YamlPlugin)
func (*YamlPlugin) MergeWith ¶
func (p *YamlPlugin) MergeWith(instance string, extended *YamlPluginTasksObjects) (merged *YamlPlugin)
MergeWith creates a new Yamlplugin object built from a merged between this plugin and the extension. except instance Details, source data won't be modified as there is no object pointer
type YamlPluginComm ¶
type YamlPluginComm struct { Socket string `yaml:",omitempty"` Port uint `yaml:",omitempty"` // Not yet implemented Command string `yaml:",omitempty"` // Not yet implemented Parameters []string `yaml:",omitempty,flow"` // Not yet implemented }
data structure in /runtime/service 'service' defines how forjj communicate with the driver If service is not defined, socket will be used. runtime:
service: socket: string - default set to the driver name with '.sock' as extension. The socket path is set by forjj. Socket file name to use between forjj and the driver port: uint - Port used to communicate between forjj and the driver parameters: Array of strings - List of parameters to provide to the shell/binary Support {{Socket}}
type YamlPluginRuntime ¶
type YamlPluginRuntime struct { Service_type string Docker DockerStruct `yaml:",omitempty"` Service YamlPluginComm `yaml:",omitempty"` }
data structure in /runtime runtime:
service_type: string - Support "REST API" and "shell" REST API means the driver comply to REST API served as web service shell means, the driver is called as shell with parameters and return a json data. image_docker: string - Docker image containing the driver to start
type YamlPluginTasksObjects ¶
type YamlPluginTasksObjects struct { Tasks map[string]map[string]YamlFlag `yaml:"task_flags"` Objects map[string]YamlObject }
Source Files
¶
- command_run.go
- docker-struct.go
- docker_container.go
- docker_services.go
- plugin-actions.go
- plugin-app-struct.go
- plugin-cmd.go
- plugin-data.go
- plugin-default-handlers.go
- plugin-docker-helper.go
- plugin-json-struct.go
- plugin-repos.go
- plugin-req-data.go
- plugin-yaml-struct.go
- plugin.go
- plugins.go
- value_struct.go
- yaml-flag.go
- yaml-object.go
- yaml-plugin.go