Documentation ¶
Index ¶
- Constants
- func AddBasicAuth(req *http.Request) error
- func BuildFunctionContext(function string) string
- func CreateServiceURL(URL, suffix string) string
- func FormatDashboardURL(gatewayURL string, event *Event) (string, error)
- func FormatEndpointURL(gatewayURL string, event *Event) (string, error)
- func FormatLogsURL(gatewayURL string, event *Event) (string, error)
- func FormatServiceName(owner, functionName string) string
- func FormatShortSHA(sha string) string
- func FormatSystemURL(gatewayURL string) (string, error)
- func GetPrivateKeyPath() string
- func GetSubdomain(URL string) (string, error)
- func HmacEnabled() bool
- func MarshalToken(token string) string
- func PostAudit(auditEvent AuditEvent)
- func ReadSecret(key string) (string, error)
- func UnmarshalToken(data []byte) (string, error)
- func ValidHMAC(payload *[]byte, secretKey string, digest string) error
- func ValidToken(token string) bool
- func ValidateCustomerList(customers []string) bool
- func ValidateCustomers() bool
- type Audit
- type AuditEvent
- type AuditLogger
- type BuildResult
- type CommitStatus
- type Customer
- type Customers
- type Event
- type Function
- type GitLabProject
- type GitLabPushEvent
- type GitLabRepository
- type Installation
- type InstallationRepositoriesEvent
- type NilLogger
- type Owner
- type PipelineLog
- type PushEvent
- type PushEventInstallation
- type PushEventRepository
- type Sender
- type Status
Constants ¶
const ( //CloudSignatureHeader header name to pass signed payload secret CloudSignatureHeader = "X-Cloud-Signature" // FunctionLabelPrefix is a prefix for openfaas labels inside functions FunctionLabelPrefix = "com.openfaas.cloud." )
const ( StatusSuccess = "success" StatusFailure = "failure" StatusPending = "pending" )
github status constant
const ( FunctionContext = "%s" StackContext = "stack-deploy" EmptyAuthToken = "" )
context constant
const (
SystemSubdomain = "system"
)
Variables ¶
This section is empty.
Functions ¶
func AddBasicAuth ¶
AddBasicAuth to a request by reading secrets when available
func BuildFunctionContext ¶
BuildFunctionContext build a github context for a function
Example: sdk.BuildFunctionContext(functionName)
func CreateServiceURL ¶
func FormatDashboardURL ¶
FormatDashboardURL takes the environmental variable gateway_public_url and event object and formats the URL to point to the dashboard
func FormatEndpointURL ¶
FormatEndpointURL takes the gateway_public_url environmental variable along with event object to format URL which points to the function endpoint
func FormatLogsURL ¶
FormatLogsURL formats the URL where function logs are stored with the gateway_public_url environmental variable and event object
func FormatServiceName ¶
func FormatSystemURL ¶
FormatSystemURL formats the system URL which points to the edge-router with the gateway_public_url environmental variable
func GetPrivateKeyPath ¶
func GetPrivateKeyPath() string
func GetSubdomain ¶
GetSubdomain gets the subdomain of the URL for example the subdomain of www.o6s.io would be www
func HmacEnabled ¶
func HmacEnabled() bool
HmacEnabled uses validate_hmac env-var to verify if the feature is disabled
func MarshalToken ¶
MarshalToken marshal a token into json i.e. {"token": "auth_token_value"}
func PostAudit ¶
func PostAudit(auditEvent AuditEvent)
func ReadSecret ¶
ReadSecret reads a secret from /var/openfaas/secrets or from env-var 'secret_mount_path' if set.
func UnmarshalToken ¶
UnmarshalToken unmarshal a token and validate
func ValidHMAC ¶
ValidHMAC returns an error if HMAC could not be validated or if the signature could not be loaded.
func ValidateCustomerList ¶
ValidateCustomerList validate customer names list
func ValidateCustomers ¶
func ValidateCustomers() bool
ValidateCustomers checks environmental variable validate_customers if customer validation is explicitly disabled
Types ¶
type Audit ¶
type Audit interface {
Post(AuditEvent) error
}
type AuditLogger ¶
type AuditLogger struct { }
func (AuditLogger) Post ¶
func (l AuditLogger) Post(auditEvent AuditEvent) error
type BuildResult ¶
type BuildResult struct { Log []string `json:"log"` ImageName string `json:"imageName"` Status string `json:"status"` }
BuildResult represents a successful Docker build and push operation to a remote registry
type CommitStatus ¶
type CommitStatus struct { Status string `json:"status"` Description string `json:"description"` Context string `json:"context"` }
CommitStatus to be written to GitHub/GitLab
type Customers ¶
type Customers struct { Usernames *map[string]string Sync *sync.Mutex Expires time.Time CustomersURL string CustomersPath string }
Customers checks whether users are customers of OpenFaaS Cloud
func NewCustomers ¶
NewCustomers creates a Customers struct to be used to query valid users.
type Event ¶
type Event struct { EventKey string `json:"event_key"` Service string `json:"service"` Owner string `json:"owner"` OwnerID int `json:"owner-id"` Repository string `json:"repository"` Image string `json:"image"` SHA string `json:"sha"` URL string `json:"url"` InstallationID int `json:"installationID"` Environment map[string]string `json:"environment"` Secrets []string `json:"secrets"` Private bool `json:"private"` SCM string `json:"scm"` RepoURL string `json:"repourl"` Labels map[string]string `json:"labels"` Annotations map[string]string `json:"annotations"` }
Event info used to pass events between functions
func BuildEventFromPushEvent ¶
BuildEventFromPushEvent function to build Event from PushEvent
type GitLabProject ¶
type GitLabPushEvent ¶
type GitLabPushEvent struct { Ref string `json:"ref"` UserUsername string `json:"user_username"` UserEmail string `json:"user_email"` GitLabProject GitLabProject `json:"project"` GitLabRepository GitLabRepository `json:"repository"` AfterCommitID string `json:"after"` }
GitLabPushEvent as received from GitLab's system hook event
type GitLabRepository ¶
type GitLabRepository struct {
CloneURL string `json:"git_http_url"`
}
type Installation ¶
type InstallationRepositoriesEvent ¶
type InstallationRepositoriesEvent struct { Action string `json:"action"` Installation struct { Account struct { Login string } } `json:"installation"` RepositoriesRemoved []Installation `json:"repositories_removed"` RepositoriesAdded []Installation `json:"repositories_added"` Repositories []Installation `json:"repositories"` }
type NilLogger ¶
type NilLogger struct { }
func (NilLogger) Post ¶
func (l NilLogger) Post(auditEvent AuditEvent) error
type PipelineLog ¶
type PipelineLog struct { RepoPath string CommitSHA string Function string Source string Data string }
PipelineLog stores a log output from a given stage of a pipeline such as the container builder
type PushEvent ¶
type PushEvent struct { Ref string `json:"ref"` Repository PushEventRepository AfterCommitID string `json:"after"` Installation PushEventInstallation SCM string // SCM field is for internal use and not provided by GitHub }
PushEvent is received from GitHub's push event subscription
type PushEventInstallation ¶
type PushEventInstallation struct {
ID int `json:"id"`
}
type PushEventRepository ¶
type PushEventRepository struct { Name string `json:"name"` FullName string `json:"full_name"` CloneURL string `json:"clone_url"` Private bool `json:"private"` ID int64 `json:"id"` RepositoryURL string `json:"url"` Owner Owner `json:"owner"` }
PushEventRepository represents the repository from a push event
type Status ¶
type Status struct { CommitStatuses map[string]CommitStatus `json:"commit-statuses"` EventInfo Event `json:"event"` AuthToken string `json:"auth-token"` }
Status to post status to github-status function
func BuildStatus ¶
BuildStatus constructs a status object from event
func UnmarshalStatus ¶
UnmarshalStatus unmarshals a status object from json
func (*Status) AddStatus ¶
AddStatus adds a commit status into a status object a status can contain multiple commit status
func (*Status) Clear ¶
func (status *Status) Clear()
Clear removes any statuses which have been added