forjfile

package
v0.0.0-...-e867e26 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DevDeployType = "DEV"

	ProDeployType = "PRO"
)
View Source
const (
	FieldRepoName          = "name"
	FieldRepoUpstream      = "upstream"
	FieldRepoApps          = "apps"
	FieldRepoGitRemote     = "git-remote"
	FieldRepoRemote        = "remote"
	FieldRepoRemoteURL     = "remote-url"
	FieldRepoTitle         = "title"
	FieldRepoFlow          = "flow"
	FieldRepoTemplate      = "repo-template"
	FieldRepoDeployName    = "deployment-name"
	FieldRepoDeployType    = "deployment-type"
	FieldRepoRole          = "role"
	FieldCurrentDeployRepo = "current-deployment-repo"
)
View Source
const (
	// DockerBinPathField identify full path to the docker binary.
	DockerBinPathField = "docker-bin-path"

	// ContribRepoPathField identify collection of paths of contribution repositories
	ContribRepoPathField = "contrib-repo-path"

	// FlowRepoPathField identify collection of path to the flow repositories.
	FlowRepoPathField = "flow-repo-path"

	// RepoTemplateRepoPathField identify collection of path to the repository template repositories.
	RepoTemplateRepoPathField = "repotemplate-repo-path"

	// PluginsSocketDirsPathField identify full path to the plugins sockets directory
	PluginsSocketDirsPathField = "plugins-socket-dirs-path"

	// PluginsSocketBaseField identify the base path of PluginsSocketDirsPathField
	PluginsSocketBaseField = "plugins-socket-base-path"

	// PluginsSocketDirField identify the dir name of PluginsSocketDirsPathField
	PluginsSocketDirField = "plugins-socket-dir-name"

	// OrganizationField identify the organization name
	OrganizationField = "organization"

	// InfraInstanceNameField identify the instance name
	InfraInstanceNameField = "infra-instance-name"

	//InfraDriverNameField identify the infra driver name
	InfraDriverNameField = "infra-driver-name"
)

Variables

View Source
var ForjValueSelectDefault bool

TODO: Add a function/cap to forjj to generate Forjfile with Default values (ForjValueSelectDefault = true)

Functions

func SaveTmpl

func SaveTmpl(aPath string, f *Forge) error

SaveTmpl provide Forjfile model export from a Forge.

Types

type AppFlowYaml

type AppFlowYaml struct {
	Service string `yaml:"used-as,omitempty"`
	Options map[string]string
	// contains filtered or unexported fields
}

type AppModel

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

func (AppModel) Get

func (r AppModel) Get(field string) (_ string)

type AppStruct

type AppStruct struct {
	AppYamlStruct `yaml:",inline"`
	// contains filtered or unexported fields
}

func NewAppStruct

func NewAppStruct() (ret *AppStruct)

func (*AppStruct) Flags

func (a *AppStruct) Flags() (flags []string)

func (*AppStruct) Get

func (a *AppStruct) Get(flag string) (value *goforjj.ValueStruct, found bool, source string)

Get return the flag value. found is true if value exist in more or if the value is not empty

func (*AppStruct) MarshalYAML

func (a *AppStruct) MarshalYAML() (interface{}, error)

func (*AppStruct) Model

func (a *AppStruct) Model() AppModel

func (*AppStruct) Name

func (a *AppStruct) Name() string

func (*AppStruct) Set

func (a *AppStruct) Set(source, flag, value string) (updated bool)

func (*AppStruct) SetHandler

func (a *AppStruct) SetHandler(source string, from func(field string) (string, bool), set func(*ForjValue, string) bool, keys ...string) (updated bool)

func (*AppStruct) UnmarshalYAML

func (a *AppStruct) UnmarshalYAML(unmarchal func(interface{}) error) error

type AppYamlStruct

type AppYamlStruct struct {
	Type    string
	Driver  string
	Version string
	// TODO: Support for object dedicated to the application instance (not shared)
	// Objects map[string]map[string]string
	Flows map[string]AppFlowYaml `yaml:",omitempty"`

	More map[string]string `yaml:",inline"`
	// contains filtered or unexported fields
}

type AppsStruct

type AppsStruct map[string]*AppStruct

func (AppsStruct) Found

func (a AppsStruct) Found(appName string) (*AppStruct, error)

type DefaultRepoAppSettingsStruct

type DefaultRepoAppSettingsStruct map[string]string

DefaultRepoAppSettingsStruct contains a collection of default options/values to apply to Repoitories.

func (DefaultRepoAppSettingsStruct) Get

func (d DefaultRepoAppSettingsStruct) Get(key string) (value string, found bool)

Get return value from a key.

type DefaultSettingsStruct

type DefaultSettingsStruct struct {
	UpstreamInstance string            `yaml:"upstream-instance,omitempty"` // TODO: to remove - obsolete
	Flow             string            `yaml:",omitempty"`
	DevDeploy        string            `yaml:"dev-deploy,omitempty"`
	More             map[string]string `yaml:",inline"`
	// contains filtered or unexported fields
}

func (*DefaultSettingsStruct) Get

func (s *DefaultSettingsStruct) Get(key string) (value *goforjj.ValueStruct, found bool, source string)

Get return the value of the default setting.

func (*DefaultSettingsStruct) Set

func (s *DefaultSettingsStruct) Set(source, key, value string)

Set udpate the value of the default setting key.

type DeployForgeModel

type DeployForgeModel struct {
	// LocalSettings should not be used from a Forjfile except if this one is a template one.
	LocalSettings WorkspaceStruct
	ForjSettings  ForjSettingsStruct
	Infra         RepoModel
	Deploy        RepoModel
	Repos         map[string]RepoModel
	Apps          map[string]AppModel
	Users         UsersStruct
	Groups        GroupsStruct
	// Collection of Object/Name/Keys=values
	More map[string]map[string]ForjValues `yaml:",inline,omitempty"`
}

func NewDeployForgeModel

func NewDeployForgeModel(forge *DeployForgeYaml) (ret *DeployForgeModel)

NewDeployForgeModel return a DeployForgeYaml model object

type DeployForgeYaml

type DeployForgeYaml struct {
	LocalSettings WorkspaceStruct    `yaml:"local-settings,omitempty"` // ignored if Normal Forjfile. Otherwise, this is a template Forjfile.
	ForjSettings  ForjSettingsStruct `yaml:"forj-settings"`
	Infra         *RepoStruct
	Repos         ReposStruct `yaml:"repositories"`
	Apps          AppsStruct  `yaml:"applications"`
	Users         UsersStruct
	Groups        GroupsStruct
	// Collection of Object/Name/Keys=values
	More map[string]map[string]ForjValues `yaml:",inline,omitempty"`
	// contains filtered or unexported fields
}

DeployForgeYaml represents a dedicated deployed Forge.

func NewDeployForgeYaml

func NewDeployForgeYaml() (result *DeployForgeYaml)

NewDeployForgeYaml creates an empty pre-initialized object.

func (*DeployForgeYaml) Get

func (f *DeployForgeYaml) Get(object, instance, key string) (value *goforjj.ValueStruct, _ bool, source string)

Get return the value of the object instance key as ValueStruct.

func (*DeployForgeYaml) GetInstances

func (f *DeployForgeYaml) GetInstances(object string) (ret []string)

GetInstances return a list of instances from an object type.

func (*DeployForgeYaml) GetObjectInstance

func (f *DeployForgeYaml) GetObjectInstance(object, instance string) interface{}

func (*DeployForgeYaml) GetRepo

func (f *DeployForgeYaml) GetRepo(name string) (r *RepoStruct, found bool)

GetRepo return the object found

func (*DeployForgeYaml) GetString

func (f *DeployForgeYaml) GetString(object, instance, key string) (string, bool, string)

GetString return the value in String. It ignore the origin of the data (default or not)

func (*DeployForgeYaml) HasApps

func (f *DeployForgeYaml) HasApps(rules ...string) (found bool, err error)

HasApps return a bool if rules are all true on at least one application. a rule is a string formatted as '<key>:<value>' a rule is true on an application if it has the key value set to <value>

If the rule is not well formatted, an error is returned. If the repo has no application, HasApps return false. If no rules are provided and at least one application exist, HasApps return true.

TODO: Write Unit test of HasApps

func (*DeployForgeYaml) Init

func (f *DeployForgeYaml) Init(forge *ForgeYaml) bool

Init ensure all object are well initialized to avoid core dump

func (*DeployForgeYaml) Model

func (f *DeployForgeYaml) Model() ForgeModel

func (*DeployForgeYaml) NewRepoStruct

func (f *DeployForgeYaml) NewRepoStruct(name string) (repo *RepoStruct)

NewRepoStruct create a new Repo in the Forjfile.

func (*DeployForgeYaml) ObjectLen

func (f *DeployForgeYaml) ObjectLen(object string) int

ObjectLen returns the number of instances of object type.

func (*DeployForgeYaml) Remove

func (f *DeployForgeYaml) Remove(object, name, key string)

Remove a key value found in the object instance

func (*DeployForgeYaml) Set

func (f *DeployForgeYaml) Set(source, object, name, key, value string)

Set a value to the object instance key.

func (*DeployForgeYaml) SetDefault

func (f *DeployForgeYaml) SetDefault(source, object, name, key, value string)

SetDefault a value as default value in the object instance key.

func (*DeployForgeYaml) SetHandler

func (f *DeployForgeYaml) SetHandler(source, object, name string, from func(string) (string, bool), set func(*ForjValue, string) bool, keys ...string)

SetHandler define the core set function, and call `from` function to determine the source of the data. (set/default or not found)

type DeploymentCoreStruct

type DeploymentCoreStruct struct {
	Desc string `yaml:"description,omitempty"`

	Type string
	Pars map[string]string `yaml:"parameters,omitempty"`
	// contains filtered or unexported fields
}

DeploymentCoreStruct contains only deployment information. anything others kind of information

func (*DeploymentCoreStruct) AttachRepo

func (d *DeploymentCoreStruct) AttachRepo(repo *RepoStruct, organization string)

func (*DeploymentCoreStruct) AttachedRepo

func (d *DeploymentCoreStruct) AttachedRepo() (repo *RepoStruct)

AttachedRepo return the Deployment attached repository. If found, it returns the repo attached. nil otherwise.

func (*DeploymentCoreStruct) GetRepoPath

func (d *DeploymentCoreStruct) GetRepoPath() string

GetRepoPath returns the absolute path of the current deployment repository.

func (*DeploymentCoreStruct) GetReposPath

func (d *DeploymentCoreStruct) GetReposPath() string

GetReposPath returns the absolute path to all deployment repositories.

func (*DeploymentCoreStruct) GitCommit

func (d *DeploymentCoreStruct) GitCommit(message string) (_ error)

GitCommit do the commit in the Deployment repository.

func (*DeploymentCoreStruct) GitDefineRemote

func (d *DeploymentCoreStruct) GitDefineRemote(name, uri string) (err error)

GitDefineRemote helps to configure a deployment repository with a remote

func (*DeploymentCoreStruct) GitPush

func (d *DeploymentCoreStruct) GitPush(force bool) (_ error)

GitPush do a git push depending on the previous Git SyncFrom, a push can take place

func (*DeploymentCoreStruct) GitRemoteReady

func (d *DeploymentCoreStruct) GitRemoteReady() bool

InSync return true is deployment local repo is already connected and were synced at east once. If not sync, you may need to call d.SyncUp()

func (*DeploymentCoreStruct) GitResetBranchFromRemote

func (d *DeploymentCoreStruct) GitResetBranchFromRemote(branch, remote string)

GitResetBranchFromRemote clean current branch, check out to the requested branch and reset against remote branch. The reset is not made if the fetch return an error.

func (*DeploymentCoreStruct) GitSetRepo

func (d *DeploymentCoreStruct) GitSetRepo(aPath, origin string) (err error)

GitSetRepo define where the Deployment repo is located. It creates the repo even just empty and sync if possible and origin given. It switch to master branch

func (*DeploymentCoreStruct) GitSyncFrom

func (d *DeploymentCoreStruct) GitSyncFrom(remote, branch string) error

GitSyncFrom refresh the remote, and synchronize.

func (*DeploymentCoreStruct) GitSyncUp

func (d *DeploymentCoreStruct) GitSyncUp() error

GitSyncUp set and report sync status

func (*DeploymentCoreStruct) InSync

func (d *DeploymentCoreStruct) InSync() bool

InSync return true is deployment local repo is already connected and were synced at east once. If not sync, you may need to call d.SyncUp()

func (*DeploymentCoreStruct) Name

func (d *DeploymentCoreStruct) Name() string

func (*DeploymentCoreStruct) RunInContext

func (d *DeploymentCoreStruct) RunInContext(doRun func() error) (err error)

runInContext ensure GIT commands are executed in the right GIT repo context.

func (*DeploymentCoreStruct) SwitchTo

func (d *DeploymentCoreStruct) SwitchTo(branch string) error

SwitchTo move to the requested branch if files were updated, they are stashed and restored in the other branch !!! Conflict can happen !!!

type DeploymentStruct

type DeploymentStruct struct {
	DeploymentCoreStruct `yaml:",inline"`
	Details              *DeployForgeYaml `yaml:"define,omitempty"`
}

DeploymentStruct represent the data structure of all deployment.

func (DeploymentStruct) MarshalYAML

func (d DeploymentStruct) MarshalYAML() (interface{}, error)

MarshalYAML provides the encoding part for DeploymentStruct

In short we do not want to encode forjj deployment details) info except the core.

func (*DeploymentStruct) RunInContext

func (d *DeploymentStruct) RunInContext(doRun func() error) (err error)

RunInContext run GIT commands in the GIT repo context.

func (*DeploymentStruct) UpdateDeploymentCoreData

func (d *DeploymentStruct) UpdateDeploymentCoreData(data DeploymentCoreStruct)

UpdateDeploymentCoreData set all DeploymentCore data

type Deployments

type Deployments map[string]*DeploymentStruct

Deployments is a collection deployment

func (Deployments) GetADeployment

func (d Deployments) GetADeployment(deploy string) (v *DeploymentStruct, found bool)

GetADeployment return the Deployment Object wanted

func (Deployments) GetDeploymentPROType

func (d Deployments) GetDeploymentPROType() (v *DeploymentStruct, err error)

GetDeploymentPROType return the PRO deployment structure

func (Deployments) GetDeploymentType

func (d Deployments) GetDeploymentType(deployType string) (v Deployments, found bool)

GetDeploymentType return a list of deployment type.

func (Deployments) One

func (d Deployments) One() (v *DeploymentStruct)

type DeploymentsModel

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

DeploymentsModel is the ;odel structure of Deployments for text/template

func NewDeploymentsModel

func NewDeploymentsModel(list Deployments) (ret *DeploymentsModel)

NewDeploymentsModel return a model of Deployments

func (*DeploymentsModel) Get

func (dm *DeploymentsModel) Get(deployName string) (_ DeploymentCoreStruct)

GetFromName get attribute of a PRO deploy type

func (*DeploymentsModel) GetFromName

func (dm *DeploymentsModel) GetFromName(deployName, object, instance, key string) (ret string)

GetFromName get attribute of a PRO deploy type

func (*DeploymentsModel) GetFromPRO

func (dm *DeploymentsModel) GetFromPRO(object, instance, key string) string

GetFromPRO get attribute of a PRO deploy type

func (*DeploymentsModel) GetFromType

func (dm *DeploymentsModel) GetFromType(deployType, object, instance, key string) (ret map[string]string)

GetFromType get attributes of a collection of deploy of one type

type Forge

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

Forge is the Memory expand of a repository Forjfile.

func (*Forge) Apps

func (f *Forge) Apps() map[string]*AppStruct

func (*Forge) BuildForjfileInMem

func (f *Forge) BuildForjfileInMem() (err error)

BuildForjfileInMem return a merge of the Master forjfile with the current deployment.

func (*Forge) CheckInfraPath

func (f *Forge) CheckInfraPath(infraAbsPath string) error

CheckInfraPath will check if: - a Forjfile is found - is stored in a repository in root path.

func (*Forge) DeployForjfile

func (f *Forge) DeployForjfile() *DeployForgeYaml

DeployForjfile return the Forjfile master object

func (*Forge) Forjfile_name

func (f *Forge) Forjfile_name() string

func (*Forge) Forjfiles_name

func (f *Forge) Forjfiles_name() (ret []string)

func (*Forge) Get

func (f *Forge) Get(object, instance, key string) (value *goforjj.ValueStruct, _ bool, source string)

Get return the value and status of the object instance key

func (*Forge) GetADeployment

func (f *Forge) GetADeployment(deploy string) (v *DeploymentStruct, found bool)

GetADeployment return the Deployment Object wanted

func (*Forge) GetDeclaredFlows

func (f *Forge) GetDeclaredFlows() (result []string)

GetDeclaredFlows returns the list of flow to load from the Master Forjfile and the deploy Forjfile.

func (*Forge) GetDeployment

func (f *Forge) GetDeployment() string

GetDeployment returns the current deployment environment

func (*Forge) GetDeploymentPROType

func (f *Forge) GetDeploymentPROType() (v *DeploymentStruct, err error)

GetDeploymentPROType return the PRO deployment structure

func (*Forge) GetDeploymentType

func (f *Forge) GetDeploymentType(deployType string) (Deployments, bool)

GetDeploymentType return the first found

func (*Forge) GetDeployments

func (f *Forge) GetDeployments() (result Deployments)

GetDeployments returns all deployments.

func (*Forge) GetDeploymentsModel

func (f *Forge) GetDeploymentsModel() (ret *DeploymentsModel)

func (*Forge) GetForjfileFileLoaded

func (f *Forge) GetForjfileFileLoaded() string

func (*Forge) GetForjfileTemplateFileLoaded

func (f *Forge) GetForjfileTemplateFileLoaded() string

func (*Forge) GetInfraInstance

func (f *Forge) GetInfraInstance() (_ string)

func (*Forge) GetInfraName

func (f *Forge) GetInfraName() string

func (*Forge) GetInfraRepo

func (f *Forge) GetInfraRepo() *RepoStruct

GetInfraRepo return the infra repository object if defined.

func (*Forge) GetInstances

func (f *Forge) GetInstances(object string) (ret []string)

func (*Forge) GetObjectInstance

func (f *Forge) GetObjectInstance(object, instance string) interface{}

func (*Forge) GetRepo

func (f *Forge) GetRepo(name string) (r *RepoStruct, found bool)

GetRepo return the object found

func (*Forge) GetString

func (f *Forge) GetString(object, instance, key string) (string, bool, string)

func (*Forge) GetUpstreamApps

func (f *Forge) GetUpstreamApps() (v AppsStruct, found bool)

func (*Forge) InMemForjfile

func (f *Forge) InMemForjfile() *DeployForgeYaml

DeployForjfile return the Forjfile master object

func (*Forge) InfraPath

func (f *Forge) InfraPath() string

func (*Forge) Init

func (f *Forge) Init() bool

func (*Forge) IsDirty

func (f *Forge) IsDirty() bool

func (*Forge) IsLoaded

func (f *Forge) IsLoaded() (ret bool)

IsLoaded return true is a Forjfile has been loaded in Memory. Even empty.

func (*Forge) Load

func (f *Forge) Load(deployTo string) (loaded bool, err error)

Load : Load Forjfile stored in a Repository.

func (*Forge) MergeFromDeployment

func (f *Forge) MergeFromDeployment(deployTo string) (result *DeployForgeYaml, err error)

MergeFromDeployment provide a merge between Master and Deployment Forjfile.

func (*Forge) Model

func (f *Forge) Model(instance string) (fModel ForgeModel)

Model defines a simple struct to expose Current Application (ie driver instance)

func (*Forge) ObjectLen

func (f *Forge) ObjectLen(object string) int

func (*Forge) Remove

func (f *Forge) Remove(object, name, key string)

func (*Forge) Save

func (f *Forge) Save() error

func (*Forge) Saved

func (f *Forge) Saved()

func (*Forge) Set

func (f *Forge) Set(source, object, name, key, value string)

Set store a key/value to the merged or global Forjfile

func (*Forge) SetDefault

func (f *Forge) SetDefault(source, object, name, key, value string)

func (*Forge) SetDeployment

func (f *Forge) SetDeployment(deployTo string)

SetDeployment defines the current deployment to use.

func (*Forge) SetFromTemplate

func (f *Forge) SetFromTemplate(ft *ForjfileTmpl)

func (*Forge) SetInfraAsRepo

func (f *Forge) SetInfraAsRepo()

SetInfraAsRepo create the infra repo in the list of repositories (Repos)

Forjj deals with this list of repositories but saved specifically as Infra dedicated section in Forjfile.

func (*Forge) SetInfraPath

func (f *Forge) SetInfraPath(infraPath string, create_request bool) error

func (*Forge) SetRelPath

func (f *Forge) SetRelPath(relPath string)

func (*Forge) SetTo

func (f *Forge) SetTo(dest, source, object, name, key, value string)

SetTo permit to store the data in one of the Forjfile representative. Compare to Set, which can use the global or the merged data.

func (*Forge) Validate

func (f *Forge) Validate() error

Validate check if the information in the Forjfile are coherent or not and if code respect some basic rules. Validate do not check default values. So, validate can be executed before setting driver default values (forj.ScanAndSetObjectData)

type ForgeModel

type ForgeModel struct {
	Application AppModel
	// contains filtered or unexported fields
}

func (ForgeModel) Get

func (f ForgeModel) Get(object, instance, key string) (ret string)

Get return the value of the object instance key

func (ForgeModel) HasApps

func (f ForgeModel) HasApps(rules ...string) (_ bool)

HasApps returns true if forge has all listed apps.

type ForgeYaml

type ForgeYaml struct {
	Deployments Deployments
	ForjCore    DeployForgeYaml `yaml:",inline"`
	// contains filtered or unexported fields
}

ForgeYaml represents the master Forjfile or a piece of the Forjfile model.

func NewForgeYaml

func NewForgeYaml() (ret *ForgeYaml)

func (*ForgeYaml) Init

func (f *ForgeYaml) Init()

Init Initialize the forge. (Forjfile in repository infra)

type ForjSettingsStruct

type ForjSettingsStruct struct {
	Organization           string
	ForjSettingsStructTmpl `yaml:",inline"`
	// contains filtered or unexported fields
}

forj/settings: Collection of key/value pair

func (*ForjSettingsStruct) Flags

func (s *ForjSettingsStruct) Flags() (flags []string)

func (*ForjSettingsStruct) Get

func (s *ForjSettingsStruct) Get(instance, key string) (value *goforjj.ValueStruct, found bool, source string)

func (*ForjSettingsStruct) GetInstance

func (s *ForjSettingsStruct) GetInstance(instance string) interface{}

func (*ForjSettingsStruct) MarshalYAML

func (f *ForjSettingsStruct) MarshalYAML() (interface{}, error)

func (*ForjSettingsStruct) Set

func (s *ForjSettingsStruct) Set(source, instance, key, value string)

func (*ForjSettingsStruct) SetHandler

func (r *ForjSettingsStruct) SetHandler(source, instance string, from func(field string) (string, bool), keys ...string)

type ForjSettingsStructTmpl

type ForjSettingsStructTmpl struct {
	Default  DefaultSettingsStruct
	RepoApps DefaultRepoAppSettingsStruct `yaml:"default-repo-apps,omitempty"` // Default repo Application
	More     map[string]string            `yaml:",inline"`
}

type ForjValue

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

func (*ForjValue) Clean

func (v *ForjValue) Clean(_ string) (_ bool)

func (*ForjValue) Get

func (v *ForjValue) Get() string

func (*ForjValue) IsDefault

func (v *ForjValue) IsDefault() (_ bool)

func (ForjValue) MarshalYAML

func (v ForjValue) MarshalYAML() (interface{}, error)

func (*ForjValue) Set

func (v *ForjValue) Set(aValue string) (updated bool)

func (*ForjValue) SetDefault

func (v *ForjValue) SetDefault(aDefValue string) (updated bool)

func (*ForjValue) UnmarshalYAML

func (v *ForjValue) UnmarshalYAML(unmarshal func(interface{}) error) error

type ForjValues

type ForjValues map[string]ForjValue

func (ForjValues) Map

func (v ForjValues) Map() (values map[string]string)

Map returns a map[string]string of all values stored.

It returns values setup with Set and if not found, returns Default value.

func (ForjValues) MarshalYAML

func (v ForjValues) MarshalYAML() (interface{}, error)

type ForjfileTmpl

type ForjfileTmpl struct {
	Workspace WorkspaceStruct // See workspace.go
	// contains filtered or unexported fields
}

ForjfileTmpl is the Memory expansion of a Forjfile model (used to create a Forge)

func LoadTmpl

func LoadTmpl(aPath string) (f *ForjfileTmpl, loaded bool, err error)

LoadTmpl Search for Forjfile in `aPath` and load it. This file combines the Forjfile in the infra repository and the Workspace

type GroupStruct

type GroupStruct struct {
	Role    string            `yaml:",omitempty"`
	Members []string          `yaml:",omitempty"`
	More    map[string]string `yaml:",inline"`
	// contains filtered or unexported fields
}

func (*GroupStruct) AddMembers

func (g *GroupStruct) AddMembers(members ...string) (count int)

func (*GroupStruct) Flags

func (a *GroupStruct) Flags() (flags []string)

Flags returns the list of keys of this object.

func (*GroupStruct) Get

func (g *GroupStruct) Get(field string) (value *goforjj.ValueStruct, found bool, source string)

func (*GroupStruct) GetMembers

func (g *GroupStruct) GetMembers() []string

func (*GroupStruct) HasMember

func (g *GroupStruct) HasMember(member_exist string) bool

func (*GroupStruct) RemoveMembers

func (g *GroupStruct) RemoveMembers(members ...string) (count int)

func (*GroupStruct) Set

func (g *GroupStruct) Set(source, field, value string)

func (*GroupStruct) SetHandler

func (r *GroupStruct) SetHandler(source string, from func(field string) (string, bool), keys ...string)

type GroupsStruct

type GroupsStruct map[string]*GroupStruct

type RepoAppModel

type RepoAppModel struct {
	Default bool
	AppName string
}

type RepoFlow

type RepoFlow struct {
	Name string
	// contains filtered or unexported fields
}

type RepoModel

type RepoModel struct {
	Apps map[string]RepoAppModel
	// contains filtered or unexported fields
}

RepoModelStruct is the RepoStruct model

func (*RepoModel) From

func (r *RepoModel) From(repo *RepoStruct)

From build the repo model from a RepoStruct

func (RepoModel) Get

func (r RepoModel) Get(field string) (val string)

Get return value for any recognized fields of a repository object.

func (*RepoModel) HasApps

func (r *RepoModel) HasApps(rules ...string) (_ bool)

HasApps check is repo applications rules return true or not. a rule is true if the key:value is found in the application object attached.

See details in RepoStruct.HasApps()

func (RepoModel) IsCurrentDeploy

func (r RepoModel) IsCurrentDeploy() bool

IsCurrentDeploy returns true if the current repo is the current deployment repository.

func (RepoModel) IsDeployable

func (r RepoModel) IsDeployable() bool

IsDeployable return true if the repository identified is deployable in the current deployment context

func (RepoModel) Owner

func (r RepoModel) Owner() string

Owner return the repository owner field

func (RepoModel) RemoteType

func (r RepoModel) RemoteType() string

RemoteType return the remote type field

func (RepoModel) RemoteUrl

func (r RepoModel) RemoteUrl() string

RemoteUrl return the remote URL field

func (RepoModel) Role

func (r RepoModel) Role() (val string)

Role return the repository role

func (RepoModel) UpstreamAPIUrl

func (r RepoModel) UpstreamAPIUrl() string

UpstreamAPIUrl return the remote API url field

type RepoStruct

type RepoStruct struct {
	Deployment string `yaml:"deploy-repo-of,omitempty"`
	Upstream   string `yaml:"upstream-app,omitempty"` // Name of the application upstream hosting this repository.
	GitRemote  string `yaml:"git-remote,omitempty"`

	Title        string            `yaml:",omitempty"`
	RepoTemplate string            `yaml:"repo-template,omitempty"`
	Flow         RepoFlow          `yaml:",omitempty"`
	More         map[string]string `yaml:",inline"`

	Apps map[string]string `yaml:"in-relation-with,omitempty"` // key: <AppRelName>, value: <appName>
	// contains filtered or unexported fields
}

func (*RepoStruct) AttachedToDeployment

func (r *RepoStruct) AttachedToDeployment() string

func (*RepoStruct) Flags

func (r *RepoStruct) Flags() (flags []string)

Flags provide the list of existing keys in a repo object.

func (*RepoStruct) Get

func (r *RepoStruct) Get(field string) (value *goforjj.ValueStruct, found bool, source string)

Get return the value for a field.

func (*RepoStruct) GetApps

func (r *RepoStruct) GetApps(rules ...string) (apps map[string]*AppStruct, err error)

func (*RepoStruct) GetString

func (r *RepoStruct) GetString(field string) (_ string, _ string)

func (*RepoStruct) HasApps

func (r *RepoStruct) HasApps(rulesList ...string) (found bool, err error)

HasApps return a bool if rules are all true on at least one application.

Supported rules syntax are defined by rules module a rule is a string formatted with following syntax and meaning: - '<key>:<value>' or '<key>=<value>' - True if key has value equal to <value>. '<key>:<value>' is kept for compatibility but is obsolete. - '<key>!=<value>' - True if key has a value NOT equal to <value> - '<key>=/<regexp>/' - True if key has value respecting <regexp>. - '<key>!=/<regexp>/' - True if key has a value NOT respecting <regexp>

a rule is true on an application if it has the key value set to <value>

If the rule is not well formatted, an error is returned. If the repo has no application, HasApps return false. If no rules are provided and at least one application exist, HasApps return true. If all rules are true, HasApps return true

TODO: Write Unit test of HasApps

func (*RepoStruct) HasValues

func (r *RepoStruct) HasValues(rules ...string) (found bool, err error)

func (*RepoStruct) IsCurrentDeploy

func (r *RepoStruct) IsCurrentDeploy() (ret bool)

IsCurrentDeploy return True if this repo is the current deployment repository

func (*RepoStruct) IsInfra

func (r *RepoStruct) IsInfra() bool

func (*RepoStruct) Model

func (r *RepoStruct) Model() RepoModel

func (*RepoStruct) Name

func (r *RepoStruct) Name() string

Name return the internal reponame.

func (*RepoStruct) Owner

func (r *RepoStruct) Owner() string

func (*RepoStruct) Register

func (r *RepoStruct) Register()

Register will register the repository

func (*RepoStruct) RemoteGit

func (r *RepoStruct) RemoteGit() string

func (*RepoStruct) RemoteType

func (r *RepoStruct) RemoteType() string

func (*RepoStruct) RemoteUrl

func (r *RepoStruct) RemoteUrl() string

func (*RepoStruct) Role

func (r *RepoStruct) Role() string

func (*RepoStruct) Set

func (r *RepoStruct) Set(source, field, value string)

func (*RepoStruct) SetApp

func (r *RepoStruct) SetApp(appRelName, appName string) (updated *bool, _ error)

SetApp Define the Forjfile application name to link with the repo.

return: updated bool : true if the app has been updated. error : set if error has been found. updated is then nil.

func (*RepoStruct) SetCurrentDeploy

func (r *RepoStruct) SetCurrentDeploy()

SetCurrentDeploy set True if this repo IS the current deployment repository No check made on other repositories. At a time, only one repository should be considered as the current deployment repository

func (*RepoStruct) SetHandler

func (r *RepoStruct) SetHandler(source string, from func(field string) (string, bool), keys ...string)

SetHandler is the generic setter function.

func (*RepoStruct) SetInstanceOwner

func (r *RepoStruct) SetInstanceOwner(owner string)

func (*RepoStruct) SetInternalRelApp

func (r *RepoStruct) SetInternalRelApp(appRelName, appName string) (updated *bool, _ error)

SetInternalRelApp will set the appName connected to the repo But if the Forjfile has a setup, this one will forcefully used. return: updated bool : true if the app has been updated. error : set if error has been found. updated is then nil.

func (*RepoStruct) SetPluginOwner

func (r *RepoStruct) SetPluginOwner(d *drivers.Driver)

func (*RepoStruct) UpstreamAPIUrl

func (r *RepoStruct) UpstreamAPIUrl() string

type ReposStruct

type ReposStruct map[string]*RepoStruct

func (ReposStruct) AllHasAppWith

func (r ReposStruct) AllHasAppWith(rules ...string) (found bool, err error)

AllHasAppWith verify rules on all repos and returned true if all respect the rule.

func (ReposStruct) HasAppWith

func (r ReposStruct) HasAppWith(rules ...string) (found bool, err error)

HasAppWith return true if at least one repo respect the rule.

func (ReposStruct) MarshalYAML

func (r ReposStruct) MarshalYAML() (interface{}, error)

func (ReposStruct) SetRelapps

func (r ReposStruct) SetRelapps(relAppName, appName string) (_ error)

type UserStruct

type UserStruct struct {
	Role string
	More map[string]string `yaml:",inline"`
	// contains filtered or unexported fields
}

func (*UserStruct) Flags

func (u *UserStruct) Flags() (flags []string)

Flags returns the list of keys found in this object.

func (*UserStruct) Get

func (u *UserStruct) Get(field string) (value *goforjj.ValueStruct, found bool, source string)

func (*UserStruct) Set

func (u *UserStruct) Set(source, field, value string)

func (*UserStruct) SetHandler

func (r *UserStruct) SetHandler(source string, from func(field string) (string, bool), keys ...string)

type UsersStruct

type UsersStruct map[string]*UserStruct

type Workspace

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

Define the workspace data saved at create/update time. Workspace data are not controlled by any git repo. It is local. Usually, we stored data to found out where the infra is. But it can store any data that is workspace environment specific. like where is the docker static binary.

func (*Workspace) Check_exist

func (w *Workspace) Check_exist() (bool, error)

Check_exist Check if a workspace exist or not

func (*Workspace) CleanUnwantedEntries

func (w *Workspace) CleanUnwantedEntries()

CleanUnwantedEntries is called before save to remove some unwanted data in the Workspace file. Ex: infra-path

func (*Workspace) Data

func (w *Workspace) Data() (result map[string]WorkspaceExport)

Data provides the list of workspace variables stored.

func (*Workspace) EnsureExist

func (w *Workspace) EnsureExist() (wPath string, err error)

EnsureExist Ensure workspace path exists. So, if missing, it will be created. The current path (pwd) is moved to the existing workspace path.

func (*Workspace) Error

func (w *Workspace) Error() error

func (*Workspace) Get

func (w *Workspace) Get(field string) (value string, found bool)

Get return the value of the requested field and found if was found. Get do not extract the default value if not found to get the Default value, use GetDefault()

func (*Workspace) GetDefault

func (w *Workspace) GetDefault(field string) (value string, found bool)

GetDefault return the default value of the requested field and found if was found.

func (*Workspace) GetString

func (w *Workspace) GetString(field string) (value string)

GetString return the data of the requested field. If not found, it return the default value

func (*Workspace) Infra

func (w *Workspace) Infra() (ret *goforjj.PluginRepo)

Infra return the Infra data object

func (*Workspace) InfraPath

func (w *Workspace) InfraPath() string

InfraPath Return the path which contains the workspace. As the workspace is in the root or the infra repository, that path is then the Infra path. Note: The infra name is the repository name, ie the upstream repo name. This name is not necessarily the base name of the Infra path, because we can clone to a different name.

func (*Workspace) Init

func (w *Workspace) Init(cliSetup func(string) string, non_ws_entries ...string)

Init initialize the Workspace object

func (*Workspace) Len

func (w *Workspace) Len() int

Len provides the numbers of workspace data stored.

func (*Workspace) Load

func (w *Workspace) Load() error

Load workspace information from the forjj.json Workspace path is get from forjj and set kept in the workspace as reference for whole forjj thanks to a.w.Path()

func (*Workspace) Name

func (w *Workspace) Name() string

Name Provide the workspace Name

func (*Workspace) Path

func (w *Workspace) Path() string

Path Provide the workspace absolute path

func (*Workspace) RequireWorkspacePath

func (w *Workspace) RequireWorkspacePath() error

func (*Workspace) Save

func (w *Workspace) Save()

Save persistent workspace data to the json file

func (*Workspace) Set

func (w *Workspace) Set(field, value string, persistent bool) bool

Set save field/value pair in the workspace. If persistent is true, this data will be stored in the internal persistent workspace data Save will check this flag to update the .forj-workspace/forjj.json

func (*Workspace) SetDefault

func (w *Workspace) SetDefault(field, value string)

SetDefault save field/value pair in the workspace as default value. This value is set to the internal if not set or if unset

func (*Workspace) SetError

func (w *Workspace) SetError(err error) error

func (*Workspace) SetFrom

func (w *Workspace) SetFrom(aWorkspace WorkspaceStruct)

func (*Workspace) SetInfra

func (w *Workspace) SetInfra(infra *goforjj.PluginRepo)

SetInfra save the infra object in the workspace internal data

func (*Workspace) SetPath

func (w *Workspace) SetPath(Workspace_path string) error

SetPath define the workspace path.

func (*Workspace) SocketPath

func (w *Workspace) SocketPath(subdirs string) (socketPath string)

SocketPath creates a socket path if it doesn't exist. This information is stored in the workspace forjj.json file

func (*Workspace) Unset

func (w *Workspace) Unset(field string) (updated bool)

Unset remove value of the given field in the workspace. The default value can be restored if it was originally set

type WorkspaceData

type WorkspaceData struct {
	Organization    string              // Workspace Organization name
	Driver          string              // Infra upstream driver name
	Instance        string              // Infra upstream instance name
	Infra           *goforjj.PluginRepo // Infra-repo definition
	WorkspaceStruct                     // Struct shared with local-settings of a Forjfile model
}

WorkspaceData contains the structured data saved as json

type WorkspaceExport

type WorkspaceExport struct {
	Value     string
	IsDefault bool
}

type WorkspaceStruct

type WorkspaceStruct struct {
	DockerBinPath          string `yaml:"docker-exe-path"`    // Docker static binary path
	Contrib_repo_path      string `yaml:"contribs-repo"`      // Contrib Repo path used.
	Flow_repo_path         string `yaml:"flows-repo"`         // Flow repo path used.
	Repotemplate_repo_path string `yaml:"repotemplates-repo"` // Repotemplate Path used.
	SocketDir              string `yaml:"-"`                  // Calculated field. Full path to forjj plugins sockets dir - Shared with plugins containers. Composed by `SocketDirName`/`SocketBaseName`.
	SocketDirName          string `yaml:"socker-dir-name"`    // Base path containing the sockets directory - Shared in DooD CI context - Can be defined in Yaml by a Forjfile model.

	More map[string]string `yaml:",inline"`
	// contains filtered or unexported fields
}

WorkspaceStruct represents the yaml structure of a workspace.

Jump to

Keyboard shortcuts

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