Documentation ¶
Index ¶
- Constants
- Variables
- func ArchiveTypeByExtension(name string) int
- func CertificateExists(cert string, key string) (exists bool, err error)
- func CopyFile(src string, dst string) error
- func CreateJobID(job JobData) (jobID string)
- func EnsureFolder(path string) error
- func ExtractArchive(dst string, in io.Reader, size int64, format int) error
- func FileExists(path string) (bool, error)
- func FolderExists(path string) (bool, error)
- func GetAzureAuthorizer(service string) (autorest.Authorizer, error)
- func GetAzureEndpoint(service string) (endpoint string, err error)
- func GetAzureOAuthConfig() (*adal.OAuthConfig, error)
- func GetAzureServicePrincipalToken(service string) (*adal.ServicePrincipalToken, error)
- func GetAzureStorageCredentials() (azblob.Credential, error)
- func GetAzureStorageEndpointSuffix() (string, error)
- func HeaderIsAllowed(name string) bool
- func IsTruthy(val string) bool
- func NodeAddress() string
- func ParseRSAPublicKey(nStr string, eStr string) (*rsa.PublicKey, error)
- func PathExists(path string) (bool, error)
- func ReaderFuncWithContext(ctx context.Context, in io.Reader) ioctx
- func RemoveContents(dir string) error
- func RequestJSON(client *http.Client, url string, target interface{}) error
- func SHA256String(str string) string
- func SanitizeAppName(name string) string
- func SerializeECDSAKey(privateKey *ecdsa.PrivateKey) ([]byte, error)
- func StringInSlice(list []string, a string) bool
- func UnserializeECDSAKey(pemEncoded []byte) (*ecdsa.PrivateKey, error)
- func WriterFuncWithContext(ctx context.Context, in io.Writer) ioctx
- type AppManifest
- type JobData
- type ManifestRule
- type ManifestRuleOptions
- type ManifestRules
- type NginxStatus
- type NodeStatus
- type NodeStore
- type NodeSync
- type SiteHealth
Constants ¶
const ( ArchiveTar = iota ArchiveTarBz2 ArchiveTarGz ArchiveTarLz4 ArchiveTarSz ArchiveTarXz ArchiveZip ArchiveRar )
Type of archive
const ( JobTypeTLSCertificate = "tlscert" JobTypeACME = "acme" )
Job type identifiers
Variables ¶
var ArchiveExtensions = []string{".zip", ".tar", ".tar.bz2", ".tbz2", ".tar.gz", ".tgz", ".tar.lz4", ".tlz4", ".tar.sz", ".tsz", ".tar.xz", ".txz", ".rar"}
Valid extensions
Functions ¶
func ArchiveTypeByExtension ¶
ArchiveTypeByExtension returns the type of the archive by the file's extension Note: this function assumes that the file was already validated to contain one of the valid extensions Ensure to use the SiteApp.Validate() method first
func CertificateExists ¶
CertificateExists checks if the certificate and key exist on disk
func CopyFile ¶
CopyFile copies the src file to dst. Any existing file will be overwritten and will not copy file attributes. Source: https://stackoverflow.com/a/21061062/192024
func EnsureFolder ¶
EnsureFolder creates a folder if it doesn't exist already
func ExtractArchive ¶
ExtractArchive extracts a compressed archive Reads input from a stream in, and extracts all files into dst This supports all archive formats supported by archiver, including zip, tar.gz, tar.bz2, rar
func FileExists ¶
FileExists returns true if the path exists on disk and it's not a folder
func FolderExists ¶
FolderExists returns true if the path exists on disk and it's a folder
func GetAzureAuthorizer ¶
func GetAzureAuthorizer(service string) (autorest.Authorizer, error)
GetAzureAuthorizer returns the autorest.Authorizer object for the Azure SDK, for a given service See GetAzureEndpoint for the list of services
func GetAzureEndpoint ¶
GetAzureEndpoint returns the endpoint for the Azure service Service can be one of: - "azure" for Azure Resource Manager - "keyvault" for Azure Key Vault - "storage" for Azure Storage
func GetAzureOAuthConfig ¶
func GetAzureOAuthConfig() (*adal.OAuthConfig, error)
GetAzureOAuthConfig returns the adal.OAuthConfig object that can be used to authenticate against Azure resources
func GetAzureServicePrincipalToken ¶
func GetAzureServicePrincipalToken(service string) (*adal.ServicePrincipalToken, error)
GetAzureServicePrincipalToken returns a Service Principal token inside an adal.ServicePrincipalToken object, for a given service Note that the returned token needs to be refreshed with the `Refresh()` method right away before it can be used See GetAzureEndpoint for the list of services
func GetAzureStorageCredentials ¶
func GetAzureStorageCredentials() (azblob.Credential, error)
GetAzureStorageCredentials returns a azblob.Credential object that can be used to authenticate an Azure Blob Storage SDK pipeline
func GetAzureStorageEndpointSuffix ¶
GetAzureStorageEndpointSuffix returns the endpoint suffix for Azure Storage in this environment
func HeaderIsAllowed ¶
HeaderIsAllowed returns true if a header is allowed as response header
func IsTruthy ¶
IsTruthy returns true if a string (e.g. a querystring parameter) is a truthy value, as a string
func ParseRSAPublicKey ¶
ParseRSAPublicKey converts a public RSA key represented by base64-encoded modulus and exponent into a rsa.PublicKey object
func PathExists ¶
PathExists returns true if the path exists on disk
func RemoveContents ¶
RemoveContents remove all contents within a directory Source: https://stackoverflow.com/a/33451503/192024
func RequestJSON ¶
RequestJSON fetches a JSON document from the web
func SHA256String ¶
SHA256String returns the SHA256 of a string, as a hex-encoded string
func SanitizeAppName ¶
SanitizeAppName validates and sanitizes the name of an app's bundle App bundles must be lowercase strings containing letters, numbers, dashes and dots; the first character must be a letter
func SerializeECDSAKey ¶
func SerializeECDSAKey(privateKey *ecdsa.PrivateKey) ([]byte, error)
SerializeECDSAKey serializes an ecdsa private key Source https://stackoverflow.com/a/41315404/192024
func StringInSlice ¶
StringInSlice checks if a string is contained inside a slice of strings
func UnserializeECDSAKey ¶
func UnserializeECDSAKey(pemEncoded []byte) (*ecdsa.PrivateKey, error)
UnserializeECDSAKey unserializes an ecdsa private key Source https://stackoverflow.com/a/41315404/192024
Types ¶
type AppManifest ¶
type AppManifest struct { Rules ManifestRules `yaml:"rules"` Rewrite map[string]string `yaml:"rewrite"` Page403 string `yaml:"page403"` Page404 string `yaml:"page404"` // Internal Locations map[string]ManifestRuleOptions `yaml:"-"` }
AppManifest represents the manifest of an app
type ManifestRule ¶
type ManifestRule struct { // An "exact" match equals to a = modifier in the nginx location block Exact string `yaml:"exact"` // A "prefix" match equals to a ^~ modifier in the nginx location block // Exception is the prefix "/", which doesn't use any modifier Prefix string `yaml:"prefix"` // A "match" match equals to ~* modifier (or ~ modifier if "caseSensitive" is true) in the nginx location block Match string `yaml:"match"` CaseSensitive bool `yaml:"caseSensitive"` // Using "file" lets user list file extensions or extension groups (such as "_images") File string `yaml:"file"` // Options to apply Options ManifestRuleOptions `yaml:"options"` }
ManifestRule is the dictionary with rules
type ManifestRuleOptions ¶
type ManifestRuleOptions struct { Deny bool `yaml:"deny"` ClientCaching string `yaml:"clientCaching"` Headers map[string]string `yaml:"headers"` CleanHeaders map[string]string `yaml:"-"` Proxy string `yaml:"proxy"` }
ManifestRuleOptions is used by the AppManifest struct to represent options for a specific location or file type
type ManifestRules ¶
type ManifestRules []ManifestRule
ManifestRules is a slice of ManifestRule structs
type NginxStatus ¶
type NginxStatus struct {
Running bool `json:"running"`
}
NginxStatus contains information on the status of the Nginx server
type NodeStatus ¶
type NodeStatus struct { NodeName string `json:"name"` Nginx NginxStatus `json:"nginx"` Sync NodeSync `json:"sync"` Store NodeStore `json:"store"` Health []SiteHealth `json:"health"` }
NodeStatus contains the current status of the node
type NodeStore ¶
type NodeStore struct {
Healthy bool `json:"healthy"`
}
NodeStore contains information on the status of the store Particularly useful if using etcd as store
type NodeSync ¶
type NodeSync struct { Running bool `json:"running"` LastSync *time.Time `json:"lastSync"` SyncError string `json:"syncError,omitempty"` }
NodeSync contains information on the sync status
type SiteHealth ¶
type SiteHealth struct { Domain string `json:"domain"` App *string `json:"app"` StatusCode *int `json:"-"` ResponseSize *int `json:"-"` Error string `json:"error,omitempty"` Time *time.Time `json:"time,omitempty"` }
SiteHealth contains the results of the health checks for each individual app
func (*SiteHealth) IsHealthy ¶
func (h *SiteHealth) IsHealthy() bool
IsHealthy returns true if the site is in a healthy state
func (*SiteHealth) MarshalJSON ¶
func (h *SiteHealth) MarshalJSON() ([]byte, error)
MarshalJSON implements a custom JSON serializer for the SiteHealth object