Documentation ¶
Index ¶
- Constants
- Variables
- func AddLockInfo(projectFilePath, branch, version string) error
- func CleanProjectMapping(cfg ConfigGetter)
- func GetCachedProjectNameForPath(config ConfigGetter, projectPath string) string
- func GetProjectFileMapping(config ConfigGetter) map[string][]*Project
- func GetProjectFilePath() (string, error)
- func GetProjectMapping(config ConfigGetter) map[string][]string
- func GetProjectPaths(cfg ConfigGetter, namespace string) []string
- func GetStaleProjectMapping(config ConfigGetter) map[string][]string
- func NewProjectField() *projectField
- func NewYamlField(field string, value interface{}) *yamlField
- func RegisterMigrator(m MigratorFunc)
- func RemoveLockInfo(projectFilePath string) error
- func SetRecentlyUsedNamespace(cfg ConfigGetter, namespace string)
- func StoreProjectMapping(cfg ConfigGetter, namespace, projectPath string)
- func ValidateProjectURL(url string) error
- type Build
- type Conditional
- type ConfigGetter
- type Constant
- type ConstantFields
- type Constants
- type ConstrainedEntity
- type CreateParams
- type ErrorNoDefaultProject
- type ErrorNoProject
- type ErrorNoProjectFromEnv
- type ErrorParseProject
- type Event
- type EventFields
- type Events
- type Job
- type Jobs
- type MigratorFunc
- type NameVal
- type Package
- type Packages
- type Project
- func (p *Project) BranchName() string
- func (p *Project) Channel() string
- func (p *Project) Dir() string
- func (p *Project) Init() error
- func (p *Project) LegacyCommitID() string
- func (p *Project) Name() string
- func (p *Project) Owner() string
- func (p *Project) Path() string
- func (p *Project) Reload() error
- func (p *Project) Save(cfg ConfigGetter) error
- func (p *Project) SetBranch(branch string) error
- func (p *Project) SetLegacyCommit(commitID string) error
- func (p *Project) SetNamespace(owner, project string) error
- func (p *Project) SetPath(path string)
- func (p *Project) URL() string
- func (p *Project) Version() string
- type ProjectSimple
- type Script
- type ScriptFields
- type Scripts
- type Secret
- type SecretScopes
- type Secrets
- type VersionInfo
Constants ¶
const ConfigVersion = 1
const LocalProjectsConfigKey = "projects"
Variables ¶
var ( // ProjectURLRe Regex used to validate project fields /orgname/projectname[?commitID=someUUID] ProjectURLRe = regexp.MustCompile(urlProjectRegexStr) // CommitURLRe Regex used to validate commit info /commit/someUUID CommitURLRe = regexp.MustCompile(urlCommitRegexStr) )
Functions ¶
func AddLockInfo ¶
AddLockInfo adds the lock field to activestate.yaml
func CleanProjectMapping ¶
func CleanProjectMapping(cfg ConfigGetter)
CleanProjectMapping removes projects that no longer exist on a user's filesystem from the projects config entry
func GetCachedProjectNameForPath ¶
func GetCachedProjectNameForPath(config ConfigGetter, projectPath string) string
func GetProjectFileMapping ¶
func GetProjectFileMapping(config ConfigGetter) map[string][]*Project
func GetProjectFilePath ¶
GetProjectFilePath returns the path to the project activestate.yaml It considers projects in the following order: 1. Environment variable (e.g. `state shell` sets one) 2. Working directory (i.e. walk up directory tree looking for activestate.yaml) 3. Fall back on default project
func GetProjectMapping ¶
func GetProjectMapping(config ConfigGetter) map[string][]string
func GetProjectPaths ¶
func GetProjectPaths(cfg ConfigGetter, namespace string) []string
GetProjectPaths returns the paths of all projects associated with the namespace
func GetStaleProjectMapping ¶
func GetStaleProjectMapping(config ConfigGetter) map[string][]string
GetStaleProjectMapping returns a project mapping from the last time the state tool was run. This mapping could include projects that are no longer on the system.
func NewProjectField ¶
func NewProjectField() *projectField
func NewYamlField ¶
func NewYamlField(field string, value interface{}) *yamlField
func RegisterMigrator ¶
func RegisterMigrator(m MigratorFunc)
func RemoveLockInfo ¶
func SetRecentlyUsedNamespace ¶
func SetRecentlyUsedNamespace(cfg ConfigGetter, namespace string)
func StoreProjectMapping ¶
func StoreProjectMapping(cfg ConfigGetter, namespace, projectPath string)
StoreProjectMapping associates the namespace with the project path in the config
func ValidateProjectURL ¶
ValidateProjectURL validates the configured project URL
Types ¶
type Build ¶
Build covers the build map, which can go under languages or packages Build can hold variable keys, so we cannot predict what they are, hence why it is a map
type Conditional ¶
type Conditional string
Conditional is an `if` conditional that when evalutes to true enables the entity its under it is meant to replace Constraints
type ConfigGetter ¶
type Constant ¶
type Constant struct { NameVal `yaml:",inline"` ConstantFields `yaml:",inline"` }
Constant covers the constant structure, which goes under Project
func MakeConstantsFromConstrainedEntities ¶
func MakeConstantsFromConstrainedEntities(items []ConstrainedEntity) (constants []*Constant)
MakeConstantsFromConstrainedEntities unboxes ConstraintedEntities as Constants
func (*Constant) ConditionalFilter ¶
func (c *Constant) ConditionalFilter() Conditional
func (*Constant) UnmarshalYAML ¶
type ConstantFields ¶
type ConstantFields struct {
Conditional Conditional `yaml:"if,omitempty"`
}
ConstantFields are the common fields for the Constant type. This is required for type composition related to its yaml.Unmarshaler implementation.
type Constants ¶
type Constants []*Constant
Constants is a slice of constant values
func (Constants) AsConstrainedEntities ¶
func (constants Constants) AsConstrainedEntities() (items []ConstrainedEntity)
AsConstrainedEntities boxes constants as a slice ConstrainedEntities
type ConstrainedEntity ¶
type ConstrainedEntity interface { // ID returns the name of the entity ID() string ConditionalFilter() Conditional }
ConstrainedEntity is an entity in a project file that can be filtered with constraints
type CreateParams ¶
type CreateParams struct { Owner string Project string BranchName string Directory string Content string Language string Private bool ProjectURL string Cache string Portable bool // contains filtered or unexported fields }
CreateParams are parameters that we create a custom activestate.yaml file from
type ErrorNoDefaultProject ¶
type ErrorNoDefaultProject struct{ *locale.LocalizedError }
type ErrorNoProject ¶
type ErrorNoProject struct{ *locale.LocalizedError }
type ErrorNoProjectFromEnv ¶
type ErrorNoProjectFromEnv struct{ *locale.LocalizedError }
type ErrorParseProject ¶
type ErrorParseProject struct{ *locale.LocalizedError }
type Event ¶
type Event struct { NameVal `yaml:",inline"` EventFields `yaml:",inline"` }
Event covers the event structure, which goes under Project
func MakeEventsFromConstrainedEntities ¶
func MakeEventsFromConstrainedEntities(items []ConstrainedEntity) (events []*Event)
MakeEventsFromConstrainedEntities unboxes ConstraintedEntities as Events
func (Event) ConditionalFilter ¶
func (e Event) ConditionalFilter() Conditional
func (*Event) UnmarshalYAML ¶
type EventFields ¶
type EventFields struct { Scope []string `yaml:"scope"` Conditional Conditional `yaml:"if,omitempty"` // contains filtered or unexported fields }
EventFields are the common fields for the Event type. This is required for type composition related to its yaml.Unmarshaler implementation.
type Events ¶
type Events []Event
Events is a slice of Event definitions
func (Events) AsConstrainedEntities ¶
func (events Events) AsConstrainedEntities() (items []ConstrainedEntity)
AsConstrainedEntities boxes events as a slice of ConstrainedEntities
type Job ¶
type Job struct { Name string `yaml:"name"` Constants []string `yaml:"constants"` Scripts []string `yaml:"scripts"` }
Job covers the job structure, which goes under Project
type NameVal ¶
func (*NameVal) UnmarshalYAML ¶
type Package ¶
type Package struct { Name string `yaml:"name"` Version string `yaml:"version"` Conditional Conditional `yaml:"if,omitempty"` Build Build `yaml:"build,omitempty"` }
Package covers the package structure, which goes under the language struct
func MakePackagesFromConstrainedEntities ¶
func MakePackagesFromConstrainedEntities(items []ConstrainedEntity) (packages []*Package)
MakePackagesFromConstrainedEntities unboxes ConstraintedEntities as Packages
func (Package) ConditionalFilter ¶
func (p Package) ConditionalFilter() Conditional
type Packages ¶
type Packages []Package
Packages is a slice of Package configurations
func (Packages) AsConstrainedEntities ¶
func (packages Packages) AsConstrainedEntities() (items []ConstrainedEntity)
AsConstrainedEntities boxes Packages as a slice of ConstrainedEntities
type Project ¶
type Project struct { Project string `yaml:"project"` ConfigVersion int `yaml:"config_version"` Lock string `yaml:"lock,omitempty"` Environments string `yaml:"environments,omitempty"` Constants Constants `yaml:"constants,omitempty"` Secrets *SecretScopes `yaml:"secrets,omitempty"` Events Events `yaml:"events,omitempty"` Scripts Scripts `yaml:"scripts,omitempty"` Jobs Jobs `yaml:"jobs,omitempty"` Private bool `yaml:"private,omitempty"` Cache string `yaml:"cache,omitempty"` Portable bool `yaml:"portable,omitempty"` // contains filtered or unexported fields }
Project covers the top level project structure of our yaml
func Create ¶
func Create(params *CreateParams) (*Project, error)
Create will create a new activestate.yaml with a projectURL for the given details
func FromEnv ¶
FromEnv returns the project configuration based on environment information (env vars, cwd, etc)
func FromExactPath ¶
FromExactPath will return the projectfile that's located at the given path without walking up the directory tree
func FromPath ¶
FromPath will return the projectfile that's located at the given path (this will walk up the directory tree until it finds the project)
func (*Project) BranchName ¶
BranchName returns the branch name specified in the project
func (*Project) LegacyCommitID ¶
LegacyCommitID is for use by legacy mechanics ONLY It returns a pre-migrated project's commit ID from activestate.yaml.
func (*Project) Save ¶
func (p *Project) Save(cfg ConfigGetter) error
Save the project to its activestate.yaml file
func (*Project) SetBranch ¶
SetBranch sets the branch within the current project file. This is done in-place so that line order is preserved.
func (*Project) SetLegacyCommit ¶
SetLegacyCommit sets the commit id within the current project file. This is done in-place so that line order is preserved.
func (*Project) SetNamespace ¶
SetNamespace updates the namespace in the project file
func (*Project) SetPath ¶
SetPath sets the path of the project file and should generally only be used by tests
type ProjectSimple ¶
type ProjectSimple struct {
Project string `yaml:"project"`
}
ProjectSimple reflects a bare basic project structure
type Script ¶
type Script struct { NameVal `yaml:",inline"` ScriptFields `yaml:",inline"` }
Script covers the script structure, which goes under Project
func MakeScriptsFromConstrainedEntities ¶
func MakeScriptsFromConstrainedEntities(items []ConstrainedEntity) (scripts []*Script)
MakeScriptsFromConstrainedEntities unboxes ConstraintedEntities as Scripts
func (Script) ConditionalFilter ¶
func (s Script) ConditionalFilter() Conditional
func (*Script) UnmarshalYAML ¶
type ScriptFields ¶
type ScriptFields struct { Description string `yaml:"description,omitempty"` Filename string `yaml:"filename,omitempty"` Standalone bool `yaml:"standalone,omitempty"` Language string `yaml:"language,omitempty"` Conditional Conditional `yaml:"if,omitempty"` }
ScriptFields are the common fields for the Script type. This is required for type composition related to its yaml.Unmarshaler implementation.
type Scripts ¶
type Scripts []Script
Scripts is a slice of scripts
func (Scripts) AsConstrainedEntities ¶
func (scripts Scripts) AsConstrainedEntities() (items []ConstrainedEntity)
AsConstrainedEntities boxes scripts as a slice of ConstrainedEntities
type Secret ¶
type Secret struct { Name string `yaml:"name"` Description string `yaml:"description"` Conditional Conditional `yaml:"if,omitempty"` }
Secret covers the variable structure, which goes under Project
func MakeSecretsFromConstrainedEntities ¶
func MakeSecretsFromConstrainedEntities(items []ConstrainedEntity) (secrets []*Secret)
MakeSecretsFromConstrainedEntities unboxes ConstraintedEntities as Secrets
func (*Secret) ConditionalFilter ¶
func (s *Secret) ConditionalFilter() Conditional
type SecretScopes ¶
type SecretScopes struct { User Secrets `yaml:"user,omitempty"` Project Secrets `yaml:"project,omitempty"` }
SecretScopes holds secret scopes, scopes define what the secrets belong to
type Secrets ¶
type Secrets []*Secret
Secrets is a slice of Secret definitions
func (Secrets) AsConstrainedEntities ¶
func (secrets Secrets) AsConstrainedEntities() (items []ConstrainedEntity)
AsConstrainedEntities box Secrets as a slice of ConstrainedEntities
type VersionInfo ¶
type VersionInfo struct { Channel string `yaml:"branch"` // branch for backward compatibility Version string Lock string `yaml:"lock"` }
VersionInfo is used in cases where we only care about parsing the version and channel fields. In all other cases the version is parsed via the Project struct
func ParseLock ¶
func ParseLock(lock string) (*VersionInfo, error)
func ParseVersionInfo ¶
func ParseVersionInfo(projectFilePath string) (*VersionInfo, error)
ParseVersionInfo parses the lock field from the projectfile and updates the activestate.yaml if an older version representation is present