contracts

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: MIT Imports: 7 Imported by: 13

README

Ziplinee CI

The ziplinee-ci-contracts library is part of the Ziplinee CI system documented at https://ziplinee.io.

Please file any issues related to Ziplinee CI at https://github.com/ziplineeci/ziplinee-ci-central/issues

Ziplinee-ci-contracts

This library has contracts for requests / responses between various components of the Ziplinee CI system.

Development

To start development run

git clone git@github.com:ziplineeci/ziplinee-ci-contracts.git
cd ziplinee-ci-contracts

Before committing your changes run

go test ./...
go mod tidy

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCredentialsForTrustedImage

func GetCredentialsForTrustedImage(credentials []*CredentialConfig, trustedImage TrustedImageConfig) map[string][]*CredentialConfig

GetCredentialsForTrustedImage returns all credentials of a certain type

func HasCanceledStatus

func HasCanceledStatus(steps []*BuildLogStep) bool

HasCanceledStatus returns true if aggregated status is canceled

func HasFailedStatus

func HasFailedStatus(steps []*BuildLogStep) bool

HasFailedStatus returns true if aggregated status is failed

func HasSucceededStatus

func HasSucceededStatus(steps []*BuildLogStep) bool

HasSucceededStatus returns true if aggregated status is succeeded

func HasUnknownStatus

func HasUnknownStatus(steps []*BuildLogStep) bool

HasUnknownStatus returns true if aggregated status is unknown

func IsAllowedBranchForCredential

func IsAllowedBranchForCredential(credential CredentialConfig, branch string) bool

IsAllowedBranchForCredential returns true if AllowedBranches is empty or matches the build/release job branch

func IsAllowedPipelineForCredential

func IsAllowedPipelineForCredential(credential CredentialConfig, fullRepositoryPath string) bool

IsAllowedPipelineForCredential returns true if AllowedPipelines is empty or matches the pipelines full path

func IsAllowedPipelineForTrustedImage

func IsAllowedPipelineForTrustedImage(trustedImage TrustedImageConfig, fullRepositoryPath string) bool

IsAllowedPipelineForTrustedImage returns true if AllowedPipelines is empty or matches the pipelines full path

func IsAllowedTrustedImageForCredential

func IsAllowedTrustedImageForCredential(credential CredentialConfig, trustedImage TrustedImageConfig) bool

IsAllowedTrustedImageForCredential returns true if AllowedTrustedImages is empty or matches the trusted image Path property

Types

type Bot

type Bot struct {
	Name            string                   `json:"name"`
	ID              string                   `json:"id,omitempty"`
	RepoSource      string                   `json:"repoSource,omitempty"`
	RepoOwner       string                   `json:"repoOwner,omitempty"`
	RepoName        string                   `json:"repoName,omitempty"`
	BotStatus       Status                   `json:"botStatus,omitempty"`
	Events          []manifest.ZiplineeEvent `json:"triggerEvents,omitempty"`
	InsertedAt      *time.Time               `json:"insertedAt,omitempty"`
	StartedAt       *time.Time               `json:"startedAt,omitempty"`
	UpdatedAt       *time.Time               `json:"updatedAt,omitempty"`
	Duration        *time.Duration           `json:"duration,omitempty"`
	PendingDuration *time.Duration           `json:"pendingDuration,omitempty"`
	ExtraInfo       *BotExtraInfo            `json:"extraInfo,omitempty"`
	Groups          []*Group                 `json:"groups,omitempty"`
	Organizations   []*Organization          `json:"organizations,omitempty"`
}

Bot represents a bot execution

func (*Bot) GetFullRepoPath

func (bot *Bot) GetFullRepoPath() string

GetFullRepoPath returns the full path of the bot repository with source, owner and name

type BotExtraInfo

type BotExtraInfo struct {
	MedianPendingDuration time.Duration `json:"medianPendingDuration"`
	MedianDuration        time.Duration `json:"medianDuration"`
}

BotExtraInfo contains extra information like aggregates over the last x releases

type BotLog

type BotLog struct {
	ID         string          `json:"id,omitempty"`
	RepoSource string          `json:"repoSource"`
	RepoOwner  string          `json:"repoOwner"`
	RepoName   string          `json:"repoName"`
	BotID      string          `json:"botID"`
	Steps      []*BuildLogStep `json:"steps"`
	InsertedAt time.Time       `json:"insertedAt"`
}

BotLog represents a bot log for a specific bot execution

func (*BotLog) GetAggregatedStatus

func (botLog *BotLog) GetAggregatedStatus() LogStatus

GetAggregatedStatus returns the status aggregated across all stages

func (*BotLog) HasCanceledStatus

func (botLog *BotLog) HasCanceledStatus() bool

HasCanceledStatus returns true if aggregated status is canceled

func (*BotLog) HasFailedStatus

func (botLog *BotLog) HasFailedStatus() bool

HasFailedStatus returns true if aggregated status is failed

func (*BotLog) HasSucceededStatus

func (botLog *BotLog) HasSucceededStatus() bool

HasSucceededStatus returns true if aggregated status is succeeded

func (*BotLog) HasUnknownStatus

func (botLog *BotLog) HasUnknownStatus() bool

HasUnknownStatus returns true if aggregated status is unknown

type BotParamsConfig

type BotParamsConfig struct {
	BotName string `json:"botName"`
	BotID   int    `json:"botID"`
}

BotParamsConfig has config specific to releases

type Build

type Build struct {
	ID                   string                     `json:"id"`
	RepoSource           string                     `json:"repoSource"`
	RepoOwner            string                     `json:"repoOwner"`
	RepoName             string                     `json:"repoName"`
	RepoBranch           string                     `json:"repoBranch"`
	RepoRevision         string                     `json:"repoRevision"`
	BuildVersion         string                     `json:"buildVersion,omitempty"`
	BuildStatus          Status                     `json:"buildStatus,omitempty"`
	Labels               []Label                    `json:"labels,omitempty"`
	ReleaseTargets       []ReleaseTarget            `json:"releaseTargets,omitempty"`
	Manifest             string                     `json:"manifest,omitempty"`
	ManifestWithDefaults string                     `json:"manifestWithDefaults,omitempty"`
	Commits              []GitCommit                `json:"commits,omitempty"`
	Triggers             []manifest.ZiplineeTrigger `json:"triggers,omitempty"`
	Events               []manifest.ZiplineeEvent   `json:"triggerEvents,omitempty"`
	InsertedAt           time.Time                  `json:"insertedAt"`
	StartedAt            *time.Time                 `json:"startedAt,omitempty"`
	UpdatedAt            time.Time                  `json:"updatedAt"`
	Duration             time.Duration              `json:"duration"`
	PendingDuration      *time.Duration             `json:"pendingDuration,omitempty"`
	ManifestObject       *manifest.ZiplineeManifest `json:"-"`
	Groups               []*Group                   `json:"groups,omitempty"`
	Organizations        []*Organization            `json:"organizations,omitempty"`
}

Build represents a specific build, including version number, repo, branch, revision, labels and manifest

func (*Build) GetFullRepoPath

func (build *Build) GetFullRepoPath() string

GetFullRepoPath returns the full path of the build repository with source, owner and name

type BuildEventType

type BuildEventType string
const (
	BuildEventTypeUnknown      BuildEventType = ""
	BuildEventTypeUpdateStatus BuildEventType = "updateStatus"
	BuildEventTypeClean        BuildEventType = "clean"
)

type BuildLog

type BuildLog struct {
	ID           string          `json:"id,omitempty"`
	RepoSource   string          `json:"repoSource"`
	RepoOwner    string          `json:"repoOwner"`
	RepoName     string          `json:"repoName"`
	RepoBranch   string          `json:"repoBranch"`
	RepoRevision string          `json:"repoRevision"`
	BuildID      string          `json:"buildID"`
	Steps        []*BuildLogStep `json:"steps"`
	InsertedAt   time.Time       `json:"insertedAt"`
}

BuildLog represents a build log for a specific revision

func (*BuildLog) GetAggregatedStatus

func (buildLog *BuildLog) GetAggregatedStatus() LogStatus

GetAggregatedStatus returns the status aggregated across all stages

func (*BuildLog) HasCanceledStatus

func (buildLog *BuildLog) HasCanceledStatus() bool

HasCanceledStatus returns true if aggregated status is canceled

func (*BuildLog) HasFailedStatus

func (buildLog *BuildLog) HasFailedStatus() bool

HasFailedStatus returns true if aggregated status is failed

func (*BuildLog) HasSucceededStatus

func (buildLog *BuildLog) HasSucceededStatus() bool

HasSucceededStatus returns true if aggregated status is succeeded

func (*BuildLog) HasUnknownStatus

func (buildLog *BuildLog) HasUnknownStatus() bool

HasUnknownStatus returns true if aggregated status is unknown

type BuildLogLine

type BuildLogLine struct {
	LineNumber int       `json:"line,omitempty"`
	Timestamp  time.Time `json:"timestamp"`
	StreamType string    `json:"streamType"`
	Text       string    `json:"text"`
}

BuildLogLine has low level log information

type BuildLogStep

type BuildLogStep struct {
	Step         string                   `json:"step"`
	Depth        int                      `json:"depth,omitempty"`
	Image        *BuildLogStepDockerImage `json:"image"`
	RunIndex     int                      `json:"runIndex,omitempty"`
	Duration     time.Duration            `json:"duration"`
	LogLines     []BuildLogLine           `json:"logLines"`
	ExitCode     int64                    `json:"exitCode"`
	Status       LogStatus                `json:"status"`
	AutoInjected bool                     `json:"autoInjected,omitempty"`
	NestedSteps  []*BuildLogStep          `json:"nestedSteps,omitempty"`
	Services     []*BuildLogStep          `json:"services,omitempty"`
}

BuildLogStep represents the logs for a single step of a pipeline

type BuildLogStepDockerImage

type BuildLogStepDockerImage struct {
	Name                   string        `json:"name"`
	Tag                    string        `json:"tag"`
	IsPulled               bool          `json:"isPulled"`
	ImageSize              int64         `json:"imageSize"`
	PullDuration           time.Duration `json:"pullDuration"`
	Error                  string        `json:"error,omitempty"`
	IsTrusted              bool          `json:"isTrusted,omitempty"`
	HasInjectedCredentials bool          `json:"hasInjectedCredentials,omitempty"`
}

BuildLogStepDockerImage represents info about the docker image used for a step

type BuildParamsConfig

type BuildParamsConfig struct {
	BuildID int `json:"buildID"`
}

BuildParamsConfig has config specific to builds

type BuilderConfig

type BuilderConfig struct {
	JobType JobType        `yaml:"jobType,omitempty" json:"jobType,omitempty"`
	Build   *Build         `yaml:"build,omitempty" json:"build,omitempty"`
	Release *Release       `yaml:"release,omitempty" json:"release,omitempty"`
	Bot     *Bot           `yaml:"bot,omitempty" json:"bot,omitempty"`
	Git     *GitConfig     `yaml:"git,omitempty" json:"git,omitempty"`
	Version *VersionConfig `yaml:"version,omitempty" json:"version,omitempty"`

	Track               *string                               `yaml:"track,omitempty" json:"track,omitempty"`
	DockerConfig        *DockerConfig                         `yaml:"dockerConfig,omitempty" json:"dockerConfig,omitempty"`
	Manifest            *manifest.ZiplineeManifest            `yaml:"manifest,omitempty" json:"manifest,omitempty"`
	ManifestPreferences *manifest.ZiplineeManifestPreferences `yaml:"manifestPreferences,omitempty" json:"manifestPreferences,omitempty"`
	JobName             *string                               `yaml:"jobName,omitempty" json:"jobName,omitempty"`
	Events              []manifest.ZiplineeEvent              `yaml:"triggerEvents,omitempty" json:"triggerEvents,omitempty"`
	CIServer            *CIServerConfig                       `yaml:"ciServer,omitempty" json:"ciServer,omitempty"`
	Stages              []*manifest.ZiplineeStage             `yaml:"stages,omitempty" json:"stages,omitempty"`
	Credentials         []*CredentialConfig                   `yaml:"credentials,omitempty" json:"credentials,omitempty"`
	TrustedImages       []*TrustedImageConfig                 `yaml:"trustedImages,omitempty" json:"trustedImages,omitempty"`
}

BuilderConfig parameterizes a build/release job

func (*BuilderConfig) GetCredentialsByType

func (c *BuilderConfig) GetCredentialsByType(filterType string) []*CredentialConfig

GetCredentialsByType returns all credentials of a certain type

func (*BuilderConfig) GetCredentialsForTrustedImage

func (c *BuilderConfig) GetCredentialsForTrustedImage(trustedImage TrustedImageConfig) map[string][]*CredentialConfig

GetCredentialsForTrustedImage returns all credentials of a certain type

func (*BuilderConfig) GetTrustedImage

func (c *BuilderConfig) GetTrustedImage(imagePath string) *TrustedImageConfig

GetTrustedImage returns a trusted image if the path without tag matches any of the trustedImages

func (*BuilderConfig) Validate

func (bc *BuilderConfig) Validate() (err error)

type CIServerConfig

type CIServerConfig struct {
	BaseURL          string    `json:"baseUrl"`
	BuilderEventsURL string    `json:"builderEventsUrl"`
	PostLogsURL      string    `json:"postLogsUrl"`
	CancelJobURL     string    `json:"cancelJobUrl"`
	JWT              string    `json:"jwt"`
	JWTExpiry        time.Time `json:"jwtExpiry"`
}

CIServerConfig has a number of config items related to communication or linking to the CI server

type CatalogEntity

type CatalogEntity struct {
	ID             string                 `json:"id,omitempty"`
	ParentKey      string                 `json:"parentKey,omitempty"`
	ParentValue    string                 `json:"parentValue,omitempty"`
	Key            string                 `json:"key,omitempty"`
	Value          string                 `json:"value,omitempty"`
	LinkedPipeline string                 `json:"linkedPipeline,omitempty"`
	Labels         []Label                `json:"labels,omitempty"`
	Metadata       map[string]interface{} `json:"metadata,omitempty"`
	InsertedAt     *time.Time             `json:"insertedAt,omitempty"`
	UpdatedAt      *time.Time             `json:"updatedAt,omitempty"`
}

CatalogEntity represents any entity stored in the catalog tree

type Client

type Client struct {
	ID            string          `json:"id,omitempty"`
	Active        bool            `json:"active,omitempty"`
	Name          string          `json:"name,omitempty"`
	ClientID      string          `json:"clientID,omitempty"`
	ClientSecret  string          `json:"clientSecret,omitempty"`
	Roles         []*string       `json:"roles,omitempty"`
	Organizations []*Organization `json:"organizations,omitempty"`
	CreatedAt     *time.Time      `json:"createdAt,omitempty"`
}

Client represents a client application registered with Ziplinee

type ContainerLinkDetail

type ContainerLinkDetail struct {
	Tag         string `json:"tag,omitempty"`
	PublicImage bool   `json:"publicImage,omitempty"`
}

type ContainerRepositoryCredentialConfig

type ContainerRepositoryCredentialConfig struct {
	Repository string `yaml:"repository"`
	Username   string `yaml:"username"`
	Password   string `yaml:"password"`
}

ContainerRepositoryCredentialConfig is used to authenticate for (private) container repositories (will be replaced by CredentialConfig eventually)

type CredentialConfig

type CredentialConfig struct {
	Name                 string                 `yaml:"name" json:"name"`
	Type                 string                 `yaml:"type" json:"type"`
	AllowedPipelines     string                 `yaml:"allowedPipelines,omitempty" json:"allowedPipelines,omitempty"`
	AllowedTrustedImages string                 `yaml:"allowedTrustedImages,omitempty" json:"allowedTrustedImages,omitempty"`
	AllowedBranches      string                 `yaml:"allowedBranches,omitempty" json:"allowedBranches,omitempty"`
	AdditionalProperties map[string]interface{} `yaml:",inline" json:"additionalProperties,omitempty"`
}

CredentialConfig is used to store credentials for every type of authenticated service you can use from docker registries, to kubernetes engine to, github apis, bitbucket; in combination with trusted images access to these centrally stored credentials can be limited

func AddCredentialsIfNotPresent

func AddCredentialsIfNotPresent(sourceCredentials []*CredentialConfig, newCredentials []*CredentialConfig) []*CredentialConfig

AddCredentialsIfNotPresent adds new credentials to source credentials if they're not present yet

func FilterCredentials

func FilterCredentials(credentials []*CredentialConfig, trustedImages []*TrustedImageConfig, fullRepositoryPath, branch string) []*CredentialConfig

FilterCredentials returns only credentials used by the trusted images

func FilterCredentialsByBranchesAllowList

func FilterCredentialsByBranchesAllowList(credentials []*CredentialConfig, branch string) (filteredCredentials []*CredentialConfig)

FilterCredentialsByBranchesAllowList returns the list of credentials filtered by the AllowedBranches property on the credentials

func FilterCredentialsByPipelinesAllowList

func FilterCredentialsByPipelinesAllowList(credentials []*CredentialConfig, fullRepositoryPath string) (filteredCredentials []*CredentialConfig)

FilterCredentialsByPipelinesAllowList returns the list of credentials filtered by the AllowedPipelines property on the credentials

func FilterCredentialsByTrustedImagesAllowList

func FilterCredentialsByTrustedImagesAllowList(credentials []*CredentialConfig, trustedImage TrustedImageConfig) (filteredCredentials []*CredentialConfig)

FilterCredentialsByTrustedImagesAllowList returns the list of credentials filtered by the AllowedTrustedImages property on the credentials

func GetCredentialsByType

func GetCredentialsByType(credentials []*CredentialConfig, filterType string) []*CredentialConfig

GetCredentialsByType returns all credentials of a certain type

func (*CredentialConfig) UnmarshalYAML

func (cc *CredentialConfig) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

UnmarshalYAML customizes unmarshalling an ZiplineeStage

type DockerConfig

type DockerConfig struct {
	RunType        DockerRunType         `yaml:"runType,omitempty" json:"runType,omitempty"`
	MTU            int                   `yaml:"mtu,omitempty" json:"mtu,omitempty"`
	BIP            string                `yaml:"bip,omitempty" json:"bip,omitempty"`
	Networks       []DockerNetworkConfig `yaml:"networks,omitempty" json:"networks,omitempty"`
	RegistryMirror string                `yaml:"registryMirror,omitempty" json:"registryMirror,omitempty"`
}

DockerConfig has configuration to configure docker in ziplinee-ci-builder

type DockerNetworkConfig

type DockerNetworkConfig struct {
	Name    string `json:"name"`
	Driver  string `json:"driver"`
	Subnet  string `json:"subnet"`
	Gateway string `json:"gateway"`
	Durable bool   `json:"durable"`
}

DockerNetworkConfig has settings for creating a user defined docker network to make service containers accessible by name from other containers

type DockerRunType

type DockerRunType string
const (
	// DockerRunTypeUnknown indicates the value couldn't be mapped
	DockerRunTypeUnknown DockerRunType = ""
	// DockerRunTypeDinD represents docker-inside-docker
	DockerRunTypeDinD DockerRunType = "dind"
	// DockerRunTypeDoD represents docker-outside-docker
	DockerRunTypeDoD DockerRunType = "dod"
)

type GitAuthor

type GitAuthor struct {
	Email    string `json:"email"`
	Name     string `json:"name"`
	Username string `json:"username"`
}

GitAuthor represents the author of a commmit

type GitCommit

type GitCommit struct {
	Message string    `json:"message"`
	Author  GitAuthor `json:"author"`
}

GitCommit represents a commit summary

type GitConfig

type GitConfig struct {
	RepoSource   string `json:"repoSource"`
	RepoOwner    string `json:"repoOwner"`
	RepoName     string `json:"repoName"`
	RepoBranch   string `json:"repoBranch"`
	RepoRevision string `json:"repoRevision"`
}

GitConfig contains all information for cloning the git repository for building/releasing a specific version

type Group

type Group struct {
	ID            string           `json:"id,omitempty"`
	Active        bool             `json:"active,omitempty"`
	Name          string           `json:"name,omitempty"`
	Description   string           `json:"description,omitempty"`
	Identities    []*GroupIdentity `json:"identities,omitempty"`
	Organizations []*Organization  `json:"organizations,omitempty"`
	Roles         []*string        `json:"roles,omitempty"`
}

Group represents a group of users as configured in different systems

type GroupIdentity

type GroupIdentity struct {
	Provider string `json:"provider,omitempty"`
	ID       string `json:"id,omitempty"`
	Name     string `json:"name,omitempty"`
}

GroupIdentity represents the various identities a group can have in different systems

type JobType

type JobType string
const (
	JobTypeUnknown JobType = ""
	JobTypeBuild   JobType = "build"
	JobTypeRelease JobType = "release"
	JobTypeBot     JobType = "bot"
)

type Label

type Label struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Label represents a key/value pair as set in a build manifest

type ListResponse

type ListResponse struct {
	Items      []interface{} `json:"items"`
	Pagination Pagination    `json:"pagination"`
}

ListResponse is a container for paginated filtered list items

type LogStatus

type LogStatus string
const (
	// LogStatusUnknown indicates execution never started for some reason
	LogStatusUnknown LogStatus = "UNKNOWN"
	// LogStatusSucceeded indicates execution was successful
	LogStatusSucceeded LogStatus = "SUCCEEDED"
	// LogStatusFailed indicates execution was not successful
	LogStatusFailed LogStatus = "FAILED"
	// LogStatusSkipped indicates execution was skipped
	LogStatusSkipped LogStatus = "SKIPPED"
	// LogStatusCanceled indicates execution was canceled
	LogStatusCanceled LogStatus = "CANCELED"
	// LogStatusPending indicates container is pulling
	LogStatusPending LogStatus = "PENDING"
	// LogStatusRunning indicates container is running
	LogStatusRunning LogStatus = "RUNNING"
)

func GetAggregatedStatus

func GetAggregatedStatus(steps []*BuildLogStep) LogStatus

GetAggregatedStatus returns the status aggregated across all stages

func (LogStatus) Equals

func (l LogStatus) Equals(s Status) bool

func (LogStatus) ToStatus

func (l LogStatus) ToStatus() Status

type LogType

type LogType string
const (
	// TypeStage indicates that a tail message is for a main stage or parallel stage
	LogTypeStage LogType = "stage"
	// TypeService indicates that a tail message is for a service container
	LogTypeService LogType = "service"
)

type Notification

type Notification struct {
	Type    NotificationType  `json:"type,omitempty"`
	Level   NotificationLevel `json:"level,omitempty"`
	Message string            `json:"message,omitempty"`
}

type NotificationLevel

type NotificationLevel string
const (
	NotificationLevelUnknown  NotificationLevel = ""
	NotificationLevelCritical NotificationLevel = "critical"
	NotificationLevelHigh     NotificationLevel = "high"
	NotificationLevelMedium   NotificationLevel = "medium"
	NotificationLevelLow      NotificationLevel = "low"
)

type NotificationLinkType

type NotificationLinkType string
const (
	NotificationLinkTypeUnknown   NotificationLinkType = ""
	NotificationLinkTypePipeline  NotificationLinkType = "pipeline"
	NotificationLinkTypeContainer NotificationLinkType = "container"
)

type NotificationRecord

type NotificationRecord struct {
	ID       string               `json:"id,omitempty"`
	LinkType NotificationLinkType `json:"linkType,omitempty"`
	LinkID   string               `json:"linkID,omitempty"`

	// fields mapped to link_detail column
	PipelineDetail  *PipelineLinkDetail  `json:"pipelineDetail,omitempty"`
	ContainerDetail *ContainerLinkDetail `json:"containerDetail,omitempty"`

	Source        string          `json:"source,omitempty"`
	Notifications []Notification  `json:"notifications,omitempty"`
	InsertedAt    *time.Time      `json:"insertedAt,omitempty"`
	Groups        []*Group        `json:"groups,omitempty"`
	Organizations []*Organization `json:"organizations,omitempty"`
}

func (*NotificationRecord) GetGroups

func (nr *NotificationRecord) GetGroups() ([]byte, error)

func (*NotificationRecord) GetLinkDetail

func (nr *NotificationRecord) GetLinkDetail() ([]byte, error)

func (*NotificationRecord) GetNotifications

func (nr *NotificationRecord) GetNotifications() ([]byte, error)

func (*NotificationRecord) GetOrganizations

func (nr *NotificationRecord) GetOrganizations() ([]byte, error)

func (*NotificationRecord) SetGroups

func (nr *NotificationRecord) SetGroups(groups []byte) error

func (*NotificationRecord) SetLinkDetail

func (nr *NotificationRecord) SetLinkDetail(linkDetail []byte) error

func (*NotificationRecord) SetNotifications

func (nr *NotificationRecord) SetNotifications(notifications []byte) error

func (*NotificationRecord) SetOrganizations

func (nr *NotificationRecord) SetOrganizations(organizations []byte) error

type NotificationType

type NotificationType string
const (
	NotificationTypeUnknown       NotificationType = ""
	NotificationTypeVulnerability NotificationType = "vulnerability"
	NotificationTypeWarning       NotificationType = "warning"
)

type Organization

type Organization struct {
	ID         string                  `json:"id,omitempty"`
	Active     bool                    `json:"active,omitempty"`
	Name       string                  `json:"name,omitempty"`
	Identities []*OrganizationIdentity `json:"identities,omitempty"`
	Roles      []*string               `json:"roles,omitempty"`
}

Organization represents an organization that uses a multi-tenancy installation

type OrganizationIdentity

type OrganizationIdentity struct {
	Provider string `json:"provider,omitempty"`
	ID       string `json:"id,omitempty"`
	Name     string `json:"name,omitempty"`
}

OrganizationIdentity represents the various identities an organization can have in different systems

type Pagination

type Pagination struct {
	Page       int `json:"page"`
	Size       int `json:"size"`
	TotalPages int `json:"totalPages"`
	TotalItems int `json:"totalItems"`
}

Pagination indicates the current page, the size of the pages and total pages / items

type Pipeline

type Pipeline struct {
	ID                   string                     `json:"id"`
	RepoSource           string                     `json:"repoSource"`
	RepoOwner            string                     `json:"repoOwner"`
	RepoName             string                     `json:"repoName"`
	RepoBranch           string                     `json:"repoBranch"`
	RepoRevision         string                     `json:"repoRevision"`
	BuildVersion         string                     `json:"buildVersion,omitempty"`
	BuildStatus          Status                     `json:"buildStatus,omitempty"`
	Labels               []Label                    `json:"labels,omitempty"`
	ReleaseTargets       []ReleaseTarget            `json:"releaseTargets,omitempty"`
	Manifest             string                     `json:"manifest,omitempty"`
	ManifestWithDefaults string                     `json:"manifestWithDefaults,omitempty"`
	Commits              []GitCommit                `json:"commits,omitempty"`
	Triggers             []manifest.ZiplineeTrigger `json:"triggers,omitempty"`
	Events               []manifest.ZiplineeEvent   `json:"triggerEvents,omitempty"`
	Archived             bool                       `json:"archived,omitempty"`
	InsertedAt           time.Time                  `json:"insertedAt"`
	StartedAt            *time.Time                 `json:"startedAt,omitempty"`
	UpdatedAt            time.Time                  `json:"updatedAt"`
	Duration             time.Duration              `json:"duration"`
	PendingDuration      *time.Duration             `json:"pendingDuration,omitempty"`
	LastUpdatedAt        time.Time                  `json:"lastUpdatedAt"`
	ManifestObject       *manifest.ZiplineeManifest `json:"-"`
	RecentCommitters     []string                   `json:"recentCommitters,omitempty"`
	RecentReleasers      []string                   `json:"recentReleasers,omitempty"`
	ExtraInfo            *PipelineExtraInfo         `json:"extraInfo,omitempty"`
	Groups               []*Group                   `json:"groups,omitempty"`
	Organizations        []*Organization            `json:"organizations,omitempty"`
}

Pipeline represents a pipeline with the latest build info, including version number, repo, branch, revision, labels and manifest

func (*Pipeline) GetFullRepoPath

func (pipeline *Pipeline) GetFullRepoPath() string

GetFullRepoPath returns the full path of the pipeline repository with source, owner and name

type PipelineExtraInfo

type PipelineExtraInfo struct {
	MedianPendingDuration time.Duration `json:"medianPendingDuration"`
	MedianDuration        time.Duration `json:"medianDuration"`
}

PipelineExtraInfo contains extra information like aggregates over the last x builds

type PipelineLinkDetail

type PipelineLinkDetail struct {
	Branch   string `json:"branch,omitempty"`
	Revision string `json:"revision"`
	Version  string `json:"version,omitempty"`
	Status   Status `json:"status,omitempty"`
}

type Release

type Release struct {
	Name            string                   `json:"name"`
	Action          string                   `json:"action,omitempty"`
	ID              string                   `json:"id,omitempty"`
	RepoSource      string                   `json:"repoSource,omitempty"`
	RepoOwner       string                   `json:"repoOwner,omitempty"`
	RepoName        string                   `json:"repoName,omitempty"`
	ReleaseVersion  string                   `json:"releaseVersion,omitempty"`
	ReleaseStatus   Status                   `json:"releaseStatus,omitempty"`
	Events          []manifest.ZiplineeEvent `json:"triggerEvents,omitempty"`
	InsertedAt      *time.Time               `json:"insertedAt,omitempty"`
	StartedAt       *time.Time               `json:"startedAt,omitempty"`
	UpdatedAt       *time.Time               `json:"updatedAt,omitempty"`
	Duration        *time.Duration           `json:"duration,omitempty"`
	PendingDuration *time.Duration           `json:"pendingDuration,omitempty"`
	ExtraInfo       *ReleaseExtraInfo        `json:"extraInfo,omitempty"`
	Groups          []*Group                 `json:"groups,omitempty"`
	Organizations   []*Organization          `json:"organizations,omitempty"`
}

Release represents a release of a pipeline

func (*Release) GetFullRepoPath

func (release *Release) GetFullRepoPath() string

GetFullRepoPath returns the full path of the release repository with source, owner and name

type ReleaseExtraInfo

type ReleaseExtraInfo struct {
	MedianPendingDuration time.Duration `json:"medianPendingDuration"`
	MedianDuration        time.Duration `json:"medianDuration"`
}

ReleaseExtraInfo contains extra information like aggregates over the last x releases

type ReleaseLog

type ReleaseLog struct {
	ID         string          `json:"id,omitempty"`
	RepoSource string          `json:"repoSource"`
	RepoOwner  string          `json:"repoOwner"`
	RepoName   string          `json:"repoName"`
	ReleaseID  string          `json:"releaseID"`
	Steps      []*BuildLogStep `json:"steps"`
	InsertedAt time.Time       `json:"insertedAt"`
}

ReleaseLog represents a release log for a specific release

func (*ReleaseLog) GetAggregatedStatus

func (releaseLog *ReleaseLog) GetAggregatedStatus() LogStatus

GetAggregatedStatus returns the status aggregated across all stages

func (*ReleaseLog) HasCanceledStatus

func (releaseLog *ReleaseLog) HasCanceledStatus() bool

HasCanceledStatus returns true if aggregated status is canceled

func (*ReleaseLog) HasFailedStatus

func (releaseLog *ReleaseLog) HasFailedStatus() bool

HasFailedStatus returns true if aggregated status is failed

func (*ReleaseLog) HasSucceededStatus

func (releaseLog *ReleaseLog) HasSucceededStatus() bool

HasSucceededStatus returns true if aggregated status is succeeded

func (*ReleaseLog) HasUnknownStatus

func (releaseLog *ReleaseLog) HasUnknownStatus() bool

HasUnknownStatus returns true if aggregated status is unknown

type ReleaseParamsConfig

type ReleaseParamsConfig struct {
	ReleaseName   string `json:"releaseName"`
	ReleaseID     int    `json:"releaseID"`
	ReleaseAction string `json:"releaseAction,omitempty"`
	TriggeredBy   string `json:"triggeredBy,omitempty"`
}

ReleaseParamsConfig has config specific to releases

type ReleaseTarget

type ReleaseTarget struct {
	Name           string                           `json:"name"`
	Actions        []manifest.ZiplineeReleaseAction `json:"actions,omitempty"`
	ActiveReleases []Release                        `json:"activeReleases,omitempty"`
}

ReleaseTarget contains the information to visualize and trigger release

type Status

type Status string
const (
	// StatusPending indicates container is pulling
	StatusPending Status = "pending"
	// StatusRunning indicates container is running
	StatusRunning Status = "running"
	// StatusSucceeded indicates execution was successful
	StatusSucceeded Status = "succeeded"
	// StatusFailed indicates execution was not successful
	StatusFailed Status = "failed"
	// StatusCanceling indicates execution is canceling
	StatusCanceling Status = "canceling"
	// StatusCanceled indicates execution was canceled
	StatusCanceled Status = "canceled"

	// StatusUnknown provides a default but not allowed status for unmarshalling
	StatusUnknown Status = ""
)

func (Status) Equals

func (s Status) Equals(l LogStatus) bool

func (Status) ToLogStatus

func (s Status) ToLogStatus() LogStatus

type TailLogLine

type TailLogLine struct {
	Step         string                   `json:"step"`
	ParentStage  string                   `json:"parentStage,omitempty"`
	Type         LogType                  `json:"type"`
	Depth        int                      `json:"depth,omitempty"`
	RunIndex     int                      `json:"runIndex,omitempty"`
	LogLine      *BuildLogLine            `json:"logLine,omitempty"`
	Image        *BuildLogStepDockerImage `json:"image,omitempty"`
	Duration     *time.Duration           `json:"duration,omitempty"`
	ExitCode     *int64                   `json:"exitCode,omitempty"`
	Status       *LogStatus               `json:"status,omitempty"`
	AutoInjected *bool                    `json:"autoInjected,omitempty"`
}

TailLogLine returns a log line for streaming logs to gui during a build

type TrustedImageConfig

type TrustedImageConfig struct {
	ImagePath               string   `yaml:"path" json:"path"`
	RunPrivileged           bool     `yaml:"runPrivileged" json:"runPrivileged"`
	RunDocker               bool     `yaml:"runDocker" json:"runDocker"`
	AllowCommands           bool     `yaml:"allowCommands" json:"allowCommands"`
	AllowNotifications      bool     `yaml:"allowNotifications" json:"allowNotifications"`
	InjectedCredentialTypes []string `yaml:"injectedCredentialTypes,omitempty" json:"injectedCredentialTypes,omitempty"`
	AllowedPipelines        string   `yaml:"allowedPipelines,omitempty" json:"allowedPipelines,omitempty"`
}

TrustedImageConfig allows trusted images to run docker commands or receive specific credentials

func FilterTrustedImages

func FilterTrustedImages(trustedImages []*TrustedImageConfig, stages []*manifest.ZiplineeStage, fullRepositoryPath string) []*TrustedImageConfig

FilterTrustedImages returns only trusted images used in the stages

func FilterTrustedImagesByPipelinesAllowList

func FilterTrustedImagesByPipelinesAllowList(trustedImages []*TrustedImageConfig, fullRepositoryPath string) (filteredTrustedImages []*TrustedImageConfig)

FilterTrustedImagesByPipelinesAllowList returns the list of trusted images filtered by the AllowedTrustedPipelines property on the trusted images

func GetTrustedImage

func GetTrustedImage(trustedImages []*TrustedImageConfig, imagePath string) *TrustedImageConfig

GetTrustedImage returns a trusted image if the path without tag matches any of the trustedImages

type User

type User struct {
	ID                  string                 `json:"id,omitempty"`
	Active              bool                   `json:"active,omitempty"`
	Identities          []*UserIdentity        `json:"identities,omitempty"`
	Groups              []*Group               `json:"groups,omitempty"`
	Organizations       []*Organization        `json:"organizations,omitempty"`
	Roles               []*string              `json:"roles,omitempty"`
	Preferences         map[string]interface{} `json:"preferences,omitempty"`
	FirstVisit          *time.Time             `json:"firstVisit,omitempty"`
	LastVisit           *time.Time             `json:"lastVisit,omitempty"`
	CurrentProvider     string                 `json:"currentProvider,omitempty"`
	CurrentOrganization string                 `json:"currentOrganization,omitempty"`

	// computed fields
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
}

User represents a user of Ziplinee

func (*User) AddRole

func (u *User) AddRole(role string)

AddRole adds a role if it's not present

func (*User) GetEmail

func (u *User) GetEmail() string

GetEmail returns the first identity email address

func (*User) GetName

func (u *User) GetName() string

GetName returns the first identity name

func (*User) GetProvider

func (u *User) GetProvider() string

GetProvider returns the first identity provider

func (*User) HasRole

func (u *User) HasRole(role string) bool

HasRole returns true if a user has the parameterized role

func (*User) RemoveRole

func (u *User) RemoveRole(role string)

RemoveRole removes a role if it's present

type UserIdentity

type UserIdentity struct {
	Provider string `json:"provider,omitempty"`
	ID       string `json:"id,omitempty"`
	Email    string `json:"email,omitempty"`
	Name     string `json:"name,omitempty"`
	Avatar   string `json:"avatar,omitempty"`
}

UserIdentity represents the various identities a user can have in different systems

type VersionConfig

type VersionConfig struct {
	Version                 string  `json:"version"`
	Major                   *int    `json:"major,omitempty"`
	Minor                   *int    `json:"minor,omitempty"`
	Patch                   *string `json:"patch,omitempty"`
	Label                   *string `json:"label,omitempty"`
	AutoIncrement           *int    `json:"autoincrement,omitempty"`
	CurrentCounter          int     `json:"currentCounter,omitempty"`
	MaxCounter              int     `json:"maxCounter,omitempty"`
	MaxCounterCurrentBranch int     `json:"maxCounterCurrentBranch,omitempty"`
}

VersionConfig contains all information regarding the version number to build or release

type Warning

type Warning struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

Warning is used to issue warnings for not following best practices

type ZiplineeCiBuilderEvent added in v0.0.2

type ZiplineeCiBuilderEvent struct {
	BuildEventType BuildEventType `json:"buildEventType,omitempty"`
	JobType        JobType        `json:"jobType,omitempty"`
	JobName        string         `json:"job_name"`
	PodName        string         `json:"pod_name,omitempty"`

	Build   *Build     `json:"build,omitempty"`
	Release *Release   `json:"release,omitempty"`
	Bot     *Bot       `json:"bot,omitempty"`
	Git     *GitConfig `json:"git,omitempty"`
}

func (*ZiplineeCiBuilderEvent) GetStatus added in v0.0.2

func (bc *ZiplineeCiBuilderEvent) GetStatus() Status

func (*ZiplineeCiBuilderEvent) SetStatus added in v0.0.2

func (bc *ZiplineeCiBuilderEvent) SetStatus(status Status)

func (*ZiplineeCiBuilderEvent) Validate added in v0.0.2

func (bc *ZiplineeCiBuilderEvent) Validate() (err error)

Jump to

Keyboard shortcuts

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