Documentation ¶
Overview ¶
Package project provides tools to run a Platform.sh local development environment.
Index ¶
- Constants
- Variables
- func GetDatabaseTypeNames() []string
- func GetDefinitionEmptyRelationship(d interface{}) map[string]interface{}
- func ListOptionDescription() map[Option]string
- func MatchDatabaseTypeName(name string) int
- type Container
- func (c Container) Build() error
- func (c Container) Commit() error
- func (c Container) DeleteCommit() error
- func (c Container) Deploy() error
- func (c Container) Download(path string, writer io.Writer) error
- func (c Container) DownloadMulti(path string, writer io.Writer) error
- func (c Container) HasBuild() bool
- func (c Container) Log() error
- func (c Container) LogStdout(follow bool) error
- func (c Container) Open() ([]map[string]interface{}, error)
- func (c Container) PostDeploy() error
- func (c Container) SetupMounts() error
- func (c Container) Shell(user string, cmd []string) (int, error)
- func (c Container) Start() error
- func (c Container) Upload(path string, reader io.ReadSeeker) error
- func (c Container) UploadMulti(path string, reader io.Reader) error
- type FlagInt
- type Flags
- func (f Flags) Descriptions() map[string]string
- func (f Flags) Get(name string) int
- func (f Flags) GetValueName(name string) string
- func (f Flags) IsOff(name string) bool
- func (f Flags) IsOn(name string) bool
- func (f Flags) IsSet(name string) bool
- func (f Flags) IsUnset(name string) bool
- func (f Flags) IsValidFlag(name string) bool
- func (f *Flags) Set(name string, value int)
- func (f *Flags) UnmarshalJSON(data []byte) error
- type Option
- type Project
- func (p *Project) Build(force bool) error
- func (p *Project) BuildConfigJSON(d interface{}) ([]byte, error)
- func (p *Project) CopySlot(destSlot int) error
- func (p *Project) Deploy() error
- func (p *Project) FlagSource(name string) string
- func (p *Project) GetDatabaseDumpCommand(d interface{}, database string) string
- func (p *Project) GetDatabaseShellCommand(d interface{}, database string) string
- func (p *Project) GetDefinitionBinds(d interface{}) map[string]string
- func (p *Project) GetDefinitionBuildCommand(d interface{}) string
- func (p *Project) GetDefinitionContainerType(d interface{}) container.ObjectContainerType
- func (p *Project) GetDefinitionEnvironmentVariables(d interface{}) map[string]string
- func (p *Project) GetDefinitionHostName(d interface{}) string
- func (p *Project) GetDefinitionImages(d interface{}) []string
- func (p *Project) GetDefinitionInitCommand(d interface{}) string
- func (p *Project) GetDefinitionMountCommand(d interface{}) string
- func (p *Project) GetDefinitionName(d interface{}) string
- func (p *Project) GetDefinitionPatch(d interface{}) string
- func (p *Project) GetDefinitionPostBuildPatch(d interface{}) string
- func (p *Project) GetDefinitionPostDeployCommand(d interface{}) string
- func (p *Project) GetDefinitionRelationships(d interface{}) map[string][]map[string]interface{}
- func (p *Project) GetDefinitionStartCommand(d interface{}) []string
- func (p *Project) GetDefinitionStartOrder(defs []interface{}) ([]interface{}, error)
- func (p *Project) GetDefinitionType(d interface{}) string
- func (p *Project) GetDefinitionVariables(d interface{}) map[string]interface{}
- func (p *Project) GetDefinitionVolumes(d interface{}) map[string]string
- func (p *Project) GetOption(o Option) string
- func (p *Project) GetPlatformApplication(d interface{}) string
- func (p *Project) GetPlatformEntropy() string
- func (p *Project) GetPlatformEnvironmentVariables(d interface{}) map[string]string
- func (p *Project) GetPlatformRelationships(d interface{}) string
- func (p *Project) GetPlatformRoutes() string
- func (p *Project) GetPlatformSHDatabaseDumpCommand(d interface{}, database string, rels map[string]interface{}) string
- func (p *Project) GetPlatformVariables(d interface{}) string
- func (p *Project) HasFlag(name string) bool
- func (p *Project) Load() error
- func (p *Project) NewContainer(d interface{}) Container
- func (p *Project) OptionSource(o Option) string
- func (p *Project) PlatformSHSyncDatabases(envName string) error
- func (p *Project) PlatformSHSyncMounts(envName string) error
- func (p *Project) PlatformSHSyncVariables(envName string) error
- func (p *Project) PostDeploy() error
- func (p *Project) Pull() error
- func (p *Project) Purge() error
- func (p *Project) PurgeSlot() error
- func (p *Project) ReplaceDefault(path string) string
- func (p *Project) RouteReplaceDefault(r def.Route) def.Route
- func (p *Project) RoutesReplaceDefault(routes []def.Route) []def.Route
- func (p *Project) Save() error
- func (p *Project) SetContainerHandler(c container.Interface)
- func (p *Project) SetDefaultRegistry(registry string) error
- func (p *Project) SetGlobalConfig(gc def.GlobalConfig)
- func (p *Project) SetNoBuild()
- func (p *Project) SetNoCommit()
- func (p *Project) SetSlot(slot int)
- func (p *Project) Start() error
- func (p *Project) Status() []container.Status
- func (p *Project) Stop() error
- func (p *Project) Validate() []error
- func (p *Project) VarDelete(key string) error
- func (p *Project) VarGet(key string) (string, error)
- func (p *Project) VarSet(key string, value string) error
Constants ¶
const ( // FlagUnset signifies that flag has not been set by user. FlagUnset = 0 // FlagOff signifies that flag is set to off. FlagOff = 1 // FlagOn signifies that flag is set to on. FlagOn = 2 )
const ( // EnableCron enables cron jobs. EnableCron = "enable_cron" // EnableWorkers enables workers. EnableWorkers = "enable_workers" // EnableServiceRoutes enables routes to services like Varnish. EnableServiceRoutes = "enable_service_routes" // EnablePHPOpcache enables PHP opcache. EnablePHPOpcache = "enable_php_opcache" // EnableOSXNFSMounts uses NFS for mounts on OSX. EnableOSXNFSMounts = "enable_osx_nfs_mounts" // DisableYamlOverrides disables Platform.CC specific YAML override files. DisableYamlOverrides = "disable_yaml_overrides" // DisableAutoCommit disables automatic commit of application container. DisableAutoCommit = "disable_auto_commit" DisableSharedGlobalVolume = "disable_shared_global_volume" )
const ( // FlagSourceLocal defines a flag specific to the project. FlagSourceLocal = "project" // FlagSourceGlobal defines a flag set for all projects. FlagSourceGlobal = "global" // FlagSourceNone defines a flag that has not been set. FlagSourceNone = "unset" )
const ( // MountStrategyNone defines mount strategy where no action is taken. MountStrategyNone = "none" // MountStrategySymlink defines mount strategy where symlinks are used. MountStrategySymlink = "symlink" // MountStrategyVolume defines mount strategy where a container volume is used. MountStrategyVolume = "volume" )
const ( // OptionSourceLocal defines option source as local to current project. OptionSourceLocal = "local" // OptionSourceGlobal defines option source as global to the user. OptionSourceGlobal = "global" // OptionSourceNone defines option source as not set. OptionSourceNone = "unset" )
Variables ¶
var ( // ErrContainerNoIP is an error returned when a container has no IP address. ErrContainerNoIP = errors.New("container has no ip address") // ErrInvalidRelationship is an error returned when Platform.sh relationships are invalid. ErrInvalidRelationship = errors.New("one or more relationships are invalid") // ErrNoApplicationFound is an error returned when a project has no applications. ErrNoApplicationFound = errors.New("project should have at least one application") // ErrInvalidDefinition is an error returned when a service definition is invalid. ErrInvalidDefinition = errors.New("invalid definition") // ErrContainerRunning is returned when attempting to start an already running container. ErrContainerRunning = errors.New("container already running") // ErrRegistryNotDefined is returned when a registry is not defined. ErrRegistryNotDefined = errors.New("registry not defined") )
Functions ¶
func GetDatabaseTypeNames ¶
func GetDatabaseTypeNames() []string
GetDatabaseTypeNames returns list of all service types that are considered to be a database.
func GetDefinitionEmptyRelationship ¶
func GetDefinitionEmptyRelationship(d interface{}) map[string]interface{}
GetDefinitionEmptyRelationship returns a relationship template/empty for given definition.
func ListOptionDescription ¶
ListOptionDescription returns a mapping of option name to its description.
func MatchDatabaseTypeName ¶
MatchDatabaseTypeName matches given service type with database service type.
Types ¶
type Container ¶
type Container struct { Config container.Config Name string Definition interface{} Relationships map[string][]map[string]interface{} // contains filtered or unexported fields }
Container contains information needed to run a container.
func (Container) DeleteCommit ¶
DeleteCommit deletes the commit image.
func (Container) DownloadMulti ¶
DownloadMulti downloads container path and writes to given writer as tarball.
func (Container) PostDeploy ¶
PostDeploy runs the post deploy hooks.
func (Container) SetupMounts ¶
SetupMounts sets up mounts in container.
type FlagInt ¶
type FlagInt uint8
FlagInt defines flag for enabled features. This is the old version that uses bitmasks.
const ( // IntEnableCron enables cron jobs. IntEnableCron FlagInt = 1 << iota // IntEnableWorkers enables workers. IntEnableWorkers // IntEnableServiceRoutes enables routes to services like Varnish. IntEnableServiceRoutes // IntEnablePHPOpcache enables PHP opcache. IntEnablePHPOpcache // IntEnableMountVolume mounts Docker volume for Platform.sh mounts (NO LONGER USED). IntEnableMountVolume // IntEnableOSXNFSMounts uses NFS for mounts on OSX. IntEnableOSXNFSMounts // IntDisableYamlOverrides disables Platform.CC specific YAML override files. IntDisableYamlOverrides // IntDisableAutoCommit disables automatic commit of application container. IntDisableAutoCommit )
type Flags ¶
Flags defines flags that enable features.
func (Flags) Descriptions ¶
Descriptions returns a mapping of flag name to its description.
func (Flags) GetValueName ¶
GetValueName returns value of flag as a human readable string.
func (Flags) IsValidFlag ¶
IsValidFlag returns true if given flag is valid.
func (*Flags) UnmarshalJSON ¶
UnmarshalJSON implements Unmarshaler interface.
type Option ¶
type Option string
Option defines a project option.
func (Option) DefaultValue ¶
DefaultValue returns the default value of the option.
type Project ¶
type Project struct { ID string `json:"id"` Path string `json:"-"` Apps []def.App `json:"-"` Routes []def.Route `json:"-"` Services []def.Service `json:"-"` Variables def.Variables `json:"vars"` Flags Flags `json:"flags"` // local project flags Options map[Option]string `json:"options"` // local project options PlatformSH *platformsh.Project `json:"-"` // contains filtered or unexported fields }
Project defines a platform.sh/cc project.
func LoadFromPath ¶
LoadFromPath loads a project from its path.
func (*Project) BuildConfigJSON ¶
BuildConfigJSON makes config.json for container runtime.
func (*Project) FlagSource ¶
FlagSource returns the source of the given flag.
func (*Project) GetDatabaseDumpCommand ¶
GetDatabaseDumpCommand returns the command to dump a database for given definition.
func (*Project) GetDatabaseShellCommand ¶
GetDatabaseShellCommand returns the command to access the database shell for given definition.
func (*Project) GetDefinitionBinds ¶
GetDefinitionBinds returns list of Docker binds for given definition.
func (*Project) GetDefinitionBuildCommand ¶
GetDefinitionBuildCommand returns build command for given definition.
func (*Project) GetDefinitionContainerType ¶
func (p *Project) GetDefinitionContainerType(d interface{}) container.ObjectContainerType
GetDefinitionContainerType returns the container type for given definition.
func (*Project) GetDefinitionEnvironmentVariables ¶
GetDefinitionEnvironmentVariables returns list of environment variables for given definition.
func (*Project) GetDefinitionHostName ¶
GetDefinitionHostName returns the host name for the container of the given definition.
func (*Project) GetDefinitionImages ¶ added in v2.2.10
GetDefinitionImages returns the container image for the given definition.
func (*Project) GetDefinitionInitCommand ¶
GetDefinitionInitCommand returns the initalization command fdor the given definition.
func (*Project) GetDefinitionMountCommand ¶
GetDefinitionMountCommand returns command to setup mounts for given definition.
func (*Project) GetDefinitionName ¶
GetDefinitionName returns the name of given definition.
func (*Project) GetDefinitionPatch ¶
GetDefinitionPatch returns patch command to for given definition.
func (*Project) GetDefinitionPostBuildPatch ¶ added in v2.2.7
GetDefinitionPostBuildPatch returns post-build patch command to for given definition.
func (*Project) GetDefinitionPostDeployCommand ¶
GetDefinitionPostDeployCommand returns post deploy command for given definition.
func (*Project) GetDefinitionRelationships ¶
GetDefinitionRelationships returns relationships for given definition.
func (*Project) GetDefinitionStartCommand ¶
GetDefinitionStartCommand returns the start command for the given definition.
func (*Project) GetDefinitionStartOrder ¶
GetDefinitionStartOrder given list of definitions reorder them for optimal start order for relationships.
func (*Project) GetDefinitionType ¶
GetDefinitionType returns the service type for the given definition.
func (*Project) GetDefinitionVariables ¶
GetDefinitionVariables returns flattened variables for given definition.
func (*Project) GetDefinitionVolumes ¶
GetDefinitionVolumes returns list of Docker volumes for given definition.
func (*Project) GetOption ¶
GetOption returns the given option value globally or local to the project.
func (*Project) GetPlatformApplication ¶
GetPlatformApplication returns the PLATFORM_APPLICATION environment variable.
func (*Project) GetPlatformEntropy ¶
GetPlatformEntropy returns the PLATFORM_ENTROPY environment variable.
func (*Project) GetPlatformEnvironmentVariables ¶
GetPlatformEnvironmentVariables returns a map of all PLATFORM_ environment variables.
func (*Project) GetPlatformRelationships ¶
GetPlatformRelationships returns the PLATFORM_RELATIONSHIPS environment variable.
func (*Project) GetPlatformRoutes ¶
GetPlatformRoutes returns the PLATFORM_ROUTES environment variable.
func (*Project) GetPlatformSHDatabaseDumpCommand ¶
func (p *Project) GetPlatformSHDatabaseDumpCommand(d interface{}, database string, rels map[string]interface{}) string
GetPlatformSHDatabaseDumpCommand returns the command to dump a database from Platform.sh for given definition.
func (*Project) GetPlatformVariables ¶
GetPlatformVariables returns the PLATFORM_VARIABLES environment variable.
func (*Project) HasFlag ¶
HasFlag returns true if given flag is on globally or locally to the project.
func (*Project) NewContainer ¶
NewContainer creates a new container.
func (*Project) OptionSource ¶
OptionSource returns the source of given option.
func (*Project) PlatformSHSyncDatabases ¶
PlatformSHSyncDatabases syncs the given platform.sh environment's databases to the local project.
func (*Project) PlatformSHSyncMounts ¶
PlatformSHSyncMounts syncs the given platform.sh environment's mounts to the local project.
func (*Project) PlatformSHSyncVariables ¶
PlatformSHSyncVariables syncs the given platform.sh environment's variables to the local project.
func (*Project) PostDeploy ¶
PostDeploy runs post-deploy hooks for all applications in the project.
func (*Project) ReplaceDefault ¶
ReplaceDefault replaces {default} in given path with project id + domain suffix.
func (*Project) RouteReplaceDefault ¶
RouteReplaceDefault replaces {default} values in all paths.
func (*Project) RoutesReplaceDefault ¶
RoutesReplaceDefault replaces {default} values in all paths for multiple routes.
func (*Project) SetContainerHandler ¶
SetContainerHandler sets the container handler.
func (*Project) SetDefaultRegistry ¶ added in v2.2.10
SetDefaultRegistry sets the default registry.
func (*Project) SetGlobalConfig ¶
func (p *Project) SetGlobalConfig(gc def.GlobalConfig)
SetGlobalConfig sets the global config, used for testing.