platformsh

package
v2.2.13 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrProjectNotFound is an error returned when a Platform.sh project is not found.
	ErrProjectNotFound = errors.New("platform.sh project not found")
	// ErrBadAPIResponse is an error returned when an unexpected response is returned from the Platform.sh API.
	ErrBadAPIResponse = errors.New("platform.sh api returned unexpected response")
	// ErrMissingAPIToken is an error returned when the Platform.sh API token is missing.
	ErrMissingAPIToken = errors.New("platform.sh api token not found, please use the platformsh:login command to generate it")
	// ErrInvalidEnvironment is an error returned when an invalid Platform.sh environment is specified.
	ErrInvalidEnvironment = errors.New("invalid platform.sh environment")
	// ErrEnvironmentNotFound is an error returned when a specified Platform.sh environment is not found.
	ErrEnvironmentNotFound = errors.New("platform.sh environment not found")
)

Functions

func FindRoot

func FindRoot(path string) (string, error)

FindRoot returns the root directory for the Platform.sh project.

func GetAPIClient

func GetAPIClient() (*http.Client, error)

GetAPIClient returns the HTTP client used for API transactions.

func Login

func Login() error

Login to Platform.sh API via oauth.

Types

type Environment

type Environment struct {
	Name         string `json:"name"`
	Title        string `json:"title"`
	IsMain       bool   `json:"is_main"`
	Status       string `json:"status"`
	MachineName  string `json:"machine_name"`
	EdgeHostname string `json:"edge_hostname"`
	Links        struct {
		SSHApp struct {
			HREF string `json:"href"`
		} `json:"pf:ssh:app"`
		SSH struct {
			HREF string `json:"href"`
		} `json:"ssh"`
		PublicURL struct {
			HREF string `json:"href"`
		} `json:"public-url"`
	} `json:"_links"`
}

Environment defines a Platform.sh environment.

type Project

type Project struct {
	LocalPath    string
	Host         string
	ID           string
	Title        string
	Environments []Environment
	// contains filtered or unexported fields
}

Project contains information about a Platform.sh project.

func LoadProjectFromPath

func LoadProjectFromPath(path string) (*Project, error)

LoadProjectFromPath returns information about a Platform.sh from a path.

func (*Project) EnvironmentVariable

func (p *Project) EnvironmentVariable(env *Environment, service string, name string) (string, error)

EnvironmentVariable returns the value of the given environment variable.

func (*Project) Fetch

func (p *Project) Fetch() error

Fetch populates project with API data.

func (*Project) FetchEnvironments

func (p *Project) FetchEnvironments() error

FetchEnvironments populates environments list.

func (*Project) GetEnvironment

func (p *Project) GetEnvironment(name string) *Environment

GetEnvironment returns environment matching given name.

func (*Project) PlatformRelationships

func (p *Project) PlatformRelationships(env *Environment, service string) (map[string]interface{}, error)

PlatformRelationships returns the value of then PLATFORM_RELATIONSHIPS environment variable.

func (*Project) PlatformVariables

func (p *Project) PlatformVariables(env *Environment, service string) (map[string]interface{}, error)

PlatformVariables returns the value of then PLATFORM_VARIABLES environment variable.

func (*Project) SSHCertficiate

func (p *Project) SSHCertficiate() ([]byte, error)

SSHCertficiate returns the ssh certficiate to be used with Platform.sh.

func (*Project) SSHCommand

func (p *Project) SSHCommand(env *Environment, service string, command string) ([]byte, error)

SSHCommand sends a command to given Platform.sh environment over SSH and returns the output.

func (*Project) SSHDownload

func (p *Project) SSHDownload(env *Environment, service string, path string) (string, error)

SSHDownload downloads given remote file local and returns path to downloaded file.

func (*Project) SSHTerminal

func (p *Project) SSHTerminal(env *Environment, service string) error

SSHTerminal creates an interactive SSH terminal.

func (Project) SSHUrl

func (p Project) SSHUrl(env *Environment, service string) string

SSHUrl returns the SSH url for the environment.

func (Project) SSHUser

func (p Project) SSHUser(env *Environment, service string) string

SSHUser returns the SSH username for given environment and service.

func (Project) SSHWorkerURL

func (p Project) SSHWorkerURL(env *Environment, service string, worker string) string

SSHWorkerURL returns the SSH url for a worker in the environment.

func (*Project) Variables

func (p *Project) Variables(env *Environment, service string) (map[string]string, error)

Variables returns list of variables for given platform.sh environment.

Jump to

Keyboard shortcuts

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