configure

package module
v0.0.0-...-3dbd443 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 11 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// DefaultConfigFileName is the main config json file name.
	DefaultConfigFileName = "contxt_current_config.json"
	// DefaultPath this is the default path to store gocd configurations
	DefaultPath = "/.contxt/"
	// DefaultWorkspace this is the main configuration workspace
	DefaultWorkspace = "default_contxt_ws"
	// MirrorPath path for local mirror
	MirrorPath = "mirror/"
	// path where shared repositories are stored
	Sharedpath = "shared/"
)

Variables

View Source
var (
	USE_SPECIAL_DIR                      = true           // if true, we will use some of the special dirs like user home or other. defined in the config model
	CONTEXT_DIR                          = "contxt"       // default directory name for the config files
	CONTXT_FILE                          = "contxtv2.yml" // default file name for the config file
	CFG                  ConfigMetaV2    = ConfigMetaV2{} // the config model
	MIGRATION_ENABLED                    = true           // if true, we will try to migrate from v1 to v2
	CONFIG_PATH_CALLBACK GetPathCallback = nil            // if set, we will use this callback to get the absolte path to the config file
)

Functions

func CheckCurrentVersion

func CheckCurrentVersion(askWithVersion string) bool

CheckCurrentVersion checks if the current version is greater or equal to the given version

func CheckVersion

func CheckVersion(askWithVersion string, verifyAgainst string) bool

CheckVersion checks if the given version is greater or equal to the verifyAgainst version

func GetBinaryName

func GetBinaryName() string

GetBinaryName delivers the current binary name if no binary name is set, the default is "contxt"

func GetBuild

func GetBuild() string

GetBuild returns Build time as build NO

func GetCnShortcut

func GetCnShortcut() string

GetCnShortcut delivers the current shortcut for the context cn command in bash, fish, zsh and powershell if no shortcut is set, the default is "cn"

func GetGlobalConfig

func GetGlobalConfig() *contxtConfigure

func GetOs

func GetOs() string

GetOs returns the current operating system if no operating system is set, the default is the runtime.GOOS

func GetShortcut

func GetShortcut() string

GetShortcut delivers the current shortcut for the context functions in bash, fish, zsh and powershell if no shortcut is set, the default is "ctx"

func GetShortcutsAndBinaryName

func GetShortcutsAndBinaryName() (string, string, string)

GetShortcutsAndBinaryName delivers the current shortcuts and binary name for the context functions in bash, fish, zsh and powershell this is the contxt shortcut, then cn shortcut and the binary name

func GetVersion

func GetVersion() string

GetVersion delivers the current build version

func NewCfgV2

func NewCfgV2(c *contxtConfigure)

func NewContxtConfig

func NewContxtConfig() *contxtConfigure

func SetBinaryName

func SetBinaryName(newBinaryName string)

func SetCnShortcut

func SetCnShortcut(newShortcut string)

func SetShortcut

func SetShortcut(newShortcut string)

ment for testing

Types

type Action

type Action struct {
	Target  string   `yaml:"target"`
	Stopall bool     `yaml:"stopall"`
	Script  []string `yaml:"script"`
}

Action defines what should happens Next.

type Autorun

type Autorun struct {
	// this target will be executed if to this workspace was changed
	Onenter string `yaml:"onenter"`

	// this target will be executed if we changing to another workspace
	// so we leaving the current workspace
	// can be used for cleanup ...as a example
	Onleave string `yaml:"onleave"`
}

Autorun defines the targets they have to be executed if a special event is triggered

type CommandLine

type CommandLine struct {
	Require            RequireCheck
	Command            string
	Params             string
	Comment            string
	StopOnError        bool
	StopOnOutCountLess int
	StopOnOutCountMore int
	StopOnOutContains  string
	TraceOutput        bool
}

CommandLine defines a line of commands that can be executed

type Config

type Config struct {
	Sequencially  bool              `yaml:"sequencially"`
	Coloroff      bool              `yaml:"coloroff"`
	Loglevel      string            `yaml:"loglevel"`
	Variables     map[string]string `yaml:"variables,omitempty"`
	Autorun       Autorun           `yaml:"autorun"`
	Imports       []string          `yaml:"imports"`
	Use           []string          `yaml:"use"`
	Require       []string          `yaml:"require"`
	MergeTasks    bool              `yaml:"mergetasks"`
	AllowMutliRun bool              `yaml:"allowmultiplerun"`
}

Config is the main Configuration part of the Template.

type ConfigMetaV2

type ConfigMetaV2 struct {
	CurrentSet string                     `yaml:"CurrentSet"`
	Configs    map[string]ConfigurationV2 `yaml:"Configs"`
}

new version of the configuration starts here

type Configuration

type Configuration struct {
	CurrentSet string
	Paths      []string
	LastIndex  int
	PathInfo   map[string]WorkspaceInfo
}

Configuration includes all paths for the current workspace this is the main Configuration that is needed to eep track which path is currently used. this is the used format til version 0.4.0

type ConfigurationV2

type ConfigurationV2 struct {
	Name         string                     `yaml:"Name"`         // the name of the workspace
	CurrentIndex string                     `yaml:"CurrentIndex"` // what of the workspaces are the current used
	Paths        map[string]WorkspaceInfoV2 `yaml:"Paths"`
}

type ExecuteDefinition

type ExecuteDefinition struct {
	TestScript  []CommandLine
	InitScript  []CommandLine
	CleanScript []CommandLine
	Script      []CommandLine
}

ExecuteDefinition Defines the structure of a .execute file that defines commands they have to executed

type GetPathCallback

type GetPathCallback func() string

type GitVersionInfo

type GitVersionInfo struct {
	HashUsed    string
	Reference   string
	Repositiory string
	Path        string
	Exists      bool
}

type IncludePaths

type IncludePaths struct {
	Include struct {
		Basedir bool     `yaml:"basedir"`
		Folders []string `yaml:"folders"`
	} `yaml:"include"`
}

IncludePaths are files the defines how variables should be parsed. they indludes folders they have to be parsed first so they contents can be sued to proceeed with test/template. otherwise the yaml file is not readable

type Listener

type Listener struct {
	Trigger Trigger `yaml:"trigger"`
	Action  Action  `yaml:"action"`
}

Listener are used for watching events and triggers an action if a event happens

type Options

type Options struct {
	IgnoreCmdError bool     `yaml:"ignoreCmdError"`
	Format         string   `yaml:"format"`
	Stickcursor    bool     `yaml:"stickcursor"`
	Colorcode      string   `yaml:"colorcode"`
	Bgcolorcode    string   `yaml:"bgcolorcode"`
	Panelsize      int      `yaml:"panelsize"`
	Displaycmd     bool     `yaml:"displaycmd"`
	Hideout        bool     `yaml:"hideout"`
	Invisible      bool     `yaml:"invisible"`
	Maincmd        string   `yaml:"maincmd"`
	Mainparams     []string `yaml:"mainparams"`
	NoAutoRunNeeds bool     `yaml:"noAutoRunNeeds"`
	TimeoutNeeds   int      `yaml:"timeoutNeeds"`
	TickTimeNeeds  int      `yaml:"tickTimeNeeds"`
	WorkingDir     string   `yaml:"workingdir"`
}

Options are the per-task options

type Require

type Require struct {
	Exists      []string          `yaml:"exists"`
	NotExists   []string          `yaml:"notExists"`
	Environment map[string]string `yaml:"environment,omitempty"`
	Variables   map[string]string `yaml:"variables,omitempty"`
	System      string            `yaml:"system,omitempty"`
}

Require defines what is required to execute the task

type RequireCheck

type RequireCheck struct {
	FileExists    []string
	FileNotExists []string
}

RequireCheck defines some variables they have to be valid before script runs

type RunConfig

type RunConfig struct {
	Version   string        `yaml:"version"`
	Config    Config        `yaml:"config"`
	Task      []Task        `yaml:"task"`
	Workspace WorkspaceInfo `yaml:"workspace,omitempty"`
}

RunConfig defines the structure of the local stored execution files this is the ROOT of the contxt.yml

type Task

type Task struct {
	ID          string            `yaml:"id"`
	Variables   map[string]string `yaml:"variables,omitempty"`
	Requires    Require           `yaml:"require"`
	Stopreasons Trigger           `yaml:"stopreasons"`
	Options     Options           `yaml:"options"`
	Script      []string          `yaml:"script"`
	Listener    []Listener        `yaml:"listener"`
	Next        []string          `yaml:"next"`
	RunTargets  []string          `yaml:"runTargets"`
	Needs       []string          `yaml:"needs"`
}

Task is the main Script

type Trigger

type Trigger struct {
	Onerror        bool     `yaml:"onerror"`
	OnoutcountLess int      `yaml:"onoutcountLess"`
	OnoutcountMore int      `yaml:"onoutcountMore"`
	OnoutContains  []string `yaml:"onoutContains"`
	Now            bool     `yaml:"now"`
}

Trigger are part of listener. The defines some events they are triggered by executing scripts most of them watching the output

type WorkspaceInfo

type WorkspaceInfo struct {
	Project string `yaml:"project"` // the name of the project
	Role    string `yaml:"role"`    // what is this path about.
	Version string `yaml:"version"` // optional version
}

type WorkspaceInfoV2

type WorkspaceInfoV2 struct {
	Path    string `yaml:"Path"`
	Project string `yaml:"Project"`
	Role    string `yaml:"Role"`
	Version string `yaml:"Version"`
}

Jump to

Keyboard shortcuts

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