Documentation ¶
Index ¶
- Constants
- Variables
- func ConstantExpander(_ string, name string, meta string, isFunction bool, ctx *Expansion) (string, error)
- func DefaultScriptLanguage() []language.Language
- func EventExpander(_ string, name string, meta string, isFunction bool, ctx *Expansion) (string, error)
- func ExpandFromProject(s string, p *Project) (string, error)
- func ExpandFromProjectBashifyPaths(s string, p *Project) (string, error)
- func ExpandFromScript(s string, script *Script) (string, error)
- func IsRegistered(handle string) bool
- func ProjectExpander(_ string, name string, _ string, isFunction bool, ctx *Expansion) (string, error)
- func RegisterConditional(conditional *constraints.Conditional)
- func RegisterExpander(handle string, expanderFn ExpanderFunc) error
- func ScriptExpander(_ string, name string, meta string, isFunction bool, ctx *Expansion) (string, error)
- func TopLevelExpander(variable string, name string, _ string, _ bool, ctx *Expansion) (string, error)
- type Build
- type ConfigAble
- type Constant
- type Event
- type EventType
- type ExpanderFunc
- type Expansion
- type Job
- type Mixin
- type Namespaced
- type Project
- func FromEnv() (*Project, error)
- func FromExactPath(path string) (*Project, error)
- func FromPath(path string) (*Project, error)
- func FromWD() (*Project, error)
- func New(p *projectfile.Project, out output.Outputer) (*Project, error)
- func NewLegacy(p *projectfile.Project) (*Project, error)
- func Parse(fpath string) (*Project, error)
- func (p *Project) BranchName() string
- func (p *Project) Cache() string
- func (p *Project) Channel() string
- func (p *Project) ConstantByName(name string) *Constant
- func (p *Project) Constants() []*Constant
- func (p *Project) Dir() string
- func (p *Project) Environments() string
- func (p *Project) EventByName(name string, bashifyPaths bool) *Event
- func (p *Project) Events() []*Event
- func (p *Project) InitSecret(name string, scope SecretScope, cfg keypairs.Configurable, ...) *Secret
- func (p *Project) IsHeadless() bool
- func (p *Project) IsLocked() bool
- func (p *Project) Jobs() []*Job
- func (p *Project) LegacyCommitID() string
- func (p *Project) Lock() string
- func (p *Project) Name() string
- func (p *Project) Namespace() *Namespaced
- func (p *Project) NamespaceString() string
- func (p *Project) NewSecret(s *projectfile.Secret, scope SecretScope, cfg keypairs.Configurable, ...) *Secret
- func (p *Project) NormalizedName() string
- func (p *Project) Owner() string
- func (p *Project) Path() string
- func (p *Project) Private() bool
- func (p *Project) ProjectDir() string
- func (p *Project) ScriptByName(name string) (*Script, error)
- func (p *Project) Scripts() ([]*Script, error)
- func (p *Project) SecretByName(name string, scope SecretScope, cfg keypairs.Configurable, ...) *Secret
- func (p *Project) Secrets(cfg keypairs.Configurable, auth *authentication.Auth) []*Secret
- func (p *Project) SetLegacyCommit(commitID string) error
- func (p *Project) Source() *projectfile.Project
- func (p *Project) URL() string
- func (p *Project) Version() string
- type Script
- func (script *Script) Description() string
- func (script *Script) LanguageSafe() []language.Language
- func (script *Script) Languages() []language.Language
- func (script *Script) Name() string
- func (script *Script) Raw() string
- func (script *Script) Source() *projectfile.Project
- func (script *Script) SourceScript() *projectfile.Script
- func (script *Script) Standalone() bool
- func (script *Script) Value() (string, error)
- type Secret
- func (s *Secret) Description() string
- func (s *Secret) IsProject() bool
- func (s *Secret) IsUser() bool
- func (s *Secret) Name() string
- func (s *Secret) Scope() string
- func (s *Secret) Source() *projectfile.Project
- func (s *Secret) Value() (string, error)
- func (s *Secret) ValueOrNil() (*string, error)
- type SecretAccess
- type SecretExpander
- func (e *SecretExpander) Expand(_ string, category string, name string, isFunction bool, ctx *Expansion) (string, error)
- func (e *SecretExpander) ExpandWithPrompt(_ string, category string, name string, isFunction bool, ctx *Expansion) (string, error)
- func (e *SecretExpander) FetchDefinition(name string, isUser bool) (*secretsModels.SecretDefinition, error)
- func (e *SecretExpander) FetchSecret(name string, isUser bool) (string, error)
- func (e *SecretExpander) FindSecret(name string, isUser bool) (*secretsModels.UserSecret, error)
- func (e *SecretExpander) KeyPair() (keypairs.Keypair, error)
- func (e *SecretExpander) Organization() (*mono_models.Organization, error)
- func (e *SecretExpander) Project() (*mono_models.Project, error)
- func (e *SecretExpander) Secrets() ([]*secretsModels.UserSecret, error)
- func (e *SecretExpander) SecretsAccessed() []*SecretAccess
- type SecretFunc
- type SecretScope
Constants ¶
const NamespaceRegex = `^([\w-_]+)\/([\w-_\.]+)(?:#([-a-fA-F0-9]*))?$`
NamespaceRegex matches the org and project name in a namespace, eg. org/project
const ProjectCategory = "project"
ProjectCategory is the string used when referencing project secrets (eg. $secrets.project.foo)
const ProjectRegex = `^([\w-_\.]+)(?:#([-a-fA-F0-9]*))?$`
ProjectRegex matches the project name for a namespace with omitted org.
const TopLevelExpanderName = "toplevel"
const UserCategory = "user"
UserCategory is the string used when referencing user secrets (eg. $secrets.user.foo)
Variables ¶
var ( ErrExpandBadName = errs.New("Bad expander name") ErrExpandNoFunc = errs.New("Expander has no handler") )
var ErrSecretNotFound = errors.New("secret not found")
Functions ¶
func ConstantExpander ¶
func ConstantExpander(_ string, name string, meta string, isFunction bool, ctx *Expansion) (string, error)
ConstantExpander expands constants defined in the project-file.
func DefaultScriptLanguage ¶
DefaultScriptLanguage returns the default script language for the current platform. (ie. batch or bash)
func EventExpander ¶
func EventExpander(_ string, name string, meta string, isFunction bool, ctx *Expansion) (string, error)
EventExpander expands events defined in the project-file.
func ExpandFromProject ¶
ExpandFromProject searches for $category.name-style variables in the given string and substitutes them with their contents, derived from the given project, and subject to the given constraints (if any).
func ExpandFromProjectBashifyPaths ¶
ExpandFromProjectBashifyPaths is like ExpandFromProject, but bashifies all instances of $script.name.path().
func IsRegistered ¶
IsRegistered returns true if an Expander Func is registered for a given handle/name.
func ProjectExpander ¶
func ProjectExpander(_ string, name string, _ string, isFunction bool, ctx *Expansion) (string, error)
ProjectExpander expands constants defined in the project-file.
func RegisterConditional ¶
func RegisterConditional(conditional *constraints.Conditional)
RegisterConditional is a a temporary method for registering our conditional as a global yes this is bad, but at the time of implementation refactoring the project package to not be global is out of scope
func RegisterExpander ¶
func RegisterExpander(handle string, expanderFn ExpanderFunc) error
RegisterExpander registers an Expander Func for some given handler value. The handler value must not effectively be a blank string and the Func must be defined. It is definitely possible to replace an existing handler using this function.
Types ¶
type ConfigAble ¶
type ConfigAble interface { projectfile.ConfigGetter }
type Constant ¶
type Constant struct {
// contains filtered or unexported fields
}
Constant covers the constant structure
type Event ¶
type Event struct { BashifyPaths bool // for script path() calls, which varies by subshell // contains filtered or unexported fields }
Event covers the hook structure
func (*Event) Source ¶
func (e *Event) Source() *projectfile.Project
Source returns the source projectfile
type ExpanderFunc ¶
type ExpanderFunc func(variable, name, meta string, isFunction bool, ctx *Expansion) (string, error)
ExpanderFunc defines an Expander function which can expand the name for a category. An Expander expects the name to be expanded along with the project-file definition. It will return the expanded value of the name or a Failure if expansion was unsuccessful.
func NewSecretPromptingExpander ¶
func NewSecretPromptingExpander(secretsClient *secretsapi.Client, prompt prompt.Prompter, cfg keypairs.Configurable, auth *authentication.Auth) ExpanderFunc
NewSecretPromptingExpander creates an Expander which can retrieve and decrypt stored user secrets. Additionally, it will prompt the user to provide a value for a secret -- in the event none is found -- and save the new value with the secrets service.
func NewSecretQuietExpander ¶
func NewSecretQuietExpander(secretsClient *secretsapi.Client, cfg keypairs.Configurable, auth *authentication.Auth) ExpanderFunc
NewSecretQuietExpander creates an Expander which can retrieve and decrypt stored user secrets.
func RegisteredExpander ¶
func RegisteredExpander(handle string) ExpanderFunc
RegisteredExpander returns the expander registered for the given handle
type Expansion ¶
func NewExpansion ¶
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job covers the command structure
type Mixin ¶
type Mixin struct {
// contains filtered or unexported fields
}
Mixin provides expansions that are not sourced from a project file
func NewMixin ¶
func NewMixin(auth *authentication.Auth) *Mixin
NewMixin creates a Mixin object providing extra expansions
type Namespaced ¶
Namespaced represents a project namespace of the form <org/project>
func NameSpaceForConfig ¶
func NameSpaceForConfig(configFile string) *Namespaced
NameSpaceForConfig returns a valid project namespace. This version prefers to create a namespace from a configFile if it exists
func NewNamespace ¶
func NewNamespace(owner, project, commitID string) *Namespaced
func ParseNamespace ¶
func ParseNamespace(raw string) (*Namespaced, error)
ParseNamespace returns a valid project namespace
func ParseProjectNoOwner ¶
func ParseProjectNoOwner(raw string) (*Namespaced, error)
func (*Namespaced) IsValid ¶
func (ns *Namespaced) IsValid() bool
IsValid returns whether or not the namespace is set sufficiently.
func (*Namespaced) Set ¶
func (ns *Namespaced) Set(v string) error
Set implements the captain argmarshaler interface.
func (*Namespaced) String ¶
func (ns *Namespaced) String() string
String implements the fmt.Stringer interface.
func (*Namespaced) Type ¶
func (ns *Namespaced) Type() string
Type returns the human readable type name of Namespaced.
func (*Namespaced) Validate ¶
func (ns *Namespaced) Validate() error
Validate returns a failure if the namespace is not valid.
type Project ¶
Project covers the platform structure
func FromEnv ¶
FromEnv will return the project as per the environment configuration (eg. env var, working dir, global default, ..)
func FromExactPath ¶
FromExactPath will return the project that's located at the given path without walking up the directory tree
func FromPath ¶
FromPath will return the project that's located at the given path (this will walk up the directory tree until it finds the project)
func NewLegacy ¶
func NewLegacy(p *projectfile.Project) (*Project, error)
NewLegacy is for legacy use-cases only, DO NOT USE
func (*Project) BranchName ¶
BranchName returns the project branch name
func (*Project) Channel ¶
Channel returns channel that we're pinned to (useless unless version is also set)
func (*Project) ConstantByName ¶
ConstantByName returns a constant matching the given name (if any)
func (*Project) Environments ¶
Environments returns project environment
func (*Project) EventByName ¶
EventByName returns a reference to a projectfile.Script with a given name.
func (*Project) InitSecret ¶
func (p *Project) InitSecret(name string, scope SecretScope, cfg keypairs.Configurable, auth *authentication.Auth) *Secret
InitSecret creates a new secret with the given name and all default settings
func (*Project) IsHeadless ¶
func (*Project) LegacyCommitID ¶
LegacyCommitID is for use by legacy mechanics ONLY
func (*Project) Namespace ¶
func (p *Project) Namespace() *Namespaced
Namespace returns project namespace
func (*Project) NamespaceString ¶
NamespaceString is a convenience function to make interfaces simpler
func (*Project) NewSecret ¶
func (p *Project) NewSecret(s *projectfile.Secret, scope SecretScope, cfg keypairs.Configurable, auth *authentication.Auth) *Secret
NewSecret creates a new secret struct
func (*Project) NormalizedName ¶
NormalizedName returns the project name in a normalized format (alphanumeric, lowercase)
func (*Project) ProjectDir ¶
ProjectDir is an alias for Dir() to satisfy interfaces that may also target the setup.Targeter interface.
func (*Project) ScriptByName ¶
ScriptByName returns a reference to a projectfile.Script with a given name.
func (*Project) SecretByName ¶
func (p *Project) SecretByName(name string, scope SecretScope, cfg keypairs.Configurable, auth *authentication.Auth) *Secret
SecretByName returns a secret matching the given name (if any)
func (*Project) Secrets ¶
func (p *Project) Secrets(cfg keypairs.Configurable, auth *authentication.Auth) []*Secret
Secrets returns a reference to projectfile.Secrets
func (*Project) SetLegacyCommit ¶
func (*Project) Source ¶
func (p *Project) Source() *projectfile.Project
Source returns the source projectfile
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
Script covers the command structure
func (*Script) Description ¶
Description returns script description
func (*Script) LanguageSafe ¶
LanguageSafe returns the first languages of this script. The returned languages are guaranteed to be of a known scripting language
func (*Script) Source ¶
func (script *Script) Source() *projectfile.Project
Source returns the source projectfile
func (*Script) SourceScript ¶
func (script *Script) SourceScript() *projectfile.Script
SourceScript returns the source script
func (*Script) Standalone ¶
Standalone returns if the script is standalone or not
type Secret ¶
type Secret struct {
// contains filtered or unexported fields
}
Secret covers the secret structure
func (*Secret) Description ¶
Description returns secret description
func (*Secret) Source ¶
func (s *Secret) Source() *projectfile.Project
Source returns the source projectfile
func (*Secret) ValueOrNil ¶
ValueOrNil acts as Value() except it can return a nil
type SecretAccess ¶
SecretAccess is used to track secrets that were requested
type SecretExpander ¶
type SecretExpander struct {
// contains filtered or unexported fields
}
SecretExpander takes care of expanding secrets
func NewSecretExpander ¶
func NewSecretExpander(secretsClient *secretsapi.Client, prj *Project, prompt prompt.Prompter, cfg keypairs.Configurable, auth *authentication.Auth) *SecretExpander
NewSecretExpander returns a new instance of SecretExpander
func (*SecretExpander) Expand ¶
func (e *SecretExpander) Expand(_ string, category string, name string, isFunction bool, ctx *Expansion) (string, error)
Expand will expand a variable to a secret value, if no secret exists it will return an empty string
func (*SecretExpander) ExpandWithPrompt ¶
func (e *SecretExpander) ExpandWithPrompt(_ string, category string, name string, isFunction bool, ctx *Expansion) (string, error)
ExpandWithPrompt will expand a variable to a secret value, if no secret exists the user will be prompted
func (*SecretExpander) FetchDefinition ¶
func (e *SecretExpander) FetchDefinition(name string, isUser bool) (*secretsModels.SecretDefinition, error)
FetchDefinition retrieves the definition associated with a secret
func (*SecretExpander) FetchSecret ¶
func (e *SecretExpander) FetchSecret(name string, isUser bool) (string, error)
FetchSecret retrieves the given secret
func (*SecretExpander) FindSecret ¶
func (e *SecretExpander) FindSecret(name string, isUser bool) (*secretsModels.UserSecret, error)
FindSecret will find the secret appropriate for the current project
func (*SecretExpander) KeyPair ¶
func (e *SecretExpander) KeyPair() (keypairs.Keypair, error)
KeyPair acts as a caching layer for secrets.LoadKeypairFromConfigDir, and ensures that we have a projectfile
func (*SecretExpander) Organization ¶
func (e *SecretExpander) Organization() (*mono_models.Organization, error)
Organization acts as a caching layer, and ensures that we have a projectfile
func (*SecretExpander) Project ¶
func (e *SecretExpander) Project() (*mono_models.Project, error)
Project acts as a caching layer, and ensures that we have a projectfile
func (*SecretExpander) Secrets ¶
func (e *SecretExpander) Secrets() ([]*secretsModels.UserSecret, error)
Secrets acts as a caching layer, and ensures that we have a projectfile
func (*SecretExpander) SecretsAccessed ¶
func (e *SecretExpander) SecretsAccessed() []*SecretAccess
SecretsAccessed returns all secrets that were accessed since initialization
type SecretFunc ¶
SecretFunc defines what our expander functions will be returning
type SecretScope ¶
type SecretScope string
SecretScope defines the scope of a secret
const ( // SecretScopeUser defines a secret as being a user secret SecretScopeUser SecretScope = "user" // SecretScopeProject defines a secret as being a Project secret SecretScopeProject SecretScope = "project" )
func NewSecretScope ¶
func NewSecretScope(name string) (SecretScope, error)
NewSecretScope creates a new SecretScope from the given string name and will fail if the given string name does not match one of the available scopes