sdk

package
v0.0.0-...-24a16b5 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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."
)
View Source
const (
	StatusSuccess = "success"
	StatusFailure = "failure"
	StatusPending = "pending"
)

github status constant

View Source
const (
	FunctionContext = "%s"
	StackContext    = "stack-deploy"
	EmptyAuthToken  = ""
)

context constant

Variables

This section is empty.

Functions

func AddBasicAuth

func AddBasicAuth(req *http.Request) error

AddBasicAuth to a request by reading secrets when available

func BuildFunctionContext

func BuildFunctionContext(function string) string

BuildFunctionContext build a github context for a function

Example:
  sdk.BuildFunctionContext(functionName)

func CreateServiceURL

func CreateServiceURL(URL, suffix string) string

func FormatServiceName

func FormatServiceName(owner, functionName string) string

func GetPrivateKeyPath

func GetPrivateKeyPath() string

func HmacEnabled

func HmacEnabled() bool

HmacEnabled uses validate_hmac env-var to verify if the feature is enabled

func MarshalToken

func MarshalToken(token string) string

MarshalToken marshal a token into json i.e. {"token": "auth_token_value"}

func PostAudit

func PostAudit(auditEvent AuditEvent)

func ReadSecret

func ReadSecret(key string) (string, error)

ReadSecret reads a secret from /var/openfaas/secrets or from env-var 'secret_mount_path' if set.

func UnmarshalToken

func UnmarshalToken(data []byte) (string, error)

UnmarshalToken unmarshal a token and validate

func ValidHMAC

func ValidHMAC(payload *[]byte, secretKey string, digest string) error

ValidHMAC returns an error if HMAC could not be validated or if the signature could not be loaded.

func ValidToken

func ValidToken(token string) bool

ValidToken check if a token is in valid format

Types

type Audit

type Audit interface {
	Post(AuditEvent) error
}

type AuditEvent

type AuditEvent struct {
	Source  string
	Message string
	Owner   string
	Repo    string
}

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"`
}

type Customer

type Customer struct {
	Sender Sender `json:"sender"`
}

type Event

type Event struct {
	Service        string            `json:"service"`
	Owner          string            `json:"owner"`
	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"`
}

Event info to pass/store events across functions

func BuildEventFromPushEvent

func BuildEventFromPushEvent(pushEvent PushEvent) *Event

BuildEventFromPushEvent function to build Event from PushEvent

type NilLogger

type NilLogger struct {
}

func (NilLogger) Post

func (l NilLogger) Post(auditEvent AuditEvent) error

type Owner

type Owner struct {
	Login string `json:"login"`
	Email string `json:"email"`
}

Owner is the owner of a GitHub repo

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
}

type PushEventInstallation

type PushEventInstallation struct {
	ID int `json:"id"`
}

PushEvent as received from GitHub

type PushEventRepository

type PushEventRepository struct {
	Name     string `json:"name"`
	FullName string `json:"full_name"`
	CloneURL string `json:"clone_url"`
	Private  bool   `json:"private"`

	Owner Owner `json:"owner"`
}

type Sender

type Sender struct {
	Login string `json:"login"`
}

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

func BuildStatus(event *Event, token string) *Status

BuildStatus constructs a status object from event

func UnmarshalStatus

func UnmarshalStatus(data []byte) (*Status, error)

UnmarshalStatus unmarshal a status object from json

func (*Status) AddStatus

func (status *Status) AddStatus(state string, desc string, context string)

AddStatus adds a commit status into a status object

a status can contain multiple commit status

func (*Status) Marshal

func (status *Status) Marshal() ([]byte, error)

marshal marshal a status into json

func (*Status) Report

func (status *Status) Report(gateway string, payloadSecret string) (string, error)

Report send a status update to github-status function

Jump to

Keyboard shortcuts

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