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)
authentication.go authenticator.go builds.go codeship.go doc.go options.go pagination.go projects.go
ErrRateLimitExceeded occurs when Codeship returns 403 Forbidden response
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
Authenticator is a strategy for authenticating with the API
BasicAuth is an Authenticator that implements basic auth
NewBasicAuth returns a new BasicAuth Authenticator
SetAuth implements Authenticator
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
BuildList holds a list of Build objects
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 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 struct { Pipelines []BuildPipeline `json:"pipelines"` // contains filtered or unexported fields }
BuildPipelines holds a list of BuildPipeline objects for a Basic Project
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 struct { Services []BuildService `json:"services"` // contains filtered or unexported fields }
BuildServices holds a list of BuildService objects for a Pro Project
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 struct { Steps []BuildStep `json:"steps"` // contains filtered or unexported fields }
BuildSteps holds a list of BuildStep objects for a Pro Project
type Client struct {
// contains filtered or unexported fields
}
Client holds information necessary to make a request to the Codeship API
func New(auth Authenticator, opts ...Option) (*Client, error)
New creates a new Codeship API client
Authenticate swaps username/password for an authentication token
Codeship API docs: https://apidocs.codeship.com/v2/authentication/authentication-endpoint
func (c *Client) Authentication() Authentication
Authentication returns the client's current Authentication object
AuthenticationRequired determines if a client must authenticate before making a request
Organization scopes a client to a single Organization, allowing the user to make calls to the API
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 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 struct { Name string `json:"name,omitempty"` Value string `json:"value,omitempty"` }
EnvironmentVariable structure for EnvironmentVariable object for a Basic Project
type ErrBadRequest struct {
// contains filtered or unexported fields
}
ErrBadRequest occurs when Codeship returns a 400 Bad Request response
type ErrNotFound struct {
// contains filtered or unexported fields
}
ErrNotFound occurs when Codeship returns a 404 Not Found response
ErrUnauthorized occurs when Codeship returns a 401 Unauthorized response
func (e ErrUnauthorized) Error() string
Links contain links for pagination purposes
Codeship API docs: https://apidocs.codeship.com/v2/introduction/pagination
CurrentPage returns the page number of the current page
IsLastPage returns true if the current page is the last
LastPage returns the page number of the last page
NextPage returns the page number of the next page
PreviousPage returns the page number of the previous page
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 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
Option is a functional option for configuring the API client
BaseURL allows overriding of API client baseURL for testing
HTTPClient accepts a custom *http.Client for making API calls
Headers allows you to set custom HTTP headers when making API calls (e.g. for satisfying HTTP proxies, or for debugging)
Logger allows overriding the default STDOUT logger
Verbose allows enabling/disabling internal logging
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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (o *Organization) ResetProjectAESKey(ctx context.Context, projectUUID string) (Project, Response, error)
ResetProjectAESKey resets the AES key for a project
Codeship API docs: https://apidocs.codeship.com/v2/projects/reset-aes-key
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 (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 (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 func(o *paginationOption)
PaginationOption is a functional option for providing pagination options
func Page(page int) PaginationOption
Page sets the page of results to be returned in the response
func PerPage(perPage int) PaginationOption
PerPage sets the number of results to be returned per page in the response
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 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 struct { Projects []Project `json:"projects"` // contains filtered or unexported fields }
ProjectList holds a list of Project objects
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 (t ProjectType) MarshalJSON() ([]byte, error)
MarshalJSON marshals a ProjectType to JSON
func (t ProjectType) String() string
func (t *ProjectType) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals JSON to a ProjectType
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 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 interface {
Println(...interface{})
}
StdLogger allows you to bring your own log implementation for logging
type TestPipeline struct { ID int `json:"id,omitempty"` Commands []string `json:"commands,omitempty"` Name string `json:"name,omitempty"` }
TestPipeline structure for Project object
Path | Synopsis |
---|---|
integration | Package integration contains integration tests. |
Package codeship imports 17 packages (graph) and is imported by 1 packages. Updated 2020-11-07. Refresh now. Tools for package owners.