codeship-go: github.com/codeship/codeship-go Index | Files | Directories

package codeship

import "github.com/codeship/codeship-go"

Package codeship provides a client for using the Codeship API v2.

The Codeship API v2 documentation exists at: https://apidocs.codeship.com/v2

Usage:

import codeship "github.com/codeship/codeship-go"

Create a new API Client:

auth := codeship.NewBasicAuth("username", "password")
client, err := codeship.New(auth)

You must then scope the client to a single Organization that you have access to:

org, err := client.Organization(ctx, "codeship")

You can then perform calls to the API on behalf of an Organization:

projects, err := org.ListProjects(ctx)

Index

Package Files

authentication.go authenticator.go builds.go codeship.go doc.go options.go pagination.go projects.go

Variables

var ErrRateLimitExceeded = errors.New("rate limit exceeded")

ErrRateLimitExceeded occurs when Codeship returns 403 Forbidden response

type Authentication Uses

type Authentication struct {
    AccessToken   string `json:"access_token,omitempty"`
    Organizations []struct {
        Name   string   `json:"name,omitempty"`
        UUID   string   `json:"uuid,omitempty"`
        Scopes []string `json:"scopes,omitempty"`
    }   `json:"organizations,omitempty"`
    ExpiresAt int64 `json:"expires_at,omitempty"`
}

Authentication object holds access token and scope information

type Authenticator Uses

type Authenticator interface {
    SetAuth(*http.Request)
}

Authenticator is a strategy for authenticating with the API

type BasicAuth Uses

type BasicAuth struct {
    Username, Password string
}

BasicAuth is an Authenticator that implements basic auth

func NewBasicAuth Uses

func NewBasicAuth(username, password string) *BasicAuth

NewBasicAuth returns a new BasicAuth Authenticator

func (*BasicAuth) SetAuth Uses

func (a *BasicAuth) SetAuth(r *http.Request)

SetAuth implements Authenticator

type Build Uses

type Build struct {
    AllocatedAt      time.Time  `json:"allocated_at,omitempty"`
    Branch           string     `json:"branch,omitempty"`
    CommitMessage    string     `json:"commit_message,omitempty"`
    CommitSha        string     `json:"commit_sha,omitempty"`
    FinishedAt       time.Time  `json:"finished_at,omitempty"`
    Links            BuildLinks `json:"links,omitempty"`
    OrganizationUUID string     `json:"organization_uuid,omitempty"`
    ProjectID        uint       `json:"project_id,omitempty"`
    ProjectUUID      string     `json:"project_uuid,omitempty"`
    QueuedAt         time.Time  `json:"queued_at,omitempty"`
    Ref              string     `json:"ref,omitempty"`
    Status           string     `json:"status,omitempty"`
    Username         string     `json:"username,omitempty"`
    UUID             string     `json:"uuid,omitempty"`
}

Build structure of Build object

type BuildLinks struct {
    Pipelines string `json:"pipelines,omitempty"`
    Services  string `json:"services,omitempty"`
    Steps     string `json:"steps,omitempty"`
}

BuildLinks structure of BuildLinks object for a Build

type BuildList Uses

type BuildList struct {
    Builds []Build `json:"builds"`
    // contains filtered or unexported fields
}

BuildList holds a list of Build objects

type BuildPipeline Uses

type BuildPipeline struct {
    UUID       string               `json:"uuid,omitempty"`
    BuildUUID  string               `json:"build_uuid,omitempty"`
    Type       string               `json:"type,omitempty"`
    Status     string               `json:"status,omitempty"`
    CreatedAt  time.Time            `json:"created_at,omitempty"`
    UpdatedAt  time.Time            `json:"updated_at,omitempty"`
    FinishedAt time.Time            `json:"finished_at,omitempty"`
    Metrics    BuildPipelineMetrics `json:"metrics,omitempty"`
}

BuildPipeline structure of BuildPipeline object for a Basic Project

type BuildPipelineMetrics Uses

type BuildPipelineMetrics struct {
    AmiID                 string `json:"ami_id,omitempty"`
    Queries               string `json:"queries,omitempty"`
    CPUUser               string `json:"cpu_user,omitempty"`
    Duration              string `json:"duration,omitempty"`
    CPUSystem             string `json:"cpu_system,omitempty"`
    InstanceID            string `json:"instance_id,omitempty"`
    Architecture          string `json:"architecture,omitempty"`
    InstanceType          string `json:"instance_type,omitempty"`
    CPUPerSecond          string `json:"cpu_per_second,omitempty"`
    DiskFreeBytes         string `json:"disk_free_bytes,omitempty"`
    DiskUsedBytes         string `json:"disk_used_bytes,omitempty"`
    NetworkRxBytes        string `json:"network_rx_bytes,omitempty"`
    NetworkTxBytes        string `json:"network_tx_bytes,omitempty"`
    MaxUsedConnections    string `json:"max_used_connections,omitempty"`
    MemoryMaxUsageInBytes string `json:"memory_max_usage_in_bytes,omitempty"`
}

BuildPipelineMetrics structure of BuildPipelineMetrics object for a BuildPipeline

type BuildPipelines Uses

type BuildPipelines struct {
    Pipelines []BuildPipeline `json:"pipelines"`
    // contains filtered or unexported fields
}

BuildPipelines holds a list of BuildPipeline objects for a Basic Project

type BuildService Uses

type BuildService struct {
    BuildUUID  string    `json:"build_uuid,omitempty"`
    BuildingAt time.Time `json:"building_at,omitempty"`
    CreatedAt  time.Time `json:"created_at,omitempty"`
    FinishedAt time.Time `json:"finished_at,omitempty"`
    Name       string    `json:"name,omitempty"`
    PullingAt  time.Time `json:"pulling_at,omitempty"`
    UpdatedAt  time.Time `json:"updated_at,omitempty"`
    UUID       string    `json:"uuid,omitempty"`
    Status     string    `json:"status,omitempty"`
}

BuildService structure of BuildService object for a Pro Project

type BuildServices Uses

type BuildServices struct {
    Services []BuildService `json:"services"`
    // contains filtered or unexported fields
}

BuildServices holds a list of BuildService objects for a Pro Project

type BuildStep Uses

type BuildStep struct {
    BuildUUID   string      `json:"build_uuid,omitempty"`
    BuildingAt  time.Time   `json:"building_at,omitempty"`
    Command     string      `json:"command,omitempty"`
    FinishedAt  time.Time   `json:"finished_at,omitempty"`
    ImageName   string      `json:"image_name,omitempty"`
    Name        string      `json:"name,omitempty"`
    Registry    string      `json:"registry,omitempty"`
    ServiceUUID string      `json:"service_uuid,omitempty"`
    StartedAt   time.Time   `json:"started_at,omitempty"`
    Status      string      `json:"status,omitempty"`
    Steps       []BuildStep `json:"steps,omitempty"`
    Tag         string      `json:"tag,omitempty"`
    Type        string      `json:"type,omitempty"`
    UpdatedAt   time.Time   `json:"updated_at,omitempty"`
    UUID        string      `json:"uuid,omitempty"`
}

BuildStep structure of BuildStep object for a Pro Project

type BuildSteps Uses

type BuildSteps struct {
    Steps []BuildStep `json:"steps"`
    // contains filtered or unexported fields
}

BuildSteps holds a list of BuildStep objects for a Pro Project

type Client Uses

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

Client holds information necessary to make a request to the Codeship API

func New Uses

func New(auth Authenticator, opts ...Option) (*Client, error)

New creates a new Codeship API client

func (*Client) Authenticate Uses

func (c *Client) Authenticate(ctx context.Context) (Response, error)

Authenticate swaps username/password for an authentication token

Codeship API docs: https://apidocs.codeship.com/v2/authentication/authentication-endpoint

func (*Client) Authentication Uses

func (c *Client) Authentication() Authentication

Authentication returns the client's current Authentication object

func (*Client) AuthenticationRequired Uses

func (c *Client) AuthenticationRequired() bool

AuthenticationRequired determines if a client must authenticate before making a request

func (*Client) Organization Uses

func (c *Client) Organization(ctx context.Context, name string) (*Organization, error)

Organization scopes a client to a single Organization, allowing the user to make calls to the API

type DeploymentBranch Uses

type DeploymentBranch struct {
    BranchName string `json:"branch_name,omitempty"`
    MatchMode  string `json:"match_mode,omitempty"`
}

DeploymentBranch structure for DeploymentBranch object for a Basic Project

type DeploymentPipeline Uses

type DeploymentPipeline struct {
    ID       int                    `json:"id,omitempty"`
    Branch   DeploymentBranch       `json:"branch,omitempty"`
    Config   map[string]interface{} `json:"config,omitempty"`
    Position int                    `json:"position,omitempty"`
}

DeploymentPipeline structure for DeploymentPipeline object for a Basic Project

type EnvironmentVariable Uses

type EnvironmentVariable struct {
    Name  string `json:"name,omitempty"`
    Value string `json:"value,omitempty"`
}

EnvironmentVariable structure for EnvironmentVariable object for a Basic Project

type ErrBadRequest Uses

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

ErrBadRequest occurs when Codeship returns a 400 Bad Request response

func (ErrBadRequest) Error Uses

func (e ErrBadRequest) Error() string

type ErrNotFound Uses

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

ErrNotFound occurs when Codeship returns a 404 Not Found response

func (ErrNotFound) Error Uses

func (e ErrNotFound) Error() string

type ErrUnauthorized Uses

type ErrUnauthorized string

ErrUnauthorized occurs when Codeship returns a 401 Unauthorized response

func (ErrUnauthorized) Error Uses

func (e ErrUnauthorized) Error() string
type Links struct {
    Next     string
    Previous string
    Last     string
    First    string
}

Links contain links for pagination purposes

Codeship API docs: https://apidocs.codeship.com/v2/introduction/pagination

func (Links) CurrentPage Uses

func (l Links) CurrentPage() (int, error)

CurrentPage returns the page number of the current page

func (Links) IsLastPage Uses

func (l Links) IsLastPage() bool

IsLastPage returns true if the current page is the last

func (Links) LastPage Uses

func (l Links) LastPage() (int, error)

LastPage returns the page number of the last page

func (Links) NextPage Uses

func (l Links) NextPage() (int, error)

NextPage returns the page number of the next page

func (Links) PreviousPage Uses

func (l Links) PreviousPage() (int, error)

PreviousPage returns the page number of the previous page

type NotificationOptions Uses

type NotificationOptions struct {
    Key  string `json:"key,omitempty"`
    URL  string `json:"url,omitempty"`
    Room string `json:"room,omitempty"`
}

NotificationOptions structure for NotificationOptions object for a Project

type NotificationRule Uses

type NotificationRule struct {
    Branch        string              `json:"branch,omitempty"`
    BranchMatch   string              `json:"branch_match,omitempty"`
    Notifier      string              `json:"notifier,omitempty"`
    Options       NotificationOptions `json:"options,omitempty"`
    BuildStatuses []string            `json:"build_statuses,omitempty"`
    Target        string              `json:"target,omitempty"`
}

NotificationRule structure for NotificationRule object for a Project

type Option Uses

type Option func(*Client) error

Option is a functional option for configuring the API client

func BaseURL Uses

func BaseURL(baseURL string) Option

BaseURL allows overriding of API client baseURL for testing

func HTTPClient Uses

func HTTPClient(client *http.Client) Option

HTTPClient accepts a custom *http.Client for making API calls

func Headers Uses

func Headers(headers http.Header) Option

Headers allows you to set custom HTTP headers when making API calls (e.g. for satisfying HTTP proxies, or for debugging)

func Logger Uses

func Logger(logger StdLogger) Option

Logger allows overriding the default STDOUT logger

func Verbose Uses

func Verbose(verbose bool) Option

Verbose allows enabling/disabling internal logging

type Organization Uses

type Organization struct {
    UUID   string
    Name   string
    Scopes []string
    // contains filtered or unexported fields
}

Organization holds the configuration for the current API client scoped to the Organization. Should not be modified concurrently

func (*Organization) CreateBuild Uses

func (o *Organization) CreateBuild(ctx context.Context, projectUUID, ref, commitSha string) (bool, Response, error)

CreateBuild creates a new build

Codeship API docs: https://apidocs.codeship.com/v2/builds/create-build

func (*Organization) CreateProject Uses

func (o *Organization) CreateProject(ctx context.Context, p ProjectCreateRequest) (Project, Response, error)

CreateProject creates a new project

Codeship API docs: https://apidocs.codeship.com/v2/projects/create-project

func (*Organization) GetBuild Uses

func (o *Organization) GetBuild(ctx context.Context, projectUUID, buildUUID string) (Build, Response, error)

GetBuild fetches a build by UUID

Codeship API docs: https://apidocs.codeship.com/v2/builds/get-build

func (*Organization) GetProject Uses

func (o *Organization) GetProject(ctx context.Context, projectUUID string) (Project, Response, error)

GetProject fetches a project by UUID

Codeship API docs: https://apidocs.codeship.com/v2/projects/get-project

func (*Organization) ListBuildPipelines Uses

func (o *Organization) ListBuildPipelines(ctx context.Context, projectUUID, buildUUID string, opts ...PaginationOption) (BuildPipelines, Response, error)

ListBuildPipelines lists Basic build pipelines

Codeship API docs: https://apidocs.codeship.com/v2/builds/get-build-pipelines

func (*Organization) ListBuildServices Uses

func (o *Organization) ListBuildServices(ctx context.Context, projectUUID, buildUUID string, opts ...PaginationOption) (BuildServices, Response, error)

ListBuildServices lists Pro build services

Codeship API docs: https://apidocs.codeship.com/v2/builds/get-build-services

func (*Organization) ListBuildSteps Uses

func (o *Organization) ListBuildSteps(ctx context.Context, projectUUID, buildUUID string, opts ...PaginationOption) (BuildSteps, Response, error)

ListBuildSteps lists Pro build steps

Codeship API docs: https://apidocs.codeship.com/v2/builds/get-build-steps

func (*Organization) ListBuilds Uses

func (o *Organization) ListBuilds(ctx context.Context, projectUUID string, opts ...PaginationOption) (BuildList, Response, error)

ListBuilds fetches a list of builds

Codeship API docs: https://apidocs.codeship.com/v2/builds/list-builds

func (*Organization) ListProjects Uses

func (o *Organization) ListProjects(ctx context.Context, opts ...PaginationOption) (ProjectList, Response, error)

ListProjects fetches a list of projects

Codeship API docs: https://apidocs.codeship.com/v2/projects/list-projects

func (*Organization) RestartBuild Uses

func (o *Organization) RestartBuild(ctx context.Context, projectUUID, buildUUID string) (bool, Response, error)

RestartBuild restarts a previous build

Codeship API docs: https://apidocs.codeship.com/v2/builds/restart-build

func (*Organization) StopBuild Uses

func (o *Organization) StopBuild(ctx context.Context, projectUUID, buildUUID string) (bool, Response, error)

StopBuild stops a running build

Codeship API docs: https://apidocs.codeship.com/v2/builds/stop-build

func (*Organization) UpdateProject Uses

func (o *Organization) UpdateProject(ctx context.Context, projectUUID string, p ProjectUpdateRequest) (Project, Response, error)

UpdateProject updates an existing project

Codeship API docs: https://apidocs.codeship.com/v2/projects/update-project

type PaginationOption Uses

type PaginationOption func(o *paginationOption)

PaginationOption is a functional option for providing pagination options

func Page Uses

func Page(page int) PaginationOption

Page sets the page of results to be returned in the response

func PerPage Uses

func PerPage(perPage int) PaginationOption

PerPage sets the number of results to be returned per page in the response

type Project Uses

type Project struct {
    AesKey               string                `json:"aes_key,omitempty"`
    AuthenticationUser   string                `json:"authentication_user,omitempty"`
    CreatedAt            time.Time             `json:"created_at,omitempty"`
    DeploymentPipelines  []DeploymentPipeline  `json:"deployment_pipelines,omitempty"`
    EnvironmentVariables []EnvironmentVariable `json:"environment_variables,omitempty"`
    ID                   uint                  `json:"id,omitempty"`
    Name                 string                `json:"name,omitempty"`
    NotificationRules    []NotificationRule    `json:"notification_rules,omitempty"`
    OrganizationUUID     string                `json:"organization_uuid,omitempty"`
    RepositoryProvider   string                `json:"repository_provider,omitempty"`
    RepositoryURL        string                `json:"repository_url,omitempty"`
    SetupCommands        []string              `json:"setup_commands,omitempty"`
    SSHKey               string                `json:"ssh_key,omitempty"`
    TeamIDs              []int                 `json:"team_ids,omitempty"`
    TestPipelines        []TestPipeline        `json:"test_pipelines,omitempty"`
    Type                 ProjectType           `json:"type"`
    UpdatedAt            time.Time             `json:"updated_at,omitempty"`
    UUID                 string                `json:"uuid,omitempty"`
}

Project structure for Project object

type ProjectCreateRequest Uses

type ProjectCreateRequest struct {
    DeploymentPipelines  []DeploymentPipeline  `json:"deployment_pipelines,omitempty"`
    EnvironmentVariables []EnvironmentVariable `json:"environment_variables,omitempty"`
    NotificationRules    []NotificationRule    `json:"notification_rules,omitempty"`
    RepositoryURL        string                `json:"repository_url,omitempty"`
    SetupCommands        []string              `json:"setup_commands,omitempty"`
    TeamIDs              []int                 `json:"team_ids,omitempty"`
    TestPipelines        []TestPipeline        `json:"test_pipelines,omitempty"`
    Type                 ProjectType           `json:"type"`
}

ProjectCreateRequest structure for creating a Project

type ProjectList Uses

type ProjectList struct {
    Projects []Project `json:"projects"`
    // contains filtered or unexported fields
}

ProjectList holds a list of Project objects

type ProjectType Uses

type ProjectType int

ProjectType represents Codeship project types (Basic and Pro)

const (
    // ProjectTypeBasic represents a Codeship Basic project type
    ProjectTypeBasic ProjectType = iota
    // ProjectTypePro represents a Codeship Pro project type
    ProjectTypePro
)

func (ProjectType) MarshalJSON Uses

func (t ProjectType) MarshalJSON() ([]byte, error)

MarshalJSON marshals a ProjectType to JSON

func (ProjectType) String Uses

func (t ProjectType) String() string

func (*ProjectType) UnmarshalJSON Uses

func (t *ProjectType) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON to a ProjectType

type ProjectUpdateRequest Uses

type ProjectUpdateRequest struct {
    EnvironmentVariables []EnvironmentVariable `json:"environment_variables,omitempty"`
    NotificationRules    []NotificationRule    `json:"notification_rules,omitempty"`
    SetupCommands        []string              `json:"setup_commands,omitempty"`
    TeamIDs              []int                 `json:"team_ids,omitempty"`
    Type                 ProjectType           `json:"type"`
}

ProjectUpdateRequest structure for updating a Project

type Response Uses

type Response struct {
    *http.Response
    // Links that were returned with the response. These are parsed from the Link header.
    Links
}

Response is a Codeship response. This wraps the standard http.Response returned from Codeship.

type StdLogger Uses

type StdLogger interface {
    Println(...interface{})
}

StdLogger allows you to bring your own log implementation for logging

type TestPipeline Uses

type TestPipeline struct {
    ID       int      `json:"id,omitempty"`
    Commands []string `json:"commands,omitempty"`
    Name     string   `json:"name,omitempty"`
}

TestPipeline structure for Project object

Directories

PathSynopsis
integrationPackage integration contains integration tests.

Package codeship imports 17 packages (graph) and is imported by 1 packages. Updated 2020-05-31. Refresh now. Tools for package owners.