Documentation ¶
Overview ¶
Package build_signaler is a generated GoMock package.
Index ¶
- Variables
- func BuildInitialWerkerTask(buildConf *pb.BuildConfig, hash string, authToken string, branch string, ...) *pb.WerkerTask
- func CheckForBuildFile(buildFile []byte, deserializer *deserialize.Deserializer) (*pb.BuildConfig, error)
- func GenerateChangesetFromVCS(handler models.VCSHandler, ...) (*pb.ChangesetData, error)
- func GenerateNoPreviousHeadChangeset(handler models.VCSHandler, acctRepo, branch, latestCommitHash string) (*pb.ChangesetData, error)
- func GetConfig(repoFullName string, checkoutCommit string, ...) (*pb.BuildConfig, error)
- func PopulateStageResult(sr *models.StageResult, status int, lastMsg, errMsg string)
- type CommitPushWerkerTeller
- type DummyVcsHandler
- func (d *DummyVcsHandler) GetChangedFiles(acctRepo, latesthash, earliestHash string) ([]string, error)
- func (d *DummyVcsHandler) GetCommit(acctRepo, hash string) (*pb.Commit, error)
- func (d *DummyVcsHandler) GetFile(filePath string, fullRepoName string, commitHash string) (bytez []byte, err error)
- func (d *DummyVcsHandler) Reset()
- type MockCommitPushWerkerTeller
- type MockCommitPushWerkerTellerMockRecorder
- type MockPRWerkerTeller
- type MockPRWerkerTellerMockRecorder
- type PRWerkerTeller
- type PushWerkerTeller
- type Signaler
- type TestConsul
- type TestSingleProducer
- type TestStorage
- type TestVault
Constants ¶
This section is empty.
Variables ¶
var BuildFileMasterOnly = []byte(`image: golang:1.10.2-alpine3.7
buildTool: go
env:
- "BUILD_DIR=/go/src/bitbucket.org/level11consulting/"
branches:
- master
stages:
- name: install consul for testing
script:
- apk update
- apk add unzip
- cd /go/bin
- wget https://releases.hashicorp.com/consul/1.1.0/consul_1.1.0_linux_amd64.zip
- echo "unzipping"
- unzip consul_1.1.0_linux_amd64.zip
- echo "Done"
- name: configure git
script:
- git config --global url."git@bitbucket.org:".insteadOf "https://bitbucket.org/"
- name: make stoopid dep thing
script:
- mkdir -p $BUILD_DIR
- cp -r $WORKSPACE $BUILD_DIR/go-til
- name: install dep & ensure dependencies
script:
- cd $BUILD_DIR/go-til
- go get -u github.com/golang/dep/...
- dep ensure -v
- name: test
script:
- cd $BUILD_DIR
- go test ./...
`)
var Buildfile = []byte(`image: golang:1.10.2-alpine3.7
buildTool: go
env:
- "BUILD_DIR=/go/src/bitbucket.org/level11consulting/"
branches:
- ALL
stages:
- name: install consul for testing
script:
- apk update
- apk add unzip
- cd /go/bin
- wget https://releases.hashicorp.com/consul/1.1.0/consul_1.1.0_linux_amd64.zip
- echo "unzipping"
- unzip consul_1.1.0_linux_amd64.zip
- echo "Done"
- name: configure git
script:
- git config --global url."git@bitbucket.org:".insteadOf "https://bitbucket.org/"
- name: make stoopid dep thing
script:
- mkdir -p $BUILD_DIR
- cp -r $WORKSPACE $BUILD_DIR/go-til
- name: install dep & ensure dependencies
script:
- cd $BUILD_DIR/go-til
- go get -u github.com/golang/dep/...
- dep ensure -v
- name: test
script:
- cd $BUILD_DIR
- go test ./...
`)
Functions ¶
func BuildInitialWerkerTask ¶
func BuildInitialWerkerTask(buildConf *pb.BuildConfig, hash string, authToken string, branch string, acctRepo string, sigType pb.SignaledBy, prData *pb.PrWerkerData, vcsType pb.SubCredType) *pb.WerkerTask
BuildInitialWerkerTask will create a WerkerTask object with all the fields taht are not reliant on a database transaction, basically everyhting we know right when we know we want to try and queue a build todo: take out the hard coded VcsType of bitbucket
func CheckForBuildFile ¶
func CheckForBuildFile(buildFile []byte, deserializer *deserialize.Deserializer) (*pb.BuildConfig, error)
CheckForBuildFile will try to retrieve an ocelot.yaml file for a repository and return the protobuf message
func GenerateChangesetFromVCS ¶ added in v0.7.3
func GenerateChangesetFromVCS(handler models.VCSHandler, acctRepo, branch, latestCommitHash, earliestCommitHash string, commits []*pb.Commit) (*pb.ChangesetData, error)
GenerateChangeSetFromVCS will retrieve and fill out fields of a Changeset by calling the handler for the diff of the latest Commit Hash and earliest Commit hash
and by pulling out all commit messages from the commit list. these will be used as data to check criteria of triggers
func GenerateNoPreviousHeadChangeset ¶ added in v0.7.3
func GenerateNoPreviousHeadChangeset(handler models.VCSHandler, acctRepo, branch, latestCommitHash string) (*pb.ChangesetData, error)
GenerateNoPreviousHeadChangeset
func GetConfig ¶
func GetConfig(repoFullName string, checkoutCommit string, deserializer *deserialize.Deserializer, vcsHandler models.VCSHandler) (*pb.BuildConfig, error)
todo: pull out check for vcsHandler == nil logic, then this can be just GetConfig() todo (cont): write something in remote to switch between subtypes to instantiate the correct VCSHandler implementation GetConfig returns the protobuf ocelot.yaml, a valid bitbucket token belonging to that repo, and possible err. If a VcsHandler is passed, this method will use the existing handler to retrieve the bb config. In that case, ***IT WILL NOT RETURN A VALID TOKEN FOR YOU - ONLY BUILD CONFIG***
func PopulateStageResult ¶
func PopulateStageResult(sr *models.StageResult, status int, lastMsg, errMsg string)
Types ¶
type CommitPushWerkerTeller ¶ added in v0.7.3
type CommitPushWerkerTeller interface {
TellWerker(push *pb.Push, conf *Signaler, handler models.VCSHandler, token string, force bool, sigBy pb.SignaledBy) error
}
type DummyVcsHandler ¶
type DummyVcsHandler struct { Fail bool Filecontents []byte ChangedFiles []string ReturnCommit *pb.Commit CommitNotFound bool models.VCSHandler NotFound bool }
func (*DummyVcsHandler) GetChangedFiles ¶ added in v0.7.3
func (d *DummyVcsHandler) GetChangedFiles(acctRepo, latesthash, earliestHash string) ([]string, error)
func (*DummyVcsHandler) GetCommit ¶ added in v0.7.3
func (d *DummyVcsHandler) GetCommit(acctRepo, hash string) (*pb.Commit, error)
func (*DummyVcsHandler) Reset ¶ added in v0.7.3
func (d *DummyVcsHandler) Reset()
set all flags to their default nil value
type MockCommitPushWerkerTeller ¶ added in v0.7.3
type MockCommitPushWerkerTeller struct {
// contains filtered or unexported fields
}
MockCommitPushWerkerTeller is a mock of CommitPushWerkerTeller interface
func NewMockCommitPushWerkerTeller ¶ added in v0.7.3
func NewMockCommitPushWerkerTeller(ctrl *gomock.Controller) *MockCommitPushWerkerTeller
NewMockCommitPushWerkerTeller creates a new mock instance
func (*MockCommitPushWerkerTeller) EXPECT ¶ added in v0.7.3
func (m *MockCommitPushWerkerTeller) EXPECT() *MockCommitPushWerkerTellerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockCommitPushWerkerTeller) TellWerker ¶ added in v0.7.3
func (m *MockCommitPushWerkerTeller) TellWerker(push *pb.Push, conf *Signaler, handler models.VCSHandler, token string, force bool, sigBy pb.SignaledBy) error
TellWerker mocks base method
type MockCommitPushWerkerTellerMockRecorder ¶ added in v0.7.3
type MockCommitPushWerkerTellerMockRecorder struct {
// contains filtered or unexported fields
}
MockCommitPushWerkerTellerMockRecorder is the mock recorder for MockCommitPushWerkerTeller
func (*MockCommitPushWerkerTellerMockRecorder) TellWerker ¶ added in v0.7.3
func (mr *MockCommitPushWerkerTellerMockRecorder) TellWerker(push, conf, handler, token, force, sigBy interface{}) *gomock.Call
TellWerker indicates an expected call of TellWerker
type MockPRWerkerTeller ¶ added in v0.7.3
type MockPRWerkerTeller struct {
// contains filtered or unexported fields
}
MockPRWerkerTeller is a mock of PRWerkerTeller interface
func NewMockPRWerkerTeller ¶ added in v0.7.3
func NewMockPRWerkerTeller(ctrl *gomock.Controller) *MockPRWerkerTeller
NewMockPRWerkerTeller creates a new mock instance
func (*MockPRWerkerTeller) EXPECT ¶ added in v0.7.3
func (m *MockPRWerkerTeller) EXPECT() *MockPRWerkerTellerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockPRWerkerTeller) TellWerker ¶ added in v0.7.3
func (m *MockPRWerkerTeller) TellWerker(push *pb.PullRequest, prData *pb.PrWerkerData, conf *Signaler, handler models.VCSHandler, token string, force bool, sigBy pb.SignaledBy) error
TellWerker mocks base method
type MockPRWerkerTellerMockRecorder ¶ added in v0.7.3
type MockPRWerkerTellerMockRecorder struct {
// contains filtered or unexported fields
}
MockPRWerkerTellerMockRecorder is the mock recorder for MockPRWerkerTeller
func (*MockPRWerkerTellerMockRecorder) TellWerker ¶ added in v0.7.3
func (mr *MockPRWerkerTellerMockRecorder) TellWerker(push, prData, conf, handler, token, force, sigBy interface{}) *gomock.Call
TellWerker indicates an expected call of TellWerker
type PRWerkerTeller ¶ added in v0.7.3
type PRWerkerTeller interface {
TellWerker(push *pb.PullRequest, prData *pb.PrWerkerData, conf *Signaler, handler models.VCSHandler, token string, force bool, sigBy pb.SignaledBy) error
}
type PushWerkerTeller ¶ added in v0.7.3
type PushWerkerTeller struct{}
func (*PushWerkerTeller) TellWerker ¶ added in v0.7.3
func (pwt *PushWerkerTeller) TellWerker(push *pb.Push, conf *Signaler, handler models.VCSHandler, token string, force bool, sigBy pb.SignaledBy) (err error)
TellWerker will get config off of the HeadCommit Hash, Build the werker task object based off of the push head commit data, retrieve and generate changeset data from bitbucket to get the files changes / commit messages in the push, then it will add all of that to nsq so a werker node can swoop by and pick it up
type Signaler ¶
type Signaler struct { RC credentials.CVRemoteConfig *deserialize.Deserializer Producer nsqpb.Producer OcyValidator *build.OcelotValidator Store storage.OcelotStorage }
func NewSignaler ¶
func NewSignaler(RC credentials.CVRemoteConfig, dese *deserialize.Deserializer, producer nsqpb.Producer, ocyValidator *build.OcelotValidator, store storage.OcelotStorage) *Signaler
func (*Signaler) CheckViableThenQueueAndStore ¶
func (s *Signaler) CheckViableThenQueueAndStore(task *pb.WerkerTask, force bool, commits []*pb.Commit) error
CheckViableThenQueueAndStore is a dumb name, but i can't think of a better one. it will first - check if the build is "viable", ie if it is in the accepted branches list and none of the commits contain a skip Message. if it isn't, it won't queue and will return a NotViable error - will then run QueueAndStore, which will:
- check if build in consul, if it is it will not add to queue and return a NotViable error
- if the above doesn't return an error....
- store the initial summary in the database
- validate that the configuration is good
func (*Signaler) QueueAndStore ¶
func (s *Signaler) QueueAndStore(task *pb.WerkerTask) error
QueueAndStore is the muscle; it will:
- check if build in consul, if it is it will not add to queue and return a NotViable error
- if the above doesn't return an error....
- store the initial summary in the database
- validate that the configuration is good and add to the queue. If the build configuration (ocelot.yml) is not good, then it will store in the database that it failed validation along with the reason why
type TestConsul ¶
type TestConsul struct { consul.Consuletty // contains filtered or unexported fields }
func (*TestConsul) GetKeyValue ¶
func (tc *TestConsul) GetKeyValue(string) (*api.KVPair, error)
type TestSingleProducer ¶
func (*TestSingleProducer) WriteProto ¶
func (tp *TestSingleProducer) WriteProto(message proto.Message, topicName string) error
type TestStorage ¶
type TestStorage struct { storage.OcelotStorage // contains filtered or unexported fields }
can take one build
func (*TestStorage) AddStageDetail ¶
func (ts *TestStorage) AddStageDetail(result *models.StageResult) error
func (*TestStorage) AddSumStart ¶
func (ts *TestStorage) AddSumStart(hash, account, repo, branch string) (int64, error)
func (*TestStorage) SetQueueTime ¶
func (ts *TestStorage) SetQueueTime(id int64) error
func (*TestStorage) StoreFailedValidation ¶
func (ts *TestStorage) StoreFailedValidation(id int64) error