types

package
v0.0.0-...-c5ab296 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: MPL-2.0 Imports: 8 Imported by: 28

Documentation

Overview

Package types holds most of the types used across bow

Index

Constants

View Source
const (
	AuditActionCreated = "created"
	AuditActionUpdated = "updated"
	AuditActionDeleted = "deleted"

	// Approval specific actions
	AuditActionApprovalApproved = "approved"
	AuditActionApprovalRejected = "rejected"
	AuditActionApprovalExpired  = "expired"
	AuditActionApprovalArchived = "archived"

	// audit specific resource kinds (others are set by
	// providers, ie: deployment, daemonset, helm chart)
	AuditResourceKindApproval = "approval"
	AuditResourceKindWebhook  = "webhook"
)
View Source
const BowApprovalDeadlineDefault = 24

BowApprovalDeadlineDefault - default deadline in hours

View Source
const BowApprovalDeadlineLabel = "bow/approvalDeadline"

BowApprovalDeadlineLabel - approval deadline

View Source
const BowDefaultPort = 9300

BowDefaultPort - default port for application

View Source
const BowDigestAnnotation = "bow/digest"

BowDigestAnnotation - digest annotation

View Source
const BowForceTagMatchLabel = "bow/matchTag"
View Source
const BowForceTagMatchLegacyLabel = "bow/match-tag"

BowForceTagMatchLabel - label that checks whether tags match before force updating

View Source
const BowImagePullSecretAnnotation = "bow/imagePullSecret"
View Source
const BowMinimumApprovalsLabel = "bow/approvals"

BowMinimumApprovalsLabel - min approvals

View Source
const BowNotificationChanAnnotation = "bow/notify"

BowNotificationChanAnnotation - optional notification to override default notification channel(-s) per deployment/chart

View Source
const BowPolicyLabel = "bow/policy"

BowPolicyLabel - bow update policies (version checking)

View Source
const BowPollDefaultSchedule = "@every 5m"

BowPollDefaultSchedule - defaul polling schedule

View Source
const BowPollScheduleAnnotation = "bow/pollSchedule"

BowPollScheduleAnnotation - optional variable to setup custom schedule for polling, defaults to @every 10m

View Source
const BowReleaseNotesURL = "bow/releaseNotes"

BowReleasePage - optional release notes URL passed on with notification

View Source
const BowTriggerLabel = "bow/trigger"

BowTriggerLabel - trigger label is used to specify custom trigger types for example bow.sh/trigger=poll would signal poll trigger to start watching for repository changes

View Source
const BowUpdateTimeAnnotation = "bow/update-time"

bowUpdateTimeAnnotation - update time

Variables

This section is empty.

Functions

func ParseEventNotificationChannels

func ParseEventNotificationChannels(annotations map[string]string) []string

ParseEventNotificationChannels - parses deployment annotations or chart config to get channel overrides

func ParseReleaseNotesURL

func ParseReleaseNotesURL(annotations map[string]string) string

Types

type Approval

type Approval struct {
	ID string `json:"id" gorm:"primary_key;type:varchar(36)"`

	// Archived is set to true once approval is finally approved/rejected
	Archived bool `json:"archived"`

	// Provider name - Kubernetes/Helm
	Provider ProviderType `json:"provider"`

	// Identifier is used to inform user about specific
	// Helm release or k8s deployment
	// ie: k8s <namespace>/<deployment name>
	//     helm: <namespace>/<release name>
	Identifier string `json:"identifier"`

	// Event that triggered evaluation
	Event *Event `json:"event" gorm:"type:json"`

	Message string `json:"message"`

	CurrentVersion string `json:"currentVersion"`
	NewVersion     string `json:"newVersion"`

	// Digest is used to verify that images are the ones that got the approvals.
	// If digest doesn't match for the image, votes are reset.
	Digest string `json:"digest"`

	// Requirements for the update such as number of votes
	// and deadline
	VotesRequired int `json:"votesRequired"`
	VotesReceived int `json:"votesReceived"`

	// Voters is a list of voter
	// IDs for audit
	Voters JSONB `json:"voters" gorm:"type:json"`

	// Explicitly rejected approval
	// can be set directly by user
	// so even if deadline is not reached approval
	// could be turned down
	Rejected bool `json:"rejected"`

	// Deadline for this request
	Deadline time.Time `json:"deadline"`

	// When this approval was created
	CreatedAt time.Time `json:"createdAt"`
	// WHen this approval was updated
	UpdatedAt time.Time `json:"updatedAt"`
}

Approval used to store and track updates

func (*Approval) AddVoter

func (a *Approval) AddVoter(voter string)

func (*Approval) Delta

func (a *Approval) Delta() string

Delta of what's changed ie: webhookrelay/webhook-demo:0.15.0 -> webhookrelay/webhook-demo:0.16.0

func (*Approval) Expired

func (a *Approval) Expired() bool

Expired - checks if approval is already expired

func (*Approval) GetVoters

func (a *Approval) GetVoters() []string

func (*Approval) Status

func (a *Approval) Status() ApprovalStatus

Status - returns current approval status

type ApprovalStatus

type ApprovalStatus int

ApprovalStatus - approval status type used in approvals to determine whether it was rejected/approved or still pending

const (
	ApprovalStatusUnknown ApprovalStatus = iota
	ApprovalStatusPending
	ApprovalStatusApproved
	ApprovalStatusRejected
)

Available approval status types

func (ApprovalStatus) String

func (s ApprovalStatus) String() string

type AuditLog

type AuditLog struct {
	ID        string    `json:"id" gorm:"primary_key;type:varchar(36)"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`

	AccountID string `json:"accountId"`
	Username  string `json:"username"`
	Email     string `json:"email"`

	// create/delete/update
	Action       string `json:"action"`
	ResourceKind string `json:"resourceKind"` // approval/deployment/daemonset/statefulset/etc...
	Identifier   string `json:"identifier"`

	Message     string `json:"message"`
	Payload     string `json:"payload"` // can be used for bigger messages such as webhook payload
	PayloadType string `json:"payloadType"`

	Metadata JSONB `json:"metadata" gorm:"type:json"`
}

AuditLog - audit logs lets users basic things happening in bow such as deployment updates and approval actions

func (*AuditLog) SetMetadata

func (l *AuditLog) SetMetadata(m map[string]string)

SetMetadata - set audit log metadata (providers, namespaces)

type AuditLogQuery

type AuditLogQuery struct {
	Email    string `json:"email"`
	Username string `json:"username"`
	Order    string `json:"order"` // empty or "desc"
	Limit    int    `json:"limit"`
	Offset   int    `json:"offset"`

	ResourceKindFilter []string `json:"resourceKindFilter"`
}

AuditLogQuery - struct used to query audit logs

type AuditLogStats

type AuditLogStats struct {
	Date     string `json:"date"`
	Webhooks int    `json:"webhooks"`
	Approved int    `json:"approved"`
	Rejected int    `json:"rejected"`
	Updates  int    `json:"updates"`
}

type AuditLogStatsQuery

type AuditLogStatsQuery struct {
	Days int
}

type Credentials

type Credentials struct {
	Username, Password string
}

Credentials - registry credentials

type Event

type Event struct {
	Repository Repository `json:"repository,omitempty"`
	CreatedAt  time.Time  `json:"createdAt,omitempty"`
	// optional field to identify trigger
	TriggerName string `json:"triggerName,omitempty"`
}

Event - holds information about new event from trigger

func (*Event) Scan

func (e *Event) Scan(src interface{}) error

func (*Event) Value

func (e *Event) Value() (driver.Value, error)

type EventNotification

type EventNotification struct {
	Name         string       `json:"name"`
	Message      string       `json:"message"`
	CreatedAt    time.Time    `json:"createdAt"`
	Type         Notification `json:"type"`
	Level        Level        `json:"level"`
	ResourceKind string       `json:"resourceKind"`
	Identifier   string       `json:"identifier"`
	// Channels is an optional variable to override
	// default channel(-s) when performing an update
	Channels []string `json:"-"`

	Metadata map[string]string `json:"metadata"`
}

EventNotification notification used for sending

type GetApprovalQuery

type GetApprovalQuery struct {
	ID         string
	Identifier string
	// Rejected   bool
	Archived bool
}

type JSONB

type JSONB map[string]interface{}

JSONB is stored as a JSON blob

func (*JSONB) Scan

func (b *JSONB) Scan(src interface{}) error

func (JSONB) Value

func (b JSONB) Value() (driver.Value, error)

type Level

type Level int

Level - event levet

const (
	LevelDebug Level = iota
	LevelInfo
	LevelSuccess
	LevelWarn
	LevelError
	LevelFatal
)

Available event levels

func ParseLevel

func ParseLevel(lvl string) (Level, error)

ParseLevel takes a string level and returns notification level constant.

func (Level) Color

func (l Level) Color() string

Color - used to assign different colors for events

func (Level) MarshalJSON

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

MarshalJSON is generated so Level satisfies json.Marshaler.

func (Level) String

func (l Level) String() string

func (*Level) UnmarshalJSON

func (r *Level) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so Level satisfies json.Unmarshaler.

type Notification

type Notification int

Notification - notification types used by notifier

const (
	PreProviderSubmitNotification Notification = iota
	PostProviderSubmitNotification

	// Kubernetes notification types
	NotificationPreDeploymentUpdate
	NotificationDeploymentUpdate

	// Helm notification types
	NotificationPreReleaseUpdate
	NotificationReleaseUpdate

	NotificationSystemEvent

	NotificationUpdateApproved
	NotificationUpdateRejected
)

available notification types for hooks

func (Notification) MarshalJSON

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

MarshalJSON is generated so Notification satisfies json.Marshaler.

func (Notification) String

func (n Notification) String() string

func (*Notification) UnmarshalJSON

func (r *Notification) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so Notification satisfies json.Unmarshaler.

type Policy

type Policy interface {
	ShouldUpdate(current, new string) (bool, error)
	Name() string
}

type ProviderType

type ProviderType int

ProviderType - provider type used to differentiate different providers when used with plugins

const (
	ProviderTypeUnknown ProviderType = iota
	ProviderTypeKubernetes
	ProviderTypeHelm
)

Known provider types

func (ProviderType) MarshalJSON

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

MarshalJSON is generated so ProviderType satisfies json.Marshaler.

func (ProviderType) String

func (t ProviderType) String() string

func (*ProviderType) UnmarshalJSON

func (r *ProviderType) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so ProviderType satisfies json.Unmarshaler.

type Repository

type Repository struct {
	Host   string `json:"host"`
	Name   string `json:"name"`
	Tag    string `json:"tag"`
	Digest string `json:"digest"` // optional digest field
	OldTag string
}

Repository - represents main docker repository fields that bow cares about

func (*Repository) String

func (r *Repository) String() string

String gives you [host/]team/repo[:tag] identifier

type TrackedImage

type TrackedImage struct {
	Image        *image.Reference  `json:"image"`
	Trigger      TriggerType       `json:"trigger"`
	PollSchedule string            `json:"pollSchedule"`
	Provider     string            `json:"provider"`
	Namespace    string            `json:"namespace"`
	Secrets      []string          `json:"secrets"`
	Meta         map[string]string `json:"meta"` // metadata supplied by providers
	// a list of pre-release tags, ie: 1.0.0-dev, 1.5.0-prod get translated into
	// dev, prod
	// combined semver tags
	Tags   []string `json:"tags"`
	Policy Policy   `json:"policy"`
}

TrackedImage - tracked image data+metadata

func (TrackedImage) String

func (i TrackedImage) String() string

type TriggerType

type TriggerType int

TriggerType - trigger types

const (
	TriggerTypeDefault  TriggerType = iota // default policy is to wait for external triggers
	TriggerTypePoll                        // poll policy sets up watchers for the affected repositories
	TriggerTypeApproval                    // fulfilled approval requests trigger events
)

Available trigger types

func ParseTrigger

func ParseTrigger(trigger string) TriggerType

ParseTrigger - parse trigger string into type

func (TriggerType) MarshalJSON

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

MarshalJSON is generated so TriggerType satisfies json.Marshaler.

func (TriggerType) String

func (t TriggerType) String() string

func (*TriggerType) UnmarshalJSON

func (r *TriggerType) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so TriggerType satisfies json.Unmarshaler.

type Version

type Version struct {
	Major      int64
	Minor      int64
	Patch      int64
	PreRelease string
	Metadata   string

	Original string
}

Version - version container

func (Version) String

func (v Version) String() string

type VersionInfo

type VersionInfo struct {
	Name          string `json:"name"`
	BuildDate     string `json:"buildDate"`
	Revision      string `json:"revision"`
	Version       string `json:"version"`
	APIVersion    string `json:"apiVersion"`
	GoVersion     string `json:"goVersion"`
	OS            string `json:"os"`
	Arch          string `json:"arch"`
	KernelVersion string `json:"kernelVersion"`
	Experimental  bool   `json:"experimental"`
}

VersionInfo describes version and runtime info.

type VersionResponse

type VersionResponse struct {
	Client *VersionInfo
	Server *VersionInfo
}

VersionResponse - version API call response

func (VersionResponse) ServerOK

func (v VersionResponse) ServerOK() bool

ServerOK returns true when the client could connect to the bow and parse the information received. It returns false otherwise.

Jump to

Keyboard shortcuts

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