taskcluster-worker: github.com/taskcluster/taskcluster-worker/runtime/client Index | Files

package client

import "github.com/taskcluster/taskcluster-worker/runtime/client"


Package Files

auth.go authorizer.go queue.go


var PostAnyArtifactRequest = mock.MatchedBy(func(i interface{}) bool {
    _, ok := i.(*tcqueue.PostArtifactRequest)
    return ok

PostAnyArtifactRequest matches if tcqueue.PostArtifactRequest is called

var PostS3ArtifactRequest = mock.MatchedBy(func(i interface{}) bool {
    r, ok := i.(*tcqueue.PostArtifactRequest)
    if !ok {
        return false
    var s3req tcqueue.S3ArtifactRequest
    if json.Unmarshal(*r, &s3req) != nil {
        return false
    return s3req.StorageType == "s3"

PostS3ArtifactRequest matches if tcqueue.PostS3ArtifactRequest is called with an s3 artifact

type Auth Uses

type Auth interface {
    SentryDSN(project string) (*tcauth.SentryDSNResponse, error)
    StatsumToken(project string) (*tcauth.StatsumTokenResponse, error)

Auth interface covers parts of the tcauth.Auth client that we use. This allows us to mock the implementation during tests.

type Authorizer Uses

type Authorizer interface {
    SignHeader(method string, URL *url.URL, payload json.RawMessage) (string, error)
    SignURL(URL *url.URL, expiration time.Duration) (*url.URL, error)
    WithAuthorizedScopes(scopes ...string) Authorizer

An Authorizer is an interface for an object that can sign a request with taskcluster credentials.

func NewAuthorizer Uses

func NewAuthorizer(getCredentials func() (clientID string, accessToken string, certificate string, err error)) Authorizer

NewAuthorizer returns an authorizer that signs with credntials from getCredentials

type MockAuth Uses

type MockAuth struct {

MockAuth is a mock implementation of Auth for testing.

func (*MockAuth) SentryDSN Uses

func (m *MockAuth) SentryDSN(project string) (*tcauth.SentryDSNResponse, error)

SentryDSN is a mock implementation of SentryDSN that calls into m.Mock

func (*MockAuth) StatsumToken Uses

func (m *MockAuth) StatsumToken(project string) (*tcauth.StatsumTokenResponse, error)

StatsumToken is a mock implementation of StatsumToken that calls into Mock

type MockQueue Uses

type MockQueue struct {

MockQueue is a mocked TaskCluster queue client. Calls to methods exposed by the queue client will be recorded for assertion later and will respond with the data that was specified during creation of the mocked object.

For more information about each of these client methods, consult the taskcluster-clieng-go/queue package

func (*MockQueue) CancelTask Uses

func (m *MockQueue) CancelTask(taskID string) (*tcqueue.TaskStatusResponse, error)

CancelTask is a mock implementation of github.com/taskcluster/taskcluster-client-go/tcqueue.CancelTask

func (*MockQueue) ClaimTask Uses

func (m *MockQueue) ClaimTask(taskID, runID string, payload *tcqueue.TaskClaimRequest) (*tcqueue.TaskClaimResponse, error)

ClaimTask is a mock implementation of github.com/taskcluster/taskcluster-client-go/tcqueue.ClaimTask

func (*MockQueue) ClaimWork Uses

func (m *MockQueue) ClaimWork(provisionerID, workerType string, payload *tcqueue.ClaimWorkRequest) (*tcqueue.ClaimWorkResponse, error)

ClaimWork is a mock implementation of github.com/taskcluster/taskcluster-client-go/queue#Queue.ClaimWork

func (*MockQueue) CreateArtifact Uses

func (m *MockQueue) CreateArtifact(taskID, runID, name string, payload *tcqueue.PostArtifactRequest) (*tcqueue.PostArtifactResponse, error)

CreateArtifact is a mock implementation of github.com/taskcluster/taskcluster-client-go/tcqueue.CreateArtifact

func (*MockQueue) ExpectRedirectArtifact Uses

func (m *MockQueue) ExpectRedirectArtifact(taskID string, runID int, name string) <-chan string

ExpectRedirectArtifact will setup m to expect a redirect artifact with given name for taskID and runID to be created. This function returns a channel for the url of the redirect artifact.

func (*MockQueue) ExpectS3Artifact Uses

func (m *MockQueue) ExpectS3Artifact(taskID string, runID int, name string) <-chan []byte

ExpectS3Artifact will setup queue to expect an S3 artifact with given name to be created for taskID and runID using m and returns a channel which will receive the artifact.

func (*MockQueue) GetArtifact_SignedURL Uses

func (m *MockQueue) GetArtifact_SignedURL(taskID, runID, name string, duration time.Duration) (*url.URL, error)

GetArtifact_SignedURL is a mock implementation of github.com/taskcluster/taskcluster-client-go/tcqueue.GetArtifact_SignedURL

func (*MockQueue) PollTaskUrls Uses

func (m *MockQueue) PollTaskUrls(provisionerID, workerType string) (*tcqueue.PollTaskUrlsResponse, error)

PollTaskUrls is a mock implementation of github.com/taskcluster/taskcluster-client-go/tcqueue.PollTaskUrls

func (*MockQueue) ReclaimTask Uses

func (m *MockQueue) ReclaimTask(taskID, runID string) (*tcqueue.TaskReclaimResponse, error)

ReclaimTask is a mock implementation of github.com/taskcluster/taskcluster-client-go/tcqueue.ReclaimTask

func (*MockQueue) ReportCompleted Uses

func (m *MockQueue) ReportCompleted(taskID, runID string) (*tcqueue.TaskStatusResponse, error)

ReportCompleted is a mock implementation of github.com/taskcluster/taskcluster-client-go/tcqueue.ReportCompleted

func (*MockQueue) ReportException Uses

func (m *MockQueue) ReportException(taskID, runID string, payload *tcqueue.TaskExceptionRequest) (*tcqueue.TaskStatusResponse, error)

ReportException is a mock implementation of github.com/taskcluster/taskcluster-client-go/tcqueue.ReportException

func (*MockQueue) ReportFailed Uses

func (m *MockQueue) ReportFailed(taskID, runID string) (*tcqueue.TaskStatusResponse, error)

ReportFailed is a mock implementation of github.com/taskcluster/taskcluster-client-go/tcqueue.ReportFailed

func (*MockQueue) ServeHTTP Uses

func (m *MockQueue) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles a queue request by calling the mock implemetation

func (*MockQueue) Status Uses

func (m *MockQueue) Status(taskID string) (*tcqueue.TaskStatusResponse, error)

Status is a mock implementation of github.com/taskcluster/taskcluster-client-go/tcqueue.Status

type Queue Uses

type Queue interface {
    Status(string) (*tcqueue.TaskStatusResponse, error)
    ReportCompleted(string, string) (*tcqueue.TaskStatusResponse, error)
    ReportException(string, string, *tcqueue.TaskExceptionRequest) (*tcqueue.TaskStatusResponse, error)
    ReportFailed(string, string) (*tcqueue.TaskStatusResponse, error)
    ClaimTask(string, string, *tcqueue.TaskClaimRequest) (*tcqueue.TaskClaimResponse, error)
    ClaimWork(provisionerID, workerType string, payload *tcqueue.ClaimWorkRequest) (*tcqueue.ClaimWorkResponse, error)
    ReclaimTask(string, string) (*tcqueue.TaskReclaimResponse, error)
    PollTaskUrls(string, string) (*tcqueue.PollTaskUrlsResponse, error)
    CancelTask(string) (*tcqueue.TaskStatusResponse, error)
    CreateArtifact(string, string, string, *tcqueue.PostArtifactRequest) (*tcqueue.PostArtifactResponse, error)
    GetArtifact_SignedURL(string, string, string, time.Duration) (*url.URL, error) // nolint

Queue is an interface to the Queue client provided by the taskcluster-client-go package. Passing around an interface allows the queue client to be mocked

Package client imports 20 packages (graph) and is imported by 8 packages. Updated 2018-04-11. Refresh now. Tools for package owners.