config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Current = CIDConfig{}

Functions

func LoadConfigurationFile

func LoadConfigurationFile(config interface{}, file string) (err error)

Types

type Action

type Action struct {
	Repository  string          `required:"true" yaml:"repository"`
	Name        string          `required:"true" yaml:"name"`
	Enabled     bool            `default:"true" yaml:"enabled,omitempty"`
	Type        ActionType      `required:"true" yaml:"type"`
	Container   ContainerAction `yaml:"container,omitempty"` // Container contains the configuration for containerized actions
	Description string          `yaml:"description"`
	Version     string          `yaml:"version"`
	Scope       ActionScope     `required:"true" yaml:"scope"`
	Rules       []WorkflowRule  `yaml:"rules,omitempty"`
	Access      ActionAccess    `yaml:"access"`
}

type ActionAccess

type ActionAccess struct {
	Env []string `yaml:"env"`
}

type ActionScope

type ActionScope string
const (
	ActionScopeProject ActionScope = "project"
	ActionScopeModule  ActionScope = "module"
)

type ActionType

type ActionType string
const (
	ActionTypeBuiltinGolang ActionType = "builtin-golang"
	ActionTypeContainer     ActionType = "container"
	ActionTypeGitHubAction  ActionType = "githubaction"
)

type BinaryExecutionCandidate

type BinaryExecutionCandidate struct {
	Binary  string
	Version string
	Type    ExecutionType

	// File holds the absolute path to the executable file
	File string

	// Image holds the container image
	Image string

	// ImageCache holds information about caching for containers
	ImageCache []ToolCacheDir

	// Mounts
	Mounts []ContainerMount

	// Security
	Security ToolSecurity
}

type BranchingConventionType

type BranchingConventionType string
const (
	BranchingGitFlow BranchingConventionType = "GitFlow"
)

type CIDConfig

type CIDConfig struct {
	Paths       PathConfig
	Mode        ExecutionType `default:"PREFER_LOCAL"`
	Conventions ProjectConventions
	Env         map[string]string

	// Catalog holds all currently known actions
	Catalog Catalog `yaml:"catalog,omitempty"`

	// Workflows holds all available workflows
	Workflows []Workflow `yaml:"workflows,omitempty"`

	// Dependencies holds a key value map of required versions
	Dependencies map[string]string `yaml:"dependencies,omitempty"`

	// LocalTools holds a list to lookup locally installed tools for command execution
	LocalTools []ToolLocal `yaml:"localtools,omitempty"`

	// ContainerImages holds a list of images that provide tools for command execution
	ContainerImages []ToolContainerImage `yaml:"containerimages,omitempty"`
}

CIDConfig is the full stuct of the configuration file

func LoadConfig

func LoadConfig(projectDirectory string) *CIDConfig

func (*CIDConfig) FindAction

func (c *CIDConfig) FindAction(name string) *Action

FindAction finds an action by id

func (*CIDConfig) FindExecutionCandidates

func (c *CIDConfig) FindExecutionCandidates(binary string, constraint string, preferExecutionType ExecutionType, preferVersion PreferVersion) []BinaryExecutionCandidate

FindExecutionCandidates returns a full list of all available execution options for the specified binary

func (*CIDConfig) FindImageOfBinary

func (c *CIDConfig) FindImageOfBinary(binary string, constraint string) *ToolContainerImage

FindImageOfBinary retrieves information about the container image for the specified binary fulfilling the constraint

func (*CIDConfig) FindPathOfBinary

func (c *CIDConfig) FindPathOfBinary(binary string, constraint string) *ToolLocal

FindPathOfBinary retrieves information about the local path of the specified binary fulfilling the constraint

func (*CIDConfig) FindWorkflow

func (c *CIDConfig) FindWorkflow(name string) *Workflow

FindWorkflow finds a workflow by name

type Catalog

type Catalog struct {
	Actions []Action `json:"actions"`
}

type CommitConventionType

type CommitConventionType string
const (
	ConventionalCommits CommitConventionType = "ConventionalCommits"
)

type ContainerAction

type ContainerAction struct {
	Image   string `yaml:"image"`   // Image is the full image reference including the registry
	Command string `yaml:"command"` // Command is the command that should be executed in the container image to start the action.
}

type ContainerMount

type ContainerMount struct {
	Src  string `yaml:"src"`
	Dest string `yaml:"dest"`
}

type ExecutionType

type ExecutionType string
const (
	ExecutionExec      ExecutionType = "exec"
	ExecutionContainer ExecutionType = "container"
)

type PathConfig

type PathConfig struct {
	Artifact string `default:".dist"`
	Temp     string `default:".tmp"`
	Cache    string `default:""`
}

PathConfig contains the path configuration for build/tmp directories

func (PathConfig) ArtifactModule

func (c PathConfig) ArtifactModule(dir ...string) string

ArtifactModule returns dist folder for a specific module

func (PathConfig) ModuleCache

func (c PathConfig) ModuleCache(module string) string

ModuleCache returns the cache directory for a specific module

func (PathConfig) NamedCache

func (c PathConfig) NamedCache(name string) string

NamedCache returns the cache directory for a named cache

func (PathConfig) TempModule

func (c PathConfig) TempModule(name string) string

TempModule returns temp folder for a specific module

type PreferVersion

type PreferVersion string
const (
	PreferHighest PreferVersion = "highest"
	PreferLowest  PreferVersion = "lowest"
)

type ProjectConventions

type ProjectConventions struct {
	Branching        BranchingConventionType `default:"GitFlow"`
	Commit           CommitConventionType    `default:"ConventionalCommits"`
	PreReleaseSuffix string                  `default:"-rc.{NCI_LASTRELEASE_COMMIT_AFTER_COUNT}"`
}

type ToolBinary

type ToolBinary struct {
	Binary  string `yaml:"binary"`
	Version string `yaml:"version"`
}

type ToolCacheDir

type ToolCacheDir struct {
	ID            string
	ContainerPath string `yaml:"dir"`
	MountType     string `yaml:"type"`
}

type ToolContainerImage

type ToolContainerImage struct {
	Provides []ToolBinary   `yaml:"provides"`
	Image    string         `yaml:"image"`
	Cache    []ToolCacheDir `yaml:"cache"`
	Security ToolSecurity   `yaml:"security"`
	User     string         `yaml:"user"`

	// Mounts
	Mounts []ContainerMount `yaml:"mounts,omitempty"`
}

type ToolLocal

type ToolLocal struct {
	Binary         []string
	Lookup         []ToolLocalLookup
	LookupSuffixes []string `yaml:"lookup-suffixes"`
	Path           string
	ResolvedBinary string
}

type ToolLocalLookup

type ToolLocalLookup struct {
	Key     string // env name
	Version string // version
}

ToolLocalLookup is used to discover local tool installations based on ENV vars

type ToolSecurity

type ToolSecurity struct {
	Capabilities []string `yaml:"capabilities"`
	Privileged   bool     `yaml:"privileged"`
}

type Workflow

type Workflow struct {
	Name   string          `required:"true" yaml:"name,omitempty"`
	Rules  []WorkflowRule  `yaml:"rules,omitempty"`
	Stages []WorkflowStage `yaml:"stages,omitempty"`
}

func (*Workflow) ActionCount

func (w *Workflow) ActionCount() int

ActionCount returns the total count of actions across all stages

type WorkflowAction

type WorkflowAction struct {
	ID     string                     `required:"true" yaml:"id"`
	Rules  []WorkflowRule             `yaml:"rules,omitempty"`
	Config interface{}                `yaml:"config,omitempty"`
	Module *analyzerapi.ProjectModule `yaml:"-"`
}

type WorkflowExpressionType

type WorkflowExpressionType string
const (
	WorkflowExpressionCEL WorkflowExpressionType = "cel"
)

type WorkflowRule

type WorkflowRule struct {
	Type       WorkflowExpressionType `default:"cel" yaml:"type,omitempty"`
	Expression string                 `yaml:"expression,omitempty"`
}

type WorkflowStage

type WorkflowStage struct {
	Name    string           `required:"true" yaml:"name,omitempty"`
	Rules   []WorkflowRule   `yaml:"rules,omitempty"`
	Actions []WorkflowAction `yaml:"actions,omitempty"`
}

Jump to

Keyboard shortcuts

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