config

package
v0.4.40 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answers

type Answers struct {
	CompanyName           string   `survey:"company_name"`
	CompanyDomain         string   `survey:"company_domain"`
	CompanyComponent      string   `survey:"company_component"`
	Pipeline              string   `survey:"pipeline"`
	CloudPlatform         string   `survey:"cloud_platform"`
	TerraformGroup        string   `survey:"terraform_group"`
	TerraformStorage      string   `survey:"terraform_storage"`
	TerraformContainer    string   `survey:"terraform_container"`
	NetworkDomainExternal string   `survey:"network_domain_external"`
	NetworkDomainInternal string   `survey:"network_domain_internal"`
	Options               []string `survey:"options"`
	WorkingDir            string   `survey:"working_dir"`
	ProjectCount          int      `survey:"project_count"`
	EnvironmentCount      int      `survey:"environment_count"`
}

Answers is the object that results from the command line, when run in interactive mode, are added to.

func (*Answers) RunInteractive

func (a *Answers) RunInteractive(config *Config) error

type Business

type Business struct {
	Company   string `mapstructure:"company" yaml:",omitempty"`
	Project   string `mapstructure:"project" json:",omitempty" yaml:",omitempty"`
	Domain    string `mapstructure:"domain" yaml:",omitempty"`
	Component string `mapstructure:"component" yaml:",omitempty"`
}

type Cloud

type Cloud struct {
	Platform      string `mapstructure:"platform" yaml:",omitempty"`
	Region        string `mapstructure:"region" yaml:",omitempty"`
	ResourceGroup string `mapstructure:"group" yaml:"group,omitempty"`
}

type Commands

type Commands struct {
	Git []string `mapstructure:"git"`
}

type Config

type Config struct {
	Commands      Commands       `mapstructure:"commands"`
	FrameworkDefs []FrameworkDef `mapstructure:"frameworks" yaml:"frameworks"`
	Input         InputConfig    `mapstructure:"input" yaml:"input"`
	Internal      Internal
	Help          Help `mapstructure:"help"`
	Replace       []ReplaceConfig
	Self          SelfConfig
	Stacks        Stacks `mapstructure:"stacks" yaml:"stacks"` // Holds the information about the projects in stacks

}

func (*Config) Check

func (c *Config) Check() error

Check checks the configuration and ensures that there are some projects to work with and that the chosen pipeline is supported It also sets some defaults based on other settings in the configuration

func (*Config) ExecuteCommand

func (config *Config) ExecuteCommand(path string, logger *logrus.Logger, command string, arguments string, show bool, force bool) (string, error)

ExecuteCommand executes the command and arguments that have been supplied to the function

func (*Config) Force

func (c *Config) Force() bool

Force states if projects should be overwritten

func (*Config) GetFrameworkCommands

func (config *Config) GetFrameworkCommands(framework string) FrameworkDef

GetFrameworkCommands gets the list of commands that are associated with the specified framework. This is so that their existence on the PATH can be checked

func (*Config) GetVersion

func (config *Config) GetVersion() string

GetVersion returns the current version of the application It will check to see uif the Version is empty, if it is, it will set and identifiable local build version

func (*Config) Init

func (c *Config) Init()

func (*Config) IsDryRun

func (c *Config) IsDryRun() bool

IsDryRun returns the boolean value of the dryrun option

func (*Config) NoBanner

func (c *Config) NoBanner() bool

NoBanner returns the option to no display the Stacks banner

func (*Config) NoCleanup

func (c *Config) NoCleanup() bool

NoCleanup returns a boolean stating if the app should perform cleanup functions

func (*Config) OnlineHelp

func (c *Config) OnlineHelp() bool

Return the state of OnlineHelp

func (*Config) OpenOnlineHelp

func (config *Config) OpenOnlineHelp(cliCmd string, logger *logrus.Logger) bool

OpenOnlineHelp opens the relevant help for the specified CLI command

func (*Config) RenderTemplate

func (config *Config) RenderTemplate(name string, tmpl string, input Replacements) (string, error)

renderTemplate takes any string and attempts to replace items in it based on the values in the supplied Input object

func (*Config) Save

func (c *Config) Save(usedConfig string) (string, error)

Save saves the user's configuration to a file This is only applicable if a configuration file has not been used and the option to save the configuration has been set as an option

func (*Config) SetDefaultValues

func (config *Config) SetDefaultValues()

SetDefaultValues sets values in the config object that are based off other values in the config object For example, if the internal domain name has not been set then it will be based on the external domain name, with the TLD replaced with `internal`

func (*Config) UseCmdLog

func (c *Config) UseCmdLog() bool

UseCmdLog states of the command log should be used

func (*Config) WriteCmdLog

func (config *Config) WriteCmdLog(path string, cmd string) error

WriteCmdLog writes the command out a log file in the directory that the CLI is being run The cmd is only written out if the option to do so has been set in the config

func (*Config) WriteVariablesFile

func (config *Config) WriteVariablesFile(project *Project, pipelineSettings Pipeline, replacements Replacements) (string, error)

WriteVariablesFile writes out the variables template file for the build pipeline

type Directory

type Directory struct {
	WorkingDir string `mapstructure:"working" yaml:"working"`
	TempDir    string `mapstructure:"temp" yaml:"-"`
	HomeDir    string `mapstructure:"home" yaml:"-"`
	CacheDir   string `mapstructure:"cache" yaml:"-"`
	Export     string `mapstructure:"export"`
}

type DomainType

type DomainType struct {
	Internal string `mapstructure:"internal" json:",omitempty"`
	External string `mapstructure:"external"`
}

type Environment

type Environment struct {
	Name      string   `mapstructure:"name" yaml:",omitempty"`
	Type      string   `mapstructure:"type" yaml:",omitempty"`
	DependsOn []string `mapstructure:"dependson" yaml:",omitempty"`
}

type EnvironmentAnswers

type EnvironmentAnswers struct {
	Name      string `survey:"name"`
	Type      string `survey:"type"`
	DependsOn string `survey:"dependson"`
}

type Framework

type Framework struct {
	Type           string   `mapstructure:"type"`
	Option         string   `mapstructure:"option"`
	Version        string   `mapstructure:"version" yaml:",omitempty"`                        // Version of the project to download
	Properties     []string `mapstructure:"properties" yaml:",omitempty"`                     // additional properties to be specified that need to be passed to project commands
	DeploymentMode string   `mapstructure:"deployment_mode" yaml:"deployment_mode,omitempty"` //AKS or ACA
}

func (*Framework) GetMapKey

func (framework *Framework) GetMapKey() string

GetMapKey returns the key to be used in the srcUrl map to get the URL for cloning the repository

type FrameworkDef

type FrameworkDef struct {
	Name     string            `mapstructure:"name" yaml:"name"`
	Commands []FrameworkDefCmd `mapstructure:"commands" yaml:"commands"`
}

func (*FrameworkDef) GetCmdList added in v0.4.17

func (fd *FrameworkDef) GetCmdList() []string

type FrameworkDefCmd added in v0.4.17

type FrameworkDefCmd struct {
	Name    string              `mapstructure:"name" yaml:"name"`
	Version FrameworkDefVersion `mapstructure:"version" yaml:"version"`
}

type FrameworkDefVersion

type FrameworkDefVersion struct {
	Arguments  string `mapstructure:"arguments" yaml:"arguments"`
	Pattern    string `mapstructure:"pattern" yaml:"pattern"`
	Comparator string `mapstructure:"comparator" yaml:"comparator"`
}

type Help

type Help struct {
	Root        string `mapstructure:"root"`
	Scaffold    string `mapstructure:"scaffold"`
	Interactive string `mapstructure:"interactive"`
	Version     string `mapstructure:"version"`
	Export      string `mapstructure:"export"`
}

Help struct holds the urls for the help pages for the different commands

func (*Help) GetUrl

func (help *Help) GetUrl(cmd string) string

type Init

type Init struct {
	Operations []Operation `mapstructure:"operations"`
}

Init holds the operations that should be performed before any work is done on the working project

type InputConfig

type InputConfig struct {

	// Version of the application
	Version string `yaml:"-"`

	// Define the logging parameters
	Log models.Log `mapstructure:"log"`

	Directory Directory `mapstructure:"directory"`

	Business     Business      `mapstructure:"business"`
	Cloud        Cloud         `mapstructure:"cloud"`
	Network      Network       `mapstructure:"network"`
	Pipeline     string        `mapstructure:"pipeline"`
	Project      []Project     `mapstructure:"project"`
	Terraform    Terraform     `mapstructure:"terraform"`
	SettingsFile string        `mapstructure:"settingsfile" json:",omitempty"`
	Options      Options       `mapstructure:"options"`
	Overrides    Overrides     `mapstructure:"overrides"`
	Environment  []Environment `mapstructure:"environment"`

	// Set values to accept from the command line when running setup
	Global  bool     `mapstructure:"global" yaml:"-"`
	Folders []string `mapstructure:"folders" yaml:"-"`
}

Config is used to map the configuration onto the application models

func (*InputConfig) CheckFrameworks

func (ic *InputConfig) CheckFrameworks(config *Config) []models.Command

CheckFrameworks iterates around each of the projects and builds up a list of the frameworks that have been specified. It will then check that each of the framework binaries are present in the path. If there are not then the ones that are not present are returned to the calling function

func (*InputConfig) ValidateInput

func (ic *InputConfig) ValidateInput() []string

ValidateInput checks the input object and ensures that values are correctly formatted For example the company name should not contain spaces, so this will replace any spaces with an underscore

type Internal

type Internal struct {
	Files map[string]interface{}
}

func (*Internal) AddFiles

func (i *Internal) AddFiles()

func (*Internal) GetFileContent

func (i *Internal) GetFileContent(name string) []byte

func (*Internal) GetFileContentString

func (i *Internal) GetFileContentString(name string) string

func (*Internal) GetFilename

func (i *Internal) GetFilename(name string) string

type Network

type Network struct {
	Base NetworkBase `mapstructure:"base"`
}

type NetworkBase

type NetworkBase struct {
	Domain DomainType `mapstructure:"domain"`
}

type Operation

type Operation struct {
	Action          string   `mapstructure:"action"`
	Command         string   `mapstructure:"cmd"`
	Arguments       string   `mapstructure:"args"`
	Description     string   `mapstructure:"desc"`
	ApplyProperties bool     `mapstructure:"applyProperties"`
	Tags            []string `mapstructure:"tags"`
}

type Options

type Options struct {
	CmdLog       bool   `mapstructure:"cmdlog"`
	DryRun       bool   `mapstructure:"dryrun"`
	SaveConfig   bool   `mapstructure:"save" yaml:"-"`
	NoCleanup    bool   `mapstructure:"nocleanup" yaml:"-"`
	Force        bool   `mapstructure:"force" yaml:"-"`
	NoBanner     bool   `mapstructure:"nobanner"`
	NoCLIVersion bool   `mapstructure:"nocliversion"`
	Token        string `mapstructure:"token" json:"-"`
	OnlineHelp   bool   `mapstructure:"onlinehelp" json:"-"`
	NoScaffold   bool   `mapstructure:"noscaffold" json:"-"`
}

Options holds the options for the CLI, such as turning on cmd logging

type Output

type Output struct {
	Input InputConfig `mapstructure:"input" yaml:"input"`
}

type Overrides

type Overrides struct {
	InternalConfigPath string `mapstructure:"internal_config" yaml:"internal_config"`
	InternalConfigURL  string `mapstructure:"internal_config_url" yaml:"internal_config_url"`
	AdoVariablesPath   string `mapstructure:"ado_variables_path" yaml:"ado_variables_path"`
}

type Package

type Package struct {
	Name    string `mapstructure:"name" yaml:"name"`
	Type    string `mapstructure:"type" yaml:"type"`
	URL     string `mapstructure:"url" yaml:"url"`
	Version string `mapstructure:"version" yaml:"version"`
	ID      string `mapstructure:"id" yaml:"id"`
}

func (*Package) Normalize

func (p *Package) Normalize() string

Normalize checks to see if the older API is being used and will take the values from that and populate the new structure It will return an error object to be used as a warning for people to update their structure

type Phase

type Phase struct {
	Operations []Operation
	Directory  string
	Name       string
}

type Pipeline

type Pipeline struct {
	Type         string                `mapstructure:"type"`
	File         []PipelineFile        `mapstructure:"files"`
	Template     []PipelineFile        `mapstructure:"templates"`
	Items        []string              `mapstructure:"items"`
	Replacements []PipelineReplacement `mapstructure:"replacements"`
}

func (*Pipeline) GetFilePath

func (p *Pipeline) GetFilePath(filetype string, workingDir string, name string) string

GetFilePath iterates around the either the File or Template slice looking for the specified name, if the name is found then it will return the path associated with the name

func (*Pipeline) GetSupported

func (p *Pipeline) GetSupported() []string

GetSupported returns a slice of all the currently supported pipelines This is determined using reflection on the current object

func (*Pipeline) GetVariableTemplate

func (p *Pipeline) GetVariableTemplate(workingDir string) string

func (*Pipeline) IsSupported

func (p *Pipeline) IsSupported(name string) bool

IsSupported states if the specified pipeline is supported by Stacks This is only used to state which overall pipelines are possible, each project can define the pipelines that it supports within this overall group

func (*Pipeline) ReplacePatterns

func (p *Pipeline) ReplacePatterns(config *Config, inputs Replacements, dir string) []error

ReplacePatterns replaces the phrases that are found in the build file according to the regex pattern with the specified value

type PipelineFile

type PipelineFile struct {
	Name      string `mapstructure:"name"`
	Path      string `mapstructure:"path"`
	NoReplace bool   `mapstructure:"noreplace"`
}

type PipelineReplacement

type PipelineReplacement struct {
	Pattern string `mapstructure:"pattern"`
	Value   string `mapstructure:"value"`
}

type Platform

type Platform struct {
	Type string `mapstructure:"type" json:",omitempty"`
}

type Project

type Project struct {
	Name          string        `mapstructure:"name"`
	Framework     Framework     `mapstructure:"framework"`
	Platform      Platform      `mapstructure:"platform" json:",omitempty"`
	SourceControl SourceControl `mapstructure:"sourcecontrol"`
	SettingsFile  string        `mapstructure:"settingsfile" json:",omitempty"`
	Cloud         Cloud         `mapstructure:"cloud"`

	Directory Directory `yaml:"-"` // Holds the workingdir and tempdir for the project

	Settings Settings `yaml:"-"` // Hold the settings for the current project

	Phases []Phase `yaml:"-"` // Holds the phases for the operations
}

func (*Project) GetId

func (project *Project) GetId() string

GetId returns a consistent identifier for the name of the project It will change all to lowercase and replace spaces with an "_"

func (*Project) ReadSettings

func (project *Project) ReadSettings(path string, config *Config) error

ReadSettings reads in the settings file for the current project Returns the path to the file that was read for the project settings and any errors that were raised The operations are also read in and the phases object is created

type ProjectAnswers

type ProjectAnswers struct {
	Name                    string `survey:"name"`
	FrameworkType           string `survey:"framework_type"`
	FrameworkOption         string `survey:"framework_option"`
	FrameworkVersion        string `survey:"framework_version"`
	FrameworkProperties     string `survey:"framework_properties"`
	FrameworkDeploymentMode string `survey:"framework_deployment_mode"`
	PlatformType            string `survey:"platform_type"`
	SourceControlType       string `survey:"source_control_type"`
	SourceControlUrl        string `survey:"source_control_url"`
	CloudRegion             string `survey:"cloud_region"`
	CloudGroup              string `survey:"cloud_group"`
}

ProjectAnswers are the list of answers that are provided for each project defined on the command line

type ReplaceConfig

type ReplaceConfig struct {
	Files  []string          `yaml:"files"`
	Values map[string]string `yaml:"values"`
}

type Replacements

type Replacements struct {
	Input   InputConfig
	Project Project
}

type SelfConfig

type SelfConfig struct {
	ProjectPaths map[string]string

	CmdLogPath string
}

func (*SelfConfig) AddPath

func (selfConfig *SelfConfig) AddPath(project Project, path string)

SetPaths sets the current project path

func (*SelfConfig) GetPath

func (selfConfig *SelfConfig) GetPath(project Project) string

GetPath returns the path for the current project

type Settings

type Settings struct {
	Framework SettingsFramework `mapstructure:"framework"`
	Pipeline  []Pipeline        `mapstructure:"pipeline"`
	Init      Init              `mapstructure:"init"`
	Setup     Setup             `mapstructure:"setup"`
}

Settings holds the settings for each project as read from the `stackscli.yml` file in the project

func (*Settings) CheckCmdVersions added in v0.4.17

func (s *Settings) CheckCmdVersions(config *Config, logger *logrus.Logger, path string, tmpPath string) ([]models.Command, string)

CheckCmdVersions checks that all of the commands that have been specified for the component exist and that they are the correct version.

It takes the following parameters: - config: A pointer to the Config struct containing the framework commands. - logger: A logger instance from the logrus package for logging errors and information. - path: The file path where the commands should be executed. - tmpPath: A temporary file path used for specific command checks.

It returns a slice of models.Command containing the commands that do not meet the specified version constraints, and an info string providing additional information.

func (*Settings) CompareVersion

func (s *Settings) CompareVersion(constraint string, version string, logger *logrus.Logger) bool

CompareVersion compares the specified version against the contsraint

func (*Settings) GetPipelines

func (s *Settings) GetPipelines(name string) []Pipeline

GetPipelines attempts to return all pipelines settings for the named pipeline

func (*Settings) GetRequiredVersion

func (s *Settings) GetRequiredVersion(name string) string

GetRequiredVersion interrogates the list of framework versions to determine if any specific version is required for building the application

type SettingsFramework

type SettingsFramework struct {
	Name     string                      `mapstructure:"name"`
	Commands []SettingsFrameworkCommands `mapstructure:"commands"`
}

type SettingsFrameworkCommands

type SettingsFrameworkCommands struct {
	Name    string `mapstructure:"name"`
	Version string `mapstructure:"version"`
}

type Setup

type Setup struct {
	Operations []Operation `mapstructure:"operations"`
}

Setup holds the operaions that should be performed after the projet has been added to the working directory

type SourceControl

type SourceControl struct {
	Type string `mapstructure:"type"`
	URL  string `mapstructure:"url"`
}

type Stacks

type Stacks struct {
	Components map[string]StacksComponent `mapstructure:"components" yaml:"components"`
}

func (*Stacks) GetComponentCount

func (s *Stacks) GetComponentCount() int

func (*Stacks) GetComponentNames

func (s *Stacks) GetComponentNames() []string

GetComponentNames returns a sorted slice of the components that are defined and removes any duplicates

func (*Stacks) GetComponentOptions

func (s *Stacks) GetComponentOptions(framework string) []string

GetComponentOptions analyses the StacksComponent slice and returns all of the options that are associated with the specified framework

func (*Stacks) GetComponentPackage

func (s *Stacks) GetComponentPackage(name string) Package

func (*Stacks) GetComponentPackageRef

func (s *Stacks) GetComponentPackageRef(name string) string

type StacksComponent

type StacksComponent struct {
	Group   string  `mapstructure:"group" yaml:"group"`
	Name    string  `mapstructure:"name" yaml:"name"`
	Package Package `mapstructure:"package" yaml:"package"`
}

func (*StacksComponent) GetName

func (sc *StacksComponent) GetName() string

GetName returns the name of the component by combining the group and the name

type State

type State struct {
	ProjectPaths map[string]string
}

type Terraform

type Terraform struct {
	Backend TerraformBackend `mapstructure:"backend" yaml:",omitempty"`
}

type TerraformBackend

type TerraformBackend struct {
	Storage   string `mapstructure:"storage" yaml:",omitempty"`
	Group     string `mapstructure:"group" yaml:",omitempty"`
	Container string `mapstructure:"container" yaml:",omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳