pshgo

package module
v0.0.0-...-f0d5876 Latest Latest
Warning

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

Go to latest
Published: May 23, 2019 License: MIT Imports: 16 Imported by: 0

README

PSHGO

pshgo is a go package for the Platform.sh hosted environment.

Example

Detailed examples of pshgo are available on the example site.

Documentation

Overview

pshgo provides strongly typed models for the Platform.sh environment

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAppCommand

func GetAppCommand(p PlatformProvider) string

func GetAppDir

func GetAppDir(p PlatformProvider) string

func GetAppName

func GetAppName(p PlatformProvider) string

func GetApplicationCommand

func GetApplicationCommand(p PlatformProvider) string

func GetApplicationName

func GetApplicationName(p PlatformProvider) string

func GetBranch

func GetBranch(p PlatformProvider) string

func GetDir

func GetDir(p PlatformProvider) string

func GetDocumentRoot

func GetDocumentRoot(p PlatformProvider) string

func GetEnvironment

func GetEnvironment(p PlatformProvider) string

func GetPort

func GetPort(p PlatformProvider) string

func GetProject

func GetProject(p PlatformProvider) string

func GetProjectEntropy

func GetProjectEntropy(p PlatformProvider) string

func GetSMTPHost

func GetSMTPHost(p PlatformProvider) string

func GetSocket

func GetSocket(p PlatformProvider) string

func GetTreeID

func GetTreeID(p PlatformProvider) string

func GetXClientCert

func GetXClientCert(p PlatformProvider) string

func GetXClientDN

func GetXClientDN(p PlatformProvider) string

func GetXClientIP

func GetXClientIP(p PlatformProvider) string

func GetXClientVerify

func GetXClientVerify(p PlatformProvider) string

func LookupAppCommand

func LookupAppCommand(p PlatformProvider) (string, bool)

func LookupAppDir

func LookupAppDir(p PlatformProvider) (string, bool)

func LookupAppName

func LookupAppName(p PlatformProvider) (string, bool)

func LookupApplicationCommand

func LookupApplicationCommand(p PlatformProvider) (string, bool)

func LookupApplicationName

func LookupApplicationName(p PlatformProvider) (string, bool)

func LookupBranch

func LookupBranch(p PlatformProvider) (string, bool)

func LookupDir

func LookupDir(p PlatformProvider) (string, bool)

func LookupDocumentRoot

func LookupDocumentRoot(p PlatformProvider) (string, bool)

func LookupEnvironment

func LookupEnvironment(p PlatformProvider) (string, bool)

func LookupPort

func LookupPort(p PlatformProvider) (string, bool)

func LookupProject

func LookupProject(p PlatformProvider) (string, bool)

func LookupProjectEntropy

func LookupProjectEntropy(p PlatformProvider) (string, bool)

func LookupSMTPHost

func LookupSMTPHost(p PlatformProvider) (string, bool)

func LookupSocket

func LookupSocket(p PlatformProvider) (string, bool)

func LookupTreeID

func LookupTreeID(p PlatformProvider) (string, bool)

func LookupXClientCert

func LookupXClientCert(p PlatformProvider) (string, bool)

func LookupXClientDN

func LookupXClientDN(p PlatformProvider) (string, bool)

func LookupXClientIP

func LookupXClientIP(p PlatformProvider) (string, bool)

func LookupXClientVerify

func LookupXClientVerify(p PlatformProvider) (string, bool)

Types

type Access

type Access map[AccessType]AccessLevel

type AccessLevel

type AccessLevel uint8
const (
	AccessLevelViewer AccessLevel = iota
	AccessLevelContributor
	AccessLevelAdmin
)

func NewAccessLevel

func NewAccessLevel(name string) (AccessLevel, error)

func (AccessLevel) MarshalText

func (v AccessLevel) MarshalText() ([]byte, error)

func (AccessLevel) String

func (v AccessLevel) String() string

func (*AccessLevel) UnmarshalText

func (v *AccessLevel) UnmarshalText(text []byte) (err error)

type AccessType

type AccessType uint8
const (
	AccessTypeSSH AccessType = iota
)

func NewAccessType

func NewAccessType(name string) (AccessType, error)

func (AccessType) MarshalText

func (v AccessType) MarshalText() ([]byte, error)

func (AccessType) String

func (v AccessType) String() string

func (*AccessType) UnmarshalText

func (v *AccessType) UnmarshalText(text []byte) (err error)

type Application

type Application struct {
	ApplicationCore
	Web     Web     `json:"web"`
	Hooks   Hooks   `json:"hooks"`
	Crons   Crons   `json:"crons"`
	Workers Workers `json:"workers"`
	TreeID  string  `json:"tree_id"`
	SlugID  string  `json:"slug_id"`
	AppDir  string  `json:"app_dir"`
}

func GetApplication

func GetApplication(p PlatformProvider) *Application

func LookupApplication

func LookupApplication(p PlatformProvider) (*Application, bool)

type ApplicationBase

type ApplicationBase struct {
	Size          ServiceSize `json:"size"`
	Disk          uint32      `json:"disk"`
	Access        Access      `json:"access"`
	Relationships StringMap   `json:"relationships"`
	Mounts        Mounts      `json:"mounts"`
	Timezone      string      `json:"timezone"` // TODO: replace with serializable time.Location
	Variables     Variables   `json:"variables"`
}

type ApplicationBuilder

type ApplicationBuilder struct {
	ApplicationCore
	Dependencies JSONObject `json:"dependencies"`
	Build        Build      `json:"build"`
	Source       Source     `json:"source"`
}

type ApplicationCore

type ApplicationCore struct {
	ApplicationBase
	Name      string      `json:"name"`
	Type      string      `json:"type"`
	Runtime   interface{} `json:"runtime"`
	Preflight Preflight   `json:"preflight"`
}

type ApplicationMount

type ApplicationMount uint8
const (
	ApplicationMountLocal ApplicationMount = iota
	ApplicationMountTemp
	ApplicationMountService
)

func NewApplicationMount

func NewApplicationMount(name string) (ApplicationMount, error)

func (ApplicationMount) MarshalText

func (v ApplicationMount) MarshalText() ([]byte, error)

func (ApplicationMount) String

func (v ApplicationMount) String() string

func (*ApplicationMount) UnmarshalText

func (v *ApplicationMount) UnmarshalText(text []byte) (err error)

type Build

type Build struct {
	Flavor string `json:"flavor"`
	Caches Caches `json:"caches"`
}

type Cache

type Cache struct {
	Enabled    bool     `json:"enabled"`
	DefaultTTL int      `json:"default_ttl"`
	Cookies    []string `json:"cookies"`
	Headers    []string `json:"headers"`
}

type CacheConfiguration

type CacheConfiguration struct {
	Directory        string   `json:"directory"`
	Watch            []string `json:"watch"`
	AllowStale       bool     `json:"allow_stale"`
	ShareBetweenApps bool     `json:"share_between_apps"`
}

type Caches

type Caches map[string]CacheConfiguration

type Certificate

type Certificate struct {
	*x509.Certificate
}

func (Certificate) MarshalText

func (v Certificate) MarshalText() ([]byte, error)

func (*Certificate) UnmarshalText

func (v *Certificate) UnmarshalText(text []byte) error

type Commands

type Commands struct {
	Start string `json:"start"`
	Stop  string `json:"stop,omitempty"`
}

type Cron

type Cron struct {
	Spec string `json:"spec"`
	Cmd  string `json:"cmd"`
}

type Crons

type Crons map[string]Cron

type Duration

type Duration struct {
	time.Duration
}

func (Duration) MarshalText

func (v Duration) MarshalText() ([]byte, error)

func (*Duration) UnmarshalText

func (v *Duration) UnmarshalText(text []byte) (err error)

type Environment

type Environment struct {
	// contains filtered or unexported fields
}

func NewEnvironment

func NewEnvironment(prefix string) *Environment

func NewEnvironmentWithProvider

func NewEnvironmentWithProvider(prefix string, p Provider) *Environment

func (*Environment) Environ

func (e *Environment) Environ() []string

func (*Environment) GetAppCommand

func (e *Environment) GetAppCommand() string

func (*Environment) GetAppDir

func (e *Environment) GetAppDir() string

func (*Environment) GetAppName

func (e *Environment) GetAppName() string

func (*Environment) GetApplication

func (e *Environment) GetApplication() *Application

func (*Environment) GetApplicationCommand

func (e *Environment) GetApplicationCommand() string

func (*Environment) GetApplicationName

func (e *Environment) GetApplicationName() string

func (*Environment) GetBranch

func (e *Environment) GetBranch() string

func (*Environment) GetDir

func (e *Environment) GetDir() string

func (*Environment) GetDocumentRoot

func (e *Environment) GetDocumentRoot() string

func (*Environment) GetEnv

func (e *Environment) GetEnv(key string) string

func (*Environment) GetEnvironment

func (e *Environment) GetEnvironment() string

func (*Environment) GetPort

func (e *Environment) GetPort() string

func (*Environment) GetProject

func (e *Environment) GetProject() string

func (*Environment) GetProjectEntropy

func (e *Environment) GetProjectEntropy() string

func (*Environment) GetRelationships

func (e *Environment) GetRelationships() Relationships

func (*Environment) GetRoutes

func (e *Environment) GetRoutes() Routes

func (*Environment) GetSMTPHost

func (e *Environment) GetSMTPHost() string

func (*Environment) GetSocket

func (e *Environment) GetSocket() string

func (*Environment) GetTreeID

func (e *Environment) GetTreeID() string

func (*Environment) GetVariables

func (e *Environment) GetVariables() Variables

func (*Environment) GetVars

func (e *Environment) GetVars() Variables

func (*Environment) GetXClientCert

func (e *Environment) GetXClientCert() string

func (*Environment) GetXClientDN

func (e *Environment) GetXClientDN() string

func (*Environment) GetXClientIP

func (e *Environment) GetXClientIP() string

func (*Environment) GetXClientVerify

func (e *Environment) GetXClientVerify() string

func (*Environment) Listener

func (e *Environment) Listener() (net.Listener, error)

func (*Environment) Lookup

func (e *Environment) Lookup(key string) (string, bool)

func (*Environment) LookupAppCommand

func (e *Environment) LookupAppCommand() (string, bool)

func (*Environment) LookupAppDir

func (e *Environment) LookupAppDir() (string, bool)

func (*Environment) LookupAppName

func (e *Environment) LookupAppName() (string, bool)

func (*Environment) LookupApplication

func (e *Environment) LookupApplication() (*Application, bool)

func (*Environment) LookupApplicationCommand

func (e *Environment) LookupApplicationCommand() (string, bool)

func (*Environment) LookupApplicationName

func (e *Environment) LookupApplicationName() (string, bool)

func (*Environment) LookupBranch

func (e *Environment) LookupBranch() (string, bool)

func (*Environment) LookupDir

func (e *Environment) LookupDir() (string, bool)

func (*Environment) LookupDocumentRoot

func (e *Environment) LookupDocumentRoot() (string, bool)

func (*Environment) LookupEnvironment

func (e *Environment) LookupEnvironment() (string, bool)

func (*Environment) LookupPort

func (e *Environment) LookupPort() (string, bool)

func (*Environment) LookupProject

func (e *Environment) LookupProject() (string, bool)

func (*Environment) LookupProjectEntropy

func (e *Environment) LookupProjectEntropy() (string, bool)

func (*Environment) LookupRelationships

func (e *Environment) LookupRelationships() (Relationships, bool)

func (*Environment) LookupRoutes

func (e *Environment) LookupRoutes() (Routes, bool)

func (*Environment) LookupSMTPHost

func (e *Environment) LookupSMTPHost() (string, bool)

func (*Environment) LookupSocket

func (e *Environment) LookupSocket() (string, bool)

func (*Environment) LookupTreeID

func (e *Environment) LookupTreeID() (string, bool)

func (*Environment) LookupVariables

func (e *Environment) LookupVariables() (Variables, bool)

func (*Environment) LookupVars

func (e *Environment) LookupVars() (Variables, bool)

func (*Environment) LookupXClientCert

func (e *Environment) LookupXClientCert() (string, bool)

func (*Environment) LookupXClientDN

func (e *Environment) LookupXClientDN() (string, bool)

func (*Environment) LookupXClientIP

func (e *Environment) LookupXClientIP() (string, bool)

func (*Environment) LookupXClientVerify

func (e *Environment) LookupXClientVerify() (string, bool)

func (*Environment) Prefix

func (e *Environment) Prefix() string

func (*Environment) SetEnv

func (e *Environment) SetEnv(key, value string) error

func (*Environment) SetProvider

func (e *Environment) SetProvider(p Provider)

func (*Environment) UnsetEnv

func (e *Environment) UnsetEnv(key string) error

func (*Environment) Variable

func (e *Environment) Variable(key string) (interface{}, bool)

type HTTPAccess

type HTTPAccess struct {
	Addresses []string          `json:"addresses"`
	BasicAuth map[string]string `json:"basic_auth"`
}

type Hooks

type Hooks struct {
	Build      string `json:"build"`
	Deploy     string `json:"deploy"`
	PostDeploy string `json:"post_deploy"`
}

type JSONArray

type JSONArray = []interface{}

type JSONObject

type JSONObject = map[string]interface{}

type LayeredProvider

type LayeredProvider []Provider

func (LayeredProvider) Environ

func (lp LayeredProvider) Environ() []string

func (LayeredProvider) First

func (lp LayeredProvider) First(fn ProviderFunctor) error

func (LayeredProvider) ForEach

func (lp LayeredProvider) ForEach(fn ProviderFunctor) error

func (LayeredProvider) GetEnv

func (lp LayeredProvider) GetEnv(key string) string

func (LayeredProvider) Lookup

func (lp LayeredProvider) Lookup(key string) (rv string, ok bool)

func (*LayeredProvider) Pop

func (lp *LayeredProvider) Pop() Provider

func (*LayeredProvider) Push

func (lp *LayeredProvider) Push(p Provider)

func (LayeredProvider) SetEnv

func (lp LayeredProvider) SetEnv(key, value string) error

func (LayeredProvider) UnsetEnv

func (lp LayeredProvider) UnsetEnv(key string) error

type MapProvider

type MapProvider map[string]string

func ParseEnviron

func ParseEnviron(s []string) (MapProvider, error)

func ReadEnviron

func ReadEnviron(r io.Reader) (MapProvider, error)

func (MapProvider) Environ

func (p MapProvider) Environ() []string

func (MapProvider) GetEnv

func (p MapProvider) GetEnv(key string) string

func (MapProvider) Lookup

func (p MapProvider) Lookup(key string) (string, bool)

func (MapProvider) SetEnv

func (p MapProvider) SetEnv(key, value string) error

func (MapProvider) UnsetEnv

func (p MapProvider) UnsetEnv(key string) error

type Mount

type Mount struct {
	Source     ApplicationMount `json:"source"`
	SourcePath string           `json:"path"`
	Service    string           `json:"service,omitempty"`
}

type Mounts

type Mounts map[string]Mount

type OSProvider

type OSProvider struct{}

func (OSProvider) Environ

func (OSProvider) Environ() []string

func (OSProvider) GetEnv

func (OSProvider) GetEnv(key string) string

func (OSProvider) Lookup

func (OSProvider) Lookup(key string) (string, bool)

func (OSProvider) SetEnv

func (OSProvider) SetEnv(key, value string) error

func (OSProvider) UnsetEnv

func (OSProvider) UnsetEnv(key string) error

type Passthru

type Passthru struct {
	Enabled bool
	Path    string
}

func (Passthru) MarshalJSON

func (p Passthru) MarshalJSON() ([]byte, error)

func (*Passthru) UnmarshalJSON

func (p *Passthru) UnmarshalJSON(data []byte) error

type PlatformProvider

type PlatformProvider interface {
	Provider
	Prefix() string
}

type Preflight

type Preflight struct {
	Enabled      bool     `json:"enabled"`
	IgnoredRules []string `json:"ignored_rules"`
}

type Provider

type Provider interface {
	Lookup(key string) (string, bool)
	Environ() []string
	SetEnv(key, value string) error
	UnsetEnv(key string) error
	GetEnv(key string) string
}
var (
	DefaultProvider Provider = OSProvider{}
)

func CloneProvider

func CloneProvider(p Provider) Provider

type ProviderFunctor

type ProviderFunctor func(p Provider) error

type RedirectPath

type RedirectPath struct {
	Regexp       bool     `json:"regexp"`
	To           string   `json:"to"`
	Prefix       bool     `json:"prefix"`
	AppendSuffix bool     `json:"append_suffix"`
	Code         int      `json:"code"`
	Expires      Duration `json:"expires"`
}

type RedirectPaths

type RedirectPaths map[string]RedirectPath

type Redirects

type Redirects struct {
	Expires Duration      `json:"expires"`
	Paths   RedirectPaths `json:"paths"`
}

type Relationship

type Relationship struct {
	Cluster  string     `json:"cluster"`
	Fragment string     `json:"fragment"`
	Host     string     `json:"host"`
	Hostname string     `json:"hostname"`
	IP       string     `json:"ip"`
	Password string     `json:"password"`
	Path     string     `json:"path"`
	Port     int        `json:"port"`
	Public   bool       `json:"public"`
	Query    JSONObject `json:"query"`
	Rel      string     `json:"rel"`
	Scheme   string     `json:"scheme"`
	Service  string     `json:"service"`
	SSL      JSONObject `json:"ssl"`
	Type     string     `json:"type"`
	Username string     `json:"username"`
}

func (Relationship) URL

func (r Relationship) URL(user, query bool) string

type Relationships

type Relationships map[string][]Relationship

func GetRelationships

func GetRelationships(p PlatformProvider) Relationships

func LookupRelationships

func LookupRelationships(p PlatformProvider) (Relationships, bool)

type Route

type Route struct {
	Primary        bool              `json:"primary"`
	ID             *string           `json:"id"`
	OriginalURL    string            `json:"original_url"`
	Attributes     map[string]string `json:"attributes"`
	Type           string            `json:"type"`
	Redirects      Redirects         `json:"redirects"`
	TLS            TLSSettings       `json:"tls"`
	HTTPAccess     HTTPAccess        `json:"http_access"`
	RestrictRobots bool              `json:"restrict_robots"`

	// Upstream Routes
	Cache    Cache  `json:"cache"`
	SSI      SSI    `json:"ssi"`
	Upstream string `json:"upstream"`

	// Redirect Routes
	To string `json:"to"`
}

type RouteIdentification

type RouteIdentification struct {
	Scheme string `json:"scheme"`
	Host   string `json:"host"`
	Path   string `json:"path"`
}

type RouteRepresentation

type RouteRepresentation struct {
	Project     string              `json:"project"`
	Environment string              `json:"environment"`
	Route       RouteIdentification `json:"route"`
}

type Routes

type Routes map[url.URL]Route

func GetRoutes

func GetRoutes(p PlatformProvider) Routes

func LookupRoutes

func LookupRoutes(p PlatformProvider) (Routes, bool)

func (Routes) MarshalJSON

func (r Routes) MarshalJSON() ([]byte, error)

func (*Routes) UnmarshalJSON

func (r *Routes) UnmarshalJSON(text []byte) error

type SSI

type SSI struct {
	Enabled bool `json:"enabled"`
}

type ServiceSize

type ServiceSize uint8
const (
	ServiceSizeAuto ServiceSize = iota
	ServiceSizeSmall
	ServiceSizeMedium
	ServiceSizeLarge
	ServiceSizeExtraLarge
	ServiceSizeDoubleExtraLarge
	ServiceSizeQuadrupleExtraLarge
)

func NewServiceSize

func NewServiceSize(name string) (ServiceSize, error)

func (ServiceSize) MarshalText

func (v ServiceSize) MarshalText() ([]byte, error)

func (ServiceSize) String

func (v ServiceSize) String() string

func (*ServiceSize) UnmarshalText

func (v *ServiceSize) UnmarshalText(text []byte) (err error)

type SocketFamily

type SocketFamily uint8
const (
	SocketFamilyTCP SocketFamily = iota
	SocketFamilyUnix
)

func NewSocketFamily

func NewSocketFamily(name string) (SocketFamily, error)

func (SocketFamily) MarshalText

func (v SocketFamily) MarshalText() ([]byte, error)

func (SocketFamily) String

func (v SocketFamily) String() string

func (*SocketFamily) UnmarshalText

func (v *SocketFamily) UnmarshalText(text []byte) (err error)

type SocketProtocol

type SocketProtocol uint8
const (
	SocketProtocolHTTP SocketProtocol = iota
	SocketProtocolFastCGI
	SocketProtocolUWSGI
)

func NewSocketProtocol

func NewSocketProtocol(name string) (SocketProtocol, error)

func (SocketProtocol) MarshalText

func (v SocketProtocol) MarshalText() ([]byte, error)

func (SocketProtocol) String

func (v SocketProtocol) String() string

func (*SocketProtocol) UnmarshalText

func (v *SocketProtocol) UnmarshalText(text []byte) (err error)

type Source

type Source struct {
	Operations SourceOperations `json:"operations"`
}

type SourceOperation

type SourceOperation struct {
	Command string `json:"command"`
}

type SourceOperations

type SourceOperations map[string]SourceOperation

type StringMap

type StringMap = map[string]string

type TLSSTS

type TLSSTS struct {
	Enabled           bool `json:"enabled"`
	IncludeSubdomains bool `json:"include_subdomains"`
	Preload           bool `json:"preload"`
}

type TLSSettings

type TLSSettings struct {
	StrictTransportSecurity      TLSSTS        `json:"strict_transport_security"`
	MinVersion                   *TLSVersion   `json:"min_version"`
	ClientAuthentication         string        `json:"client_authentication"`
	ClientCertificateAuthorities []Certificate `json:"client_certificate_authorities"`
}

type TLSVersion

type TLSVersion uint16
const (
	TLSv10 TLSVersion = iota + 0x0301
	TLSv11
	TLSv12
	TLSv13
	TLSv14
)

func NewTLSVersion

func NewTLSVersion(name string) (TLSVersion, error)

func (TLSVersion) MarshalText

func (v TLSVersion) MarshalText() ([]byte, error)

func (TLSVersion) String

func (v TLSVersion) String() string

func (*TLSVersion) UnmarshalText

func (v *TLSVersion) UnmarshalText(text []byte) (err error)

type Upstream

type Upstream struct {
	SocketFamily SocketFamily   `json:"socket_family"`
	Protocol     SocketProtocol `json:"socket_protocol"`
}

type Variables

type Variables JSONObject

func GetVariables

func GetVariables(p PlatformProvider) Variables

func GetVars

func GetVars(p PlatformProvider) Variables

func LookupVariables

func LookupVariables(p PlatformProvider) (Variables, bool)

func LookupVars

func LookupVars(p PlatformProvider) (Variables, bool)

type Web

type Web struct {
	// ApplicationBase
	Locations    WebLocations `json:"locations"`
	Commands     Commands     `json:"commands"`
	Upstream     Upstream     `json:"upstream"`
	DocumentRoot *string      `json:"document_root,omitempty"` // deprecated
	Passthru     *string      `json:"passthru,omitempty"`      // deprecated
	IndexFiles   []string     `json:"index_files,omitempty"`   // deprecated
	Whitelist    []string     `json:"whitelist,omitempty"`     // deprecated
	Blacklist    []string     `json:"blacklist,omitempty"`     // deprecated
	Expires      *Duration    `json:"expires,omitempty"`       // deprecated
	MoveToRoot   *bool        `json:"move_to_root,omitempty"`  // deprecated
}

type WebLocation

type WebLocation struct {
	Root     string    `json:"root"`
	Expires  Duration  `json:"expires"`
	Passthru Passthru  `json:"passthru"`
	Scripts  bool      `json:"scripts"`
	Index    []string  `json:"index"`
	Allow    bool      `json:"allow"`
	Headers  StringMap `json:"headers"`
	Rules    WebRules  `json:"rules"`
}

type WebLocations

type WebLocations map[string]WebLocation

type WebRule

type WebRule struct {
	Expires  Duration  `json:"expires"`
	Passthru Passthru  `json:"passthru"`
	Scripts  bool      `json:"scripts"`
	Allow    bool      `json:"allow"`
	Headers  StringMap `json:"headers"`
}

type WebRules

type WebRules map[string]WebRule

type Worker

type Worker struct {
	// ApplicationBase
	Commands Commands `json:"commands"`
}

type Workers

type Workers map[string]Worker

Jump to

Keyboard shortcuts

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