gcloudutils

package
v0.21.7 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

README

This project contains some utilities for GCloud, most importantly a library for building google cloud subscriber plugins for Solobot CI builds.

To build a new cloud subscriber, simply do:

subscriber, err := NewSolobotCloudSubscriber(ctx context.Context)
if err != nil {
  // handle
}
subscriber.RegisterHandler(myCustomHandler)
if err := subscriber.Run(); err != nil {
  // handle
}

Documentation

Index

Constants

View Source
const (
	BranchMaster   = "master"
	CloudbuildFile = "cloudbuild.yaml"

	MissingSourceError = "unable to resolve source"
)
View Source
const (
	StatusUnknown       BuildStatus = "STATUS_UNKNOWN"
	StatusQueued                    = "QUEUED"
	StatusWorking                   = "WORKING"
	StatusSuccess                   = "SUCCESS"
	StatusFailure                   = "FAILURE"
	StatusInternalError             = "INTERNAL_ERROR"
	StatusTimeout                   = "TIMEOUT"
	StatusCancelled                 = "CANCELLED"
)
View Source
const (
	TOPIC = "cloud-builds"
)

Variables

View Source
var (
	DefaultRoot = "/etc/gce"
)

Functions

func BuildIsDone

func BuildIsDone(bs string) bool

func BuildIsFailure

func BuildIsFailure(bs string) bool

func BuildIsQueued

func BuildIsQueued(bs string) bool

func BuildIsSuccess

func BuildIsSuccess(bs string) bool

func GetReleaseVersionTag

func GetReleaseVersionTag(m *cloudbuild.Build) string

attempts to valid release tag returns empty string if none exists

func GetRepoName

func GetRepoName(m *cloudbuild.Build) string

attempts to return repo name returns empty string if none exists

func GetTargetCommitSh

func GetTargetCommitSh(m *cloudbuild.Build) string

func GetValidTriggeredBranchName

func GetValidTriggeredBranchName(m *cloudbuild.Build) (string, bool)

Used by slack listener to see if the current branch is a valid branch to respond to

func HandleCloudBuildEvent

func HandleCloudBuildEvent(ctx context.Context, registry *CloudBuildRegistry, build *cloudbuild.Build)

func IsMissingSourceError

func IsMissingSourceError(err string) bool

func IsPublic added in v0.9.14

func IsPublic(ctx context.Context, projectId, repoName string) bool

func NewCloudBuildClient

func NewCloudBuildClient(ctx context.Context, projectId string) (*cloudbuild.Service, error)

func NewPubSubClient

func NewPubSubClient(ctx context.Context, projectId string) (*pubsub.Client, error)

func NewStorageClient

func NewStorageClient(ctx context.Context, projectId string) (*storage.Client, error)

Types

type BuildStatus

type BuildStatus string

type CloudBot

type CloudBot struct {
	// contains filtered or unexported fields
}

func NewCloudBot

func NewCloudBot(ctx context.Context, projectIds []string, subscriberId string, handlers ...CloudBuildEventHandler) (*CloudBot, error)

func (*CloudBot) Run

func (b *CloudBot) Run(ctx context.Context) error

type CloudBuildEventHandler

type CloudBuildEventHandler interface {
	CloudBuild(ctx context.Context, build *cloudbuild.Build) error
}

type CloudBuildRegistry

type CloudBuildRegistry struct {
	// contains filtered or unexported fields
}

func (*CloudBuildRegistry) AddEventHandler

func (r *CloudBuildRegistry) AddEventHandler(handler CloudBuildEventHandler)

type CloudSubscriber

type CloudSubscriber struct {
	// contains filtered or unexported fields
}

func NewCloudSubscriber

func NewCloudSubscriber(ctx context.Context, projectId string, subscriptionId string) (*CloudSubscriber, error)

func (*CloudSubscriber) GetProjectId

func (cs *CloudSubscriber) GetProjectId() string

func (*CloudSubscriber) RegisterHandler

func (cs *CloudSubscriber) RegisterHandler(handler CloudBuildEventHandler)

func (*CloudSubscriber) Run

func (cs *CloudSubscriber) Run(ctx context.Context) error

type SplitRepoName

type SplitRepoName struct {
	Host string
	Org  string
	Repo string
}

func GetRepoNameFromRepoSource

func GetRepoNameFromRepoSource(rs *cloudbuild.RepoSource) *SplitRepoName

repo source name start as <source>_<owner>_<repo> github_solo-io_solobot transforms the above into the sum of it's parts

func GetSplitRepoName

func GetSplitRepoName(m *cloudbuild.Build) *SplitRepoName

type Tags

type Tags []string

func InitializeTags

func InitializeTags(input []string) Tags

func (Tags) AddBuilderTag added in v0.10.10

func (t Tags) AddBuilderTag(builder string) Tags

func (Tags) AddInstallationIdTag

func (t Tags) AddInstallationIdTag(instId int64) Tags

func (Tags) AddPRTag added in v0.10.6

func (t Tags) AddPRTag(pr int) Tags

func (Tags) AddRefTag

func (t Tags) AddRefTag(ref string) Tags

func (Tags) AddReleaseTag

func (t Tags) AddReleaseTag(tag string) Tags

func (Tags) AddRepoTag

func (t Tags) AddRepoTag(repo string) Tags

func (Tags) AddShaTag

func (t Tags) AddShaTag(sha string) Tags

func (Tags) GetBuilderTag added in v0.10.10

func (t Tags) GetBuilderTag() string

func (Tags) GetInstallationId

func (t Tags) GetInstallationId() int64

func (Tags) GetPR added in v0.10.6

func (t Tags) GetPR() int

func (Tags) GetRef

func (t Tags) GetRef() string

returns "" for empty

func (Tags) GetReleaseTag

func (t Tags) GetReleaseTag() string

returns "" for empty

func (Tags) GetRepo

func (t Tags) GetRepo() string

returns "" for empty

func (Tags) GetSha

func (t Tags) GetSha() string

returns "" for empty

func (Tags) IsReleaseBuild

func (t Tags) IsReleaseBuild() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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