Documentation ¶
Overview ¶
Package gocd provides a client for using the GoCD Server API.
Usage:
import "github.com/beamly/go-gocd/gocd"
Construct a new GoCD client and supply the URL to your GoCD server and if required, username and password. Then use the various services on the client to access different parts of the GoCD API. For example:
package main import ( "github.com/beamly/go-gocd/gocd" "context" "fmt" ) func main() { cfg := gocd.Configuration{ Server: "https://my_gocd/go/", Username: "ApiUser", Password: "MySecretPassword", } c := cfg.Client() // list all agents in use by the GoCD Server var a []*gocd.Agent var err error var r *gocd.APIResponse if a, r, err = c.Agents.List(context.Background()); err != nil { if r.HTTP.StatusCode == 404 { fmt.Println("Couldn't find agent") } else { panic(err) } } fmt.Println(a) }
If you wish to use your own http client, you can use the following idiom
package main import ( "github.com/beamly/go-gocd/gocd" "net/http" "context" ) func main() { client := gocd.NewClient( &gocd.Configuration{}, &http.Client{}, ) client.Login(context.Background()) }
The services of a client divide the API into logical chunks and correspond to the structure of the GoCD API documentation at https://api.gocd.org/current/.
Index ¶
- Constants
- func CheckResponse(response *APIResponse) (err error)
- func ConfigFilePath() (configPath string, err error)
- func Int(v int) *int
- func LoadConfigByName(name string, cfg *Configuration) (err error)
- func LoadConfigFromFile() (cfgs map[string]*Configuration, err error)
- func SetupLogging(log *logrus.Logger)
- func String(v string) *string
- type APIClientRequest
- type APIRequest
- type APIResponse
- type Agent
- type AgentBulkOperationUpdate
- type AgentBulkOperationsUpdate
- type AgentBulkUpdate
- type AgentsResponse
- type AgentsService
- func (s *AgentsService) BulkUpdate(ctx context.Context, agents AgentBulkUpdate) (message string, resp *APIResponse, err error)
- func (s *AgentsService) Delete(ctx context.Context, uuid string) (string, *APIResponse, error)
- func (s *AgentsService) Get(ctx context.Context, uuid string) (*Agent, *APIResponse, error)
- func (s *AgentsService) JobRunHistory(ctx context.Context, uuid string) (jobs []*Job, resp *APIResponse, err error)
- func (s *AgentsService) List(ctx context.Context) (agents []*Agent, resp *APIResponse, err error)
- func (s *AgentsService) Update(ctx context.Context, uuid string, agent *Agent) (*Agent, *APIResponse, error)
- type Approval
- type Artifact
- type Auth
- type Authorization
- type BuildCause
- type BuildDetails
- type CipherText
- type Client
- func (c *Client) BaseURL() *url.URL
- func (c *Client) Do(ctx context.Context, req *APIRequest, v interface{}, responseType string) (*APIResponse, error)
- func (c *Client) Lock()
- func (c *Client) Login(ctx context.Context) (err error)
- func (c *Client) NewRequest(method, urlStr string, body interface{}, apiVersion string) (req *APIRequest, err error)
- func (c *Client) Unlock()
- type ClientParameters
- type ConfigApproval
- type ConfigArtifact
- type ConfigAuthConfig
- type ConfigElastic
- type ConfigElasticProfile
- type ConfigEnvironmentVariable
- type ConfigFilter
- type ConfigJob
- type ConfigMaterialRepository
- type ConfigPackage
- type ConfigParam
- type ConfigPipeline
- type ConfigPipelineGroup
- type ConfigPluginConfiguration
- type ConfigProperty
- type ConfigRepo
- type ConfigRepoProperty
- type ConfigRepoService
- func (crs *ConfigRepoService) Create(ctx context.Context, cr *ConfigRepo) (out *ConfigRepo, resp *APIResponse, err error)
- func (crs *ConfigRepoService) Delete(ctx context.Context, id string) (string, *APIResponse, error)
- func (crs *ConfigRepoService) Get(ctx context.Context, id string) (out *ConfigRepo, resp *APIResponse, err error)
- func (crs *ConfigRepoService) List(ctx context.Context) (repos []*ConfigRepo, resp *APIResponse, err error)
- func (crs *ConfigRepoService) Update(ctx context.Context, id string, cr *ConfigRepo) (out *ConfigRepo, resp *APIResponse, err error)
- type ConfigReposListResponse
- type ConfigRepository
- type ConfigRepositoryGit
- type ConfigRole
- type ConfigSCM
- type ConfigSecurity
- type ConfigServer
- type ConfigStage
- type ConfigTask
- type ConfigTaskRunIf
- type ConfigTasks
- type ConfigXML
- type Configuration
- type ConfigurationService
- type EmbeddedEnvironments
- type EncryptionService
- type Environment
- type EnvironmentPatchRequest
- type EnvironmentVariable
- type EnvironmentVariablesAction
- type EnvironmentsResponse
- type EnvironmentsService
- func (es *EnvironmentsService) Create(ctx context.Context, name string) (e *Environment, resp *APIResponse, err error)
- func (es *EnvironmentsService) Delete(ctx context.Context, name string) (string, *APIResponse, error)
- func (es *EnvironmentsService) Get(ctx context.Context, name string) (e *Environment, resp *APIResponse, err error)
- func (es *EnvironmentsService) List(ctx context.Context) (e *EnvironmentsResponse, resp *APIResponse, err error)
- func (es *EnvironmentsService) Patch(ctx context.Context, name string, patch *EnvironmentPatchRequest) (e *Environment, resp *APIResponse, err error)
- type ExtensionCapabilities
- type ExtensionSettings
- type GitRepositoryMaterial
- type HALContainer
- type HALLink
- type HALLinks
- func (al *HALLinks) Add(link *HALLink)
- func (al HALLinks) Get(name string) (link *HALLink)
- func (al HALLinks) GetOk(name string) (link *HALLink, ok bool)
- func (al HALLinks) Keys() (keys []string)
- func (al HALLinks) MarshallJSON() ([]byte, error)
- func (al *HALLinks) UnmarshalJSON(j []byte) (err error)
- type Job
- type JobProperty
- type JobRunHistoryResponse
- type JobSchedule
- type JobScheduleEnvVar
- type JobScheduleLink
- type JobScheduleResponse
- type JobStateTransition
- type JobsService
- type MailHost
- type Material
- func (m Material) Equal(a *Material) (isEqual bool, err error)
- func (m *Material) Ingest(payload map[string]interface{}) (err error)
- func (m *Material) IngestAttributeGenerics(i interface{}) (err error)
- func (m *Material) IngestAttributes(rawAttributes map[string]interface{}) (err error)
- func (m *Material) IngestType(payload map[string]interface{})
- func (m *Material) UnmarshalJSON(b []byte) (err error)
- type MaterialAttribute
- type MaterialAttributesDependency
- type MaterialAttributesGit
- type MaterialAttributesHg
- type MaterialAttributesP4
- type MaterialAttributesPackage
- type MaterialAttributesPlugin
- type MaterialAttributesSvn
- type MaterialAttributesTfs
- type MaterialFilter
- type MaterialRevision
- type Modification
- type PaginationResponse
- type Parameter
- type PasswordFilePath
- type PatchStringAction
- type Pipeline
- func (p *Pipeline) AddStage(stage *Stage)
- func (p *Pipeline) GetLinks() *HALLinks
- func (p *Pipeline) GetName() string
- func (p *Pipeline) GetStage(stageName string) (stage *Stage)
- func (p *Pipeline) GetStages() []*Stage
- func (p *Pipeline) GetVersion() (version string)
- func (p *Pipeline) RemoveLinks()
- func (p *Pipeline) SetStage(newStage *Stage)
- func (p *Pipeline) SetStages(stages []*Stage)
- func (p *Pipeline) SetVersion(version string)
- type PipelineConfigOrigin
- type PipelineConfigRequest
- type PipelineConfigsService
- func (pcs *PipelineConfigsService) Create(ctx context.Context, group string, p *Pipeline) (pr *Pipeline, resp *APIResponse, err error)
- func (pcs *PipelineConfigsService) Delete(ctx context.Context, name string) (string, *APIResponse, error)
- func (pcs *PipelineConfigsService) Get(ctx context.Context, name string) (p *Pipeline, resp *APIResponse, err error)
- func (pcs *PipelineConfigsService) Update(ctx context.Context, name string, p *Pipeline) (pr *Pipeline, resp *APIResponse, err error)
- type PipelineGroup
- type PipelineGroups
- type PipelineGroupsService
- type PipelineHistory
- type PipelineInstance
- type PipelineMaterial
- type PipelineRequest
- type PipelineStatus
- type PipelineTemplate
- func (pt *PipelineTemplate) AddStage(stage *Stage)
- func (pt PipelineTemplate) GetName() string
- func (pt PipelineTemplate) GetStage(stageName string) *Stage
- func (pt PipelineTemplate) GetStages() []*Stage
- func (pt PipelineTemplate) GetVersion() (version string)
- func (pt PipelineTemplate) Pipelines() []*Pipeline
- func (pt *PipelineTemplate) RemoveLinks()
- func (pt *PipelineTemplate) SetStage(newStage *Stage)
- func (pt *PipelineTemplate) SetStages(stages []*Stage)
- func (pt *PipelineTemplate) SetVersion(version string)
- type PipelineTemplateRequest
- type PipelineTemplateResponse
- type PipelineTemplatesResponse
- type PipelineTemplatesService
- func (pts *PipelineTemplatesService) Create(ctx context.Context, name string, st []*Stage) (ptr *PipelineTemplate, resp *APIResponse, err error)
- func (pts *PipelineTemplatesService) Delete(ctx context.Context, name string) (string, *APIResponse, error)
- func (pts *PipelineTemplatesService) Get(ctx context.Context, name string) (pt *PipelineTemplate, resp *APIResponse, err error)
- func (pts *PipelineTemplatesService) List(ctx context.Context) (pt []*PipelineTemplate, resp *APIResponse, err error)
- func (pts *PipelineTemplatesService) Update(ctx context.Context, name string, template *PipelineTemplate) (ptr *PipelineTemplate, resp *APIResponse, err error)
- type PipelinesService
- func (pgs *PipelinesService) GetHistory(ctx context.Context, name string, offset int) (pt *PipelineHistory, resp *APIResponse, err error)
- func (pgs *PipelinesService) GetInstance(ctx context.Context, name string, counter int) (pt *PipelineInstance, resp *APIResponse, err error)
- func (pgs *PipelinesService) GetStatus(ctx context.Context, name string, offset int) (ps *PipelineStatus, resp *APIResponse, err error)
- func (pgs *PipelinesService) Pause(ctx context.Context, name string) (bool, *APIResponse, error)
- func (pgs *PipelinesService) ReleaseLock(ctx context.Context, name string) (bool, *APIResponse, error)
- func (pgs *PipelinesService) Schedule(ctx context.Context, name string, body *ScheduleRequestBody) (bool, *APIResponse, error)
- func (pgs *PipelinesService) Unpause(ctx context.Context, name string) (bool, *APIResponse, error)
- type PluggableInstanceSettings
- type Plugin
- type PluginAbout
- type PluginConfiguration
- type PluginConfigurationKVPair
- type PluginConfigurationMetadata
- type PluginExtension
- type PluginExtensionInfo
- type PluginIcon
- type PluginStatus
- type PluginVendor
- type PluginView
- type PluginsResponse
- type PluginsService
- type Properties
- func (pr *Properties) AddRow(r []string)
- func (pr Properties) Get(row int, column string) string
- func (pr *Properties) MarshalJSON() ([]byte, error)
- func (pr Properties) MarshallCSV() (string, error)
- func (pr *Properties) SetRow(row int, r []string)
- func (pr *Properties) UnmarshallCSV(raw string) error
- func (pr *Properties) Write(p []byte) (n int, err error)
- type PropertiesService
- func (ps *PropertiesService) Create(ctx context.Context, name string, value string, pr *PropertyRequest) (responseIsValid bool, resp *APIResponse, err error)
- func (ps *PropertiesService) Get(ctx context.Context, name string, pr *PropertyRequest) (*Properties, *APIResponse, error)
- func (ps *PropertiesService) List(ctx context.Context, pr *PropertyRequest) (*Properties, *APIResponse, error)
- func (ps *PropertiesService) ListHistorical(ctx context.Context, pr *PropertyRequest) (*Properties, *APIResponse, error)
- type PropertyCreateResponse
- type PropertyRequest
- type Role
- type RoleAttributeProperties
- type RoleAttributesGoCD
- type RoleListWrapper
- type RoleService
- func (rs *RoleService) Create(ctx context.Context, role *Role) (r *Role, resp *APIResponse, err error)
- func (rs *RoleService) Delete(ctx context.Context, roleName string) (result string, resp *APIResponse, err error)
- func (rs *RoleService) Get(ctx context.Context, roleName string) (r *Role, resp *APIResponse, err error)
- func (rs *RoleService) List(ctx context.Context) (r []*Role, resp *APIResponse, err error)
- func (rs *RoleService) Update(ctx context.Context, roleName string, role *Role) (r *Role, resp *APIResponse, err error)
- type ScheduleMaterial
- type ScheduleRequestBody
- type ServerVersion
- type ServerVersionService
- type Stage
- type StageContainer
- type StageInstance
- type StagesService
- type StringResponse
- type Tab
- type Task
- type TaskAttributes
- type TaskPluginConfiguration
- type TimeoutField
- type Timer
- type TrackingTool
- type TrackingToolAttributes
- type Version
- type Versioned
Examples ¶
Constants ¶
const ( EnvVarDefaultProfile = "GOCD_DEFAULT_PROFILE" EnvVarServer = "GOCD_SERVER" EnvVarUsername = "GOCD_USERNAME" EnvVarPassword = "GOCD_PASSWORD" EnvVarSkipSsl = "GOCD_SKIP_SSL_CHECK" )
Environment variables for configuration.
const ( // JobStateTransitionPassed "Passed" JobStateTransitionPassed = "Passed" // JobStateTransitionScheduled "Scheduled" JobStateTransitionScheduled = "Scheduled" )
const ( LogLevelEnvVarName = "GOCD_LOG_LEVEL" LogLevelDefault = "WARNING" LogTypeEnvVarName = "GOCD_LOG_TYPE" LogTypeDefault = "TEXT" )
Set logging level and type constants
const ConfigDirectoryPath = "~/.gocd.conf"
ConfigDirectoryPath is the default location of the `.gocdconf` configuration file
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
func CheckResponse(response *APIResponse) (err error)
CheckResponse asserts that the http response status code was 2xx.
func ConfigFilePath ¶
ConfigFilePath specifies the default path to a config file
func Int ¶
Int returns a pointer to the int value passed in. Allows `omitempty` to function in json building
func LoadConfigByName ¶
func LoadConfigByName(name string, cfg *Configuration) (err error)
LoadConfigByName loads configurations from yaml at the default file location
func LoadConfigFromFile ¶
func LoadConfigFromFile() (cfgs map[string]*Configuration, err error)
LoadConfigFromFile on disk and return it as a Configuration item
func SetupLogging ¶
SetupLogging based on Environment Variables
Set Logging level with $GOCD_LOG_LEVEL Allowed Values: - DEBUG - INFO - WARNING - ERROR - FATAL - PANIC Set Logging type with $GOCD_LOG_TYPE Allowed Values: - JSON - TEXT
Types ¶
type APIClientRequest ¶
type APIClientRequest struct { Method string Path string APIVersion string RequestBody interface{} ResponseType string ResponseBody interface{} Headers map[string]string }
APIClientRequest helper struct to reduce amount of code.
type APIRequest ¶
APIRequest encapsulates the net/http.Request object, and a string representing the Body.
type APIResponse ¶
type APIResponse struct { HTTP *http.Response Body string Request *APIRequest }
APIResponse encapsulates the net/http.Response object, a string representing the Body, and a gocd.Request object encapsulating the response from the API.
type Agent ¶
type Agent struct { UUID string `json:"uuid,omitempty"` Hostname string `json:"hostname,omitempty"` ElasticAgentID string `json:"elastic_agent_id,omitempty"` ElasticPluginID string `json:"elastic_plugin_id,omitempty"` IPAddress string `json:"ip_address,omitempty"` Sandbox string `json:"sandbox,omitempty"` OperatingSystem string `json:"operating_system,omitempty"` FreeSpace int `json:"free_space,omitempty"` AgentConfigState string `json:"agent_config_state,omitempty"` AgentState string `json:"agent_state,omitempty"` Resources []string `json:"resources,omitempty"` Environments []string `json:"environments,omitempty"` BuildState string `json:"build_state,omitempty"` BuildDetails *BuildDetails `json:"build_details,omitempty"` Links *HALLinks `json:"_links,omitempty,omitempty"` // contains filtered or unexported fields }
Agent represents agent in GoCD codebeat:disable[TOO_MANY_IVARS]
func (*Agent) RemoveLinks ¶
func (a *Agent) RemoveLinks()
RemoveLinks sets the `Link` attribute as `nil`. Used when rendering an `Agent` struct to JSON.
type AgentBulkOperationUpdate ¶
type AgentBulkOperationUpdate struct { Add []string `json:"add,omitempty"` Remove []string `json:"remove,omitempty"` }
AgentBulkOperationUpdate describes an action to be performed on an Environment or Resource during an agent update.
type AgentBulkOperationsUpdate ¶
type AgentBulkOperationsUpdate struct { Environments *AgentBulkOperationUpdate `json:"environments,omitempty"` Resources *AgentBulkOperationUpdate `json:"resources,omitempty"` }
AgentBulkOperationsUpdate describes the structure for a single Operation in AgentBulkUpdate the PUT payload when updating multiple agents
type AgentBulkUpdate ¶
type AgentBulkUpdate struct { Uuids []string `json:"uuids"` Operations *AgentBulkOperationsUpdate `json:"operations,omitempty"` AgentConfigState string `json:"agent_config_state,omitempty"` }
AgentBulkUpdate describes the structure for the PUT payload when updating multiple agents
type AgentsResponse ¶
type AgentsResponse struct { Links *HALLinks `json:"_links,omitempty"` Embedded *struct { Agents []*Agent `json:"agents"` } `json:"_embedded,omitempty"` }
AgentsResponse describes the structure of the API response when listing collections of agent objects
type AgentsService ¶
type AgentsService service
AgentsService describes actions which can be performed on agents
func (*AgentsService) BulkUpdate ¶
func (s *AgentsService) BulkUpdate(ctx context.Context, agents AgentBulkUpdate) (message string, resp *APIResponse, err error)
BulkUpdate will change the configuration for multiple agents in a single request.
func (*AgentsService) Delete ¶
func (s *AgentsService) Delete(ctx context.Context, uuid string) (string, *APIResponse, error)
Delete will remove an existing agent. Note: The agent must be disabled, and not currently building to be deleted.
func (*AgentsService) Get ¶
func (s *AgentsService) Get(ctx context.Context, uuid string) (*Agent, *APIResponse, error)
Get will retrieve a single agent based on the provided UUID.
func (*AgentsService) JobRunHistory ¶
func (s *AgentsService) JobRunHistory(ctx context.Context, uuid string) (jobs []*Job, resp *APIResponse, err error)
JobRunHistory will return a list of Jobs run on the agent identified by `uuid`.
func (*AgentsService) List ¶
func (s *AgentsService) List(ctx context.Context) (agents []*Agent, resp *APIResponse, err error)
List will retrieve all agents, their status, and metadata from the GoCD Server.
Example ¶
package main import ( "context" "fmt" "github.com/beamly/go-gocd/gocd" ) func main() { cfg := gocd.Configuration{ Server: "https://my_gocd/go/", // don't forget the "/go/" at the end of the url to avoid issues! Username: "ApiUser", Password: "MySecretPassword", } c := cfg.Client() // list all agents in use by the GoCD Server var a []*gocd.Agent var err error var r *gocd.APIResponse if a, r, err = c.Agents.List(context.Background()); err != nil { if r.HTTP.StatusCode == 404 { fmt.Println("Couldn't find agent") } else { panic(err) } } fmt.Println(a) }
Output:
func (*AgentsService) Update ¶
func (s *AgentsService) Update(ctx context.Context, uuid string, agent *Agent) (*Agent, *APIResponse, error)
Update will modify the configuration for an existing agents.
type Approval ¶
type Approval struct { Type string `json:"type"` Authorization *Authorization `json:"authorization"` }
Approval represents a request/response object describing the approval configuration for a GoCD Job
type Artifact ¶
type Artifact struct { Type string `json:"type"` Source string `json:"source"` Destination string `json:"destination"` }
Artifact describes the result of a job
type Auth ¶
Auth structure wrapping the Username and Password variables, which are used to get an Auth cookie header used for subsequent requests.
type Authorization ¶
Authorization describes the access control for a "manual" approval type. Specifies who (role or users) can approve the job to move to the next stage in the pipeline.
type BuildCause ¶
type BuildCause struct { Approver string `json:"approver,omitempty"` MaterialRevisions []MaterialRevision `json:"material_revisions"` TriggerForced bool `json:"trigger_forced"` TriggerMessage string `json:"trigger_message"` }
BuildCause describes the triggers which caused the build to start.
type BuildDetails ¶
type BuildDetails struct { Links *HALLinks `json:"_links"` Pipeline string `json:"pipeline"` Stage string `json:"stage"` Job string `json:"job"` }
BuildDetails describes the builds being performed on this agent.
type CipherText ¶
type CipherText struct { EncryptedValue string `json:"encrypted_value"` Links *HALLinks `json:"_links"` }
CipherText sescribes the response from the api with an encrypted value.
type Client ¶
type Client struct { Log *logrus.Logger Agents *AgentsService PipelineGroups *PipelineGroupsService Stages *StagesService Jobs *JobsService PipelineTemplates *PipelineTemplatesService Pipelines *PipelinesService PipelineConfigs *PipelineConfigsService Configuration *ConfigurationService ConfigRepos *ConfigRepoService Encryption *EncryptionService Plugins *PluginsService Environments *EnvironmentsService Properties *PropertiesService Roles *RoleService ServerVersion *ServerVersionService // contains filtered or unexported fields }
Client struct which acts as an interface to the GoCD Server. Exposes resource service handlers.
func NewClient ¶
func NewClient(cfg *Configuration, httpClient *http.Client) *Client
NewClient creates a new client based on the provided configuration payload, and optionally a custom httpClient to allow overriding of http client structures.
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, req *APIRequest, v interface{}, responseType string) (*APIResponse, error)
Do takes an HTTP request and resposne the response from the GoCD API endpoint.
func (*Client) Login ¶
Login sends basic auth to the GoCD Server and sets an auth cookie in the client to enable cookie based auth for future requests.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(method, urlStr string, body interface{}, apiVersion string) (req *APIRequest, err error)
NewRequest creates an HTTP requests to the GoCD API endpoints.
type ClientParameters ¶
ClientParameters describe how the client interacts with the GoCD Server
type ConfigApproval ¶
type ConfigApproval struct {
Type string `xml:"type,attr,omitempty" json:",omitempty"`
}
ConfigApproval part of cruise-control.xml. @TODO better documentation
type ConfigArtifact ¶
type ConfigArtifact struct { Src string `xml:"src,attr"` Destination string `xml:"dest,attr,omitempty" json:",omitempty"` }
ConfigArtifact part of cruise-control.xml. @TODO better documentation
type ConfigAuthConfig ¶
type ConfigAuthConfig struct { ID string `xml:"id,attr"` PluginID string `xml:"pluginId,attr"` Properties []ConfigProperty `xml:"property"` }
ConfigAuthConfig part of cruise-control.xml. @TODO better documentation
type ConfigElastic ¶
type ConfigElastic struct {
Profiles []ConfigElasticProfile `xml:"profiles>profile"`
}
ConfigElastic part of cruise-control.xml. @TODO better documentation
type ConfigElasticProfile ¶
type ConfigElasticProfile struct { ID string `xml:"id,attr"` PluginID string `xml:"pluginId,attr"` Properties []ConfigProperty `xml:"property"` }
ConfigElasticProfile part of cruise-control.xml. @TODO better documentation
type ConfigEnvironmentVariable ¶
ConfigEnvironmentVariable part of cruise-control.xml. @TODO better documentation
type ConfigFilter ¶
type ConfigFilter struct {
Ignore string `xml:"pattern,attr,omitempty"`
}
ConfigFilter part of cruise-control.xml. @TODO better documentation
type ConfigJob ¶
type ConfigJob struct { Name string `xml:"name,attr"` EnvironmentVariables []ConfigEnvironmentVariable `xml:"environmentvariables>variable" json:",omitempty"` Tasks ConfigTasks `xml:"tasks"` Resources []string `xml:"resources>resource" json:",omitempty"` Artifacts []ConfigArtifact `xml:"artifacts>artifact" json:",omitempty"` }
ConfigJob part of cruise-control.xml. @TODO better documentation
type ConfigMaterialRepository ¶
type ConfigMaterialRepository struct { ID string `xml:"id,attr"` Name string `xml:"name,attr"` PluginConfiguration ConfigPluginConfiguration `xml:"pluginConfiguration"` Configuration []ConfigProperty `xml:"configuration>property"` Packages []ConfigPackage `xml:"packages>package"` }
ConfigMaterialRepository part of cruise-control.xml. @TODO better documentation
type ConfigPackage ¶
type ConfigPackage struct { ID string `xml:"id,attr"` Name string `xml:"name,attr"` Configuration []ConfigProperty `xml:"configuration>property"` }
ConfigPackage part of cruise-control.xml. @TODO better documentation
type ConfigParam ¶
ConfigParam part of cruise-control.xml. @TODO better documentation
type ConfigPipeline ¶
type ConfigPipeline struct { Name string `xml:"name,attr"` LabelTemplate string `xml:"labeltemplate,attr"` Params []ConfigParam `xml:"params>param"` GitMaterials []GitRepositoryMaterial `xml:"materials>git,omitempty"` PipelineMaterials []PipelineMaterial `xml:"materials>pipeline,omitempty"` Timer string `xml:"timer"` EnvironmentVariables []ConfigEnvironmentVariable `xml:"environmentvariables>variable"` Stages []ConfigStage `xml:"stage"` }
ConfigPipeline part of cruise-control.xml. @TODO better documentation codebeat:disable[TOO_MANY_IVARS]
type ConfigPipelineGroup ¶
type ConfigPipelineGroup struct { Name string `xml:"group,attr"` Pipelines []ConfigPipeline `xml:"pipeline"` }
ConfigPipelineGroup contains a single pipeline groups
type ConfigPluginConfiguration ¶
type ConfigPluginConfiguration struct { ID string `xml:"id,attr"` Version string `xml:"version,attr"` }
ConfigPluginConfiguration part of cruise-control.xml. @TODO better documentation
type ConfigProperty ¶
ConfigProperty part of cruise-control.xml. @TODO better documentation
type ConfigRepo ¶
type ConfigRepo struct { ID string `json:"id"` PluginID string `json:"plugin_id"` Material Material `json:"material"` Configuration []*ConfigRepoProperty `json:"configuration,omitempty"` Links *HALLinks `json:"_links,omitempty,omitempty"` Version string `json:"version,omitempty"` // contains filtered or unexported fields }
ConfigRepo represents a config repo object in GoCD
func (*ConfigRepo) GetVersion ¶
func (c *ConfigRepo) GetVersion() (version string)
GetVersion retrieves a version string for this config repo
func (*ConfigRepo) SetVersion ¶
func (c *ConfigRepo) SetVersion(version string)
SetVersion sets a version string for this config repo
type ConfigRepoProperty ¶
type ConfigRepoProperty struct { Key string `json:"key"` Value string `json:"value,omitempty"` EncryptedValue string `json:"encrypted_value,omitempty"` }
ConfigRepoProperty represents a configuration related to a ConfigRepo
type ConfigRepoService ¶
type ConfigRepoService service
ConfigRepoService allows admin users to define and manage config repos using which pipelines defined in external repositories can be included in GoCD, thereby allowing users to have their Pipeline as code.
func (*ConfigRepoService) Create ¶
func (crs *ConfigRepoService) Create(ctx context.Context, cr *ConfigRepo) (out *ConfigRepo, resp *APIResponse, err error)
Create a config repo
Example ¶
package main import ( "context" "fmt" "github.com/beamly/go-gocd/gocd" ) func main() { // This example creates a config repo that uses a git material and a json config plugin cfg := gocd.Configuration{ Server: "https://my_gocd/go/", // don't forget the "/go/" at the end of the url to avoid issues! Username: "ApiUser", Password: "MySecretPassword", } c := cfg.Client() name := "my_pipeline_name" repoURL := "git@github.com:example/myrepo.git" repo := gocd.ConfigRepo{ID: name, PluginID: "json.config.plugin", Material: gocd.Material{Type: "git", Attributes: &gocd.MaterialAttributesGit{URL: repoURL, Branch: "master", AutoUpdate: true}}} r, _, err := c.ConfigRepos.Create(context.Background(), &repo) if err != nil { panic(err) } fmt.Printf("Pipeline created:\n\tName: %s\n\tMaterial type: %s\n", r.ID, r.Material.Type) if r.Material.Type == "git" { fmt.Printf("\tMaterial url: %s\n", r.Material.Attributes.(*gocd.MaterialAttributesGit).URL) } fmt.Printf("\tNumber of configuration parameters: %d\n\n", len(r.Configuration)) }
Output:
func (*ConfigRepoService) Delete ¶
func (crs *ConfigRepoService) Delete(ctx context.Context, id string) (string, *APIResponse, error)
Delete the specified config repo
func (*ConfigRepoService) Get ¶
func (crs *ConfigRepoService) Get(ctx context.Context, id string) (out *ConfigRepo, resp *APIResponse, err error)
Get fetches the config repo object for a specified id
Example ¶
package main import ( "context" "fmt" "github.com/beamly/go-gocd/gocd" ) func main() { cfg := gocd.Configuration{ Server: "https://my_gocd/go/", // don't forget the "/go/" at the end of the url to avoid issues! Username: "ApiUser", Password: "MySecretPassword", } c := cfg.Client() r, _, err := c.ConfigRepos.Get(context.Background(), "my_repo_config_id") if err != nil { panic(err) } fmt.Printf("Pipeline: %s\n\tMaterial type: %s\n", r.ID, r.Material.Type) if r.Material.Type == "git" { fmt.Printf("\tMaterial url: %s\n", r.Material.Attributes.(*gocd.MaterialAttributesGit).URL) } fmt.Printf("\tNumber of configuration parameters: %d\n\n", len(r.Configuration)) }
Output:
func (*ConfigRepoService) List ¶
func (crs *ConfigRepoService) List(ctx context.Context) (repos []*ConfigRepo, resp *APIResponse, err error)
List returns all available config repos, these are config repositories that are present in the in `cruise-config.xml`
Example ¶
package main import ( "context" "fmt" "github.com/beamly/go-gocd/gocd" ) func main() { cfg := gocd.Configuration{ Server: "https://my_gocd/go/", // don't forget the "/go/" at the end of the url to avoid issues! Username: "ApiUser", Password: "MySecretPassword", } c := cfg.Client() l, _, err := c.ConfigRepos.List(context.Background()) if err != nil { panic(err) } // Loops through the list of repositories to display some basic informations for _, r := range l { fmt.Printf("Pipeline: %s\n\tMaterial type: %s\n", r.ID, r.Material.Type) if r.Material.Type == "git" { fmt.Printf("\tMaterial url: %s\n", r.Material.Attributes.(*gocd.MaterialAttributesGit).URL) } fmt.Printf("\tNumber of configuration parameters: %d\n\n", len(r.Configuration)) } }
Output:
func (*ConfigRepoService) Update ¶
func (crs *ConfigRepoService) Update(ctx context.Context, id string, cr *ConfigRepo) (out *ConfigRepo, resp *APIResponse, err error)
Update config repos for specified config repo id
type ConfigReposListResponse ¶
type ConfigReposListResponse struct { Links *HALLinks `json:"_links,omitempty"` Embedded *struct { Repos []*ConfigRepo `json:"config_repos"` } `json:"_embedded,omitempty"` }
ConfigReposListResponse describes the structure of the API response when listing collections of ConfigRepo objects
type ConfigRepository ¶
type ConfigRepository struct { Plugin string `xml:"plugin,attr"` ID string `xml:"id,attr"` Git ConfigRepositoryGit `xml:"git"` }
ConfigRepository part of cruise-control.xml. @TODO better documentation
type ConfigRepositoryGit ¶
type ConfigRepositoryGit struct {
URL string `xml:"url,attr"`
}
ConfigRepositoryGit part of cruise-control.xml. @TODO better documentation
type ConfigRole ¶
ConfigRole part of cruise-control.xml. @TODO better documentation
type ConfigSCM ¶
type ConfigSCM struct { ID string `xml:"id,attr"` Name string `xml:"name,attr"` PluginConfiguration ConfigPluginConfiguration `xml:"pluginConfiguration"` Configuration []ConfigProperty `xml:"configuration>property"` }
ConfigSCM part of cruise-control.xml. @TODO better documentation
type ConfigSecurity ¶
type ConfigSecurity struct { AuthConfigs []ConfigAuthConfig `xml:"authConfigs>authConfig"` Roles []ConfigRole `xml:"roles>role"` Admins []string `xml:"admins>user"` PasswordFile PasswordFilePath `xml:"passwordFile"` }
ConfigSecurity part of cruise-control.xml. @TODO better documentation
type ConfigServer ¶
type ConfigServer struct { MailHost MailHost `xml:"mailhost"` Security ConfigSecurity `xml:"security"` Elastic ConfigElastic `xml:"elastic"` ArtifactsDir string `xml:"artifactsdir,attr"` SiteURL string `xml:"siteUrl,attr"` SecureSiteURL string `xml:"secureSiteUrl,attr"` PurgeStart string `xml:"purgeStart,attr"` PurgeUpTo string `xml:"purgeUpto,attr"` JobTimeout int `xml:"jobTimeout,attr"` AgentAutoRegisterKey string `xml:"agentAutoRegisterKey,attr"` WebhookSecret string `xml:"webhookSecret,attr"` CommandRepositoryLocation string `xml:"commandRepositoryLocation,attr"` ServerID string `xml:"serverId,attr"` }
ConfigServer part of cruise-control.xml. @TODO better documentation codebeat:disable[TOO_MANY_IVARS]
type ConfigStage ¶
type ConfigStage struct { Name string `xml:"name,attr"` Approval ConfigApproval `xml:"approval,omitempty" json:",omitempty"` Jobs []ConfigJob `xml:"jobs>job"` }
ConfigStage part of cruise-control.xml. @TODO better documentation
type ConfigTask ¶
type ConfigTask struct { // Because we need to preserve the order of tasks, and we have an array of elements with mixed types, // we need to use this generic xml type for tasks. XMLName xml.Name `json:",omitempty"` Type string `xml:"type,omitempty"` RunIf ConfigTaskRunIf `xml:"runif"` Command string `xml:"command,attr,omitempty" json:",omitempty"` Args []string `xml:"arg,omitempty" json:",omitempty"` Pipeline string `xml:"pipeline,attr,omitempty" json:",omitempty"` Stage string `xml:"stage,attr,omitempty" json:",omitempty"` Job string `xml:"job,attr,omitempty" json:",omitempty"` SrcFile string `xml:"srcfile,attr,omitempty" json:",omitempty"` SrcDir string `xml:"srcdir,attr,omitempty" json:",omitempty"` }
ConfigTask part of cruise-control.xml. @TODO better documentation codebeat:disable[TOO_MANY_IVARS]
type ConfigTaskRunIf ¶
type ConfigTaskRunIf struct {
Status string `xml:"status,attr"`
}
ConfigTaskRunIf part of cruise-control.xml. @TODO better documentation
type ConfigTasks ¶
type ConfigTasks struct {
Tasks []ConfigTask `xml:",any"`
}
ConfigTasks part of cruise-control.xml. @TODO better documentation
type ConfigXML ¶
type ConfigXML struct { Repositories []ConfigMaterialRepository `xml:"repositories>repository"` Server ConfigServer `xml:"server"` SCMS []ConfigSCM `xml:"scms>scm"` ConfigRepositories []ConfigRepository `xml:"config-repos>config-repo"` PipelineGroups []ConfigPipelineGroup `xml:"pipelines"` }
ConfigXML part of cruise-control.xml. @TODO better documentation
type Configuration ¶
type Configuration struct { Server string Username string `yaml:"username,omitempty"` Password string `yaml:"password,omitempty"` SkipSslCheck bool `yaml:"skip_ssl_check,omitempty" survey:"skip_ssl_check"` }
Configuration describes a single connection to a GoCD server
func (*Configuration) Client ¶
func (c *Configuration) Client() *Client
Client returns a client which allows us to interact with the GoCD Server.
func (*Configuration) HasAuth ¶
func (c *Configuration) HasAuth() bool
HasAuth checks whether or not we have the required Username/Password variables provided.
type ConfigurationService ¶
type ConfigurationService service
ConfigurationService describes the HAL _link resource for the api response object for a pipelineconfig
func (*ConfigurationService) Get ¶
func (cs *ConfigurationService) Get(ctx context.Context) (cx *ConfigXML, resp *APIResponse, err error)
Get the config.xml document from the server and... render it as JSON... 'cause... eyugh.
func (*ConfigurationService) GetVersion ¶
func (cs *ConfigurationService) GetVersion(ctx context.Context) (v *Version, resp *APIResponse, err error)
GetVersion of the GoCD server and other metadata about the software version.
type EmbeddedEnvironments ¶
type EmbeddedEnvironments struct {
Environments []*Environment `json:"environments"`
}
EmbeddedEnvironments encapsulates the environment struct
type EncryptionService ¶
type EncryptionService service
EncryptionService describes the HAL _link resource for the api response object for a pipelineconfig
func (*EncryptionService) Encrypt ¶
func (es *EncryptionService) Encrypt(ctx context.Context, plaintext string) (c *CipherText, resp *APIResponse, err error)
Encrypt takes a plaintext value and returns a cipher text.
type Environment ¶
type Environment struct { Links *HALLinks `json:"_links,omitempty"` Name string `json:"name"` Pipelines []*Pipeline `json:"pipelines,omitempty"` Agents []*Agent `json:"agents,omitempty"` EnvironmentVariables []*EnvironmentVariable `json:"environment_variables,omitempty"` Version string `json:"version"` }
Environment describes a group of pipelines and agents
func (*Environment) GetLinks ¶
func (env *Environment) GetLinks() *HALLinks
GetLinks from the Environment
func (*Environment) GetVersion ¶
func (env *Environment) GetVersion() (version string)
GetVersion retrieves a version string for this pipeline
func (*Environment) RemoveLinks ¶
func (env *Environment) RemoveLinks()
RemoveLinks gets the Environment ready to be submitted to the GoCD API.
func (*Environment) SetVersion ¶
func (env *Environment) SetVersion(version string)
SetVersion sets a version string for this pipeline
type EnvironmentPatchRequest ¶
type EnvironmentPatchRequest struct { Pipelines *PatchStringAction `json:"pipelines"` Agents *PatchStringAction `json:"agents"` EnvironmentVariables *EnvironmentVariablesAction `json:"environment_variables"` }
EnvironmentPatchRequest describes the actions to perform on an environment
type EnvironmentVariable ¶
type EnvironmentVariable struct { Name string `json:"name"` Value string `json:"value,omitempty"` EncryptedValue string `json:"encrypted_value,omitempty"` Secure bool `json:"secure"` }
EnvironmentVariable describes an environment variable key/pair.
func (*EnvironmentVariable) MarshalJSON ¶
func (v *EnvironmentVariable) MarshalJSON() ([]byte, error)
MarshalJSON is a custom JSON Marhsaller for EnvironmentVariables to handle empty values
type EnvironmentVariablesAction ¶
type EnvironmentVariablesAction struct { Add []*EnvironmentVariable `json:"add"` Remove []string `json:"remove"` }
EnvironmentVariablesAction describes a collection of Environment Variables to add or remove.
type EnvironmentsResponse ¶
type EnvironmentsResponse struct { Links *HALLinks `json:"_links"` Embedded *EmbeddedEnvironments `json:"_embedded"` }
EnvironmentsResponse describes the response obejct for a plugin API call.
func (*EnvironmentsResponse) GetLinks ¶
func (er *EnvironmentsResponse) GetLinks() *HALLinks
GetLinks from the EnvironmentResponse
func (*EnvironmentsResponse) RemoveLinks ¶
func (er *EnvironmentsResponse) RemoveLinks()
RemoveLinks gets the EnvironmentsResponse ready to be submitted to the GoCD API.
type EnvironmentsService ¶
type EnvironmentsService service
EnvironmentsService exposes calls for interacting with Environment objects in the GoCD API.
func (*EnvironmentsService) Create ¶
func (es *EnvironmentsService) Create(ctx context.Context, name string) (e *Environment, resp *APIResponse, err error)
Create an environment
func (*EnvironmentsService) Delete ¶
func (es *EnvironmentsService) Delete(ctx context.Context, name string) (string, *APIResponse, error)
Delete an environment
func (*EnvironmentsService) Get ¶
func (es *EnvironmentsService) Get(ctx context.Context, name string) (e *Environment, resp *APIResponse, err error)
Get a single environment by name
func (*EnvironmentsService) List ¶
func (es *EnvironmentsService) List(ctx context.Context) (e *EnvironmentsResponse, resp *APIResponse, err error)
List all environments
func (*EnvironmentsService) Patch ¶
func (es *EnvironmentsService) Patch(ctx context.Context, name string, patch *EnvironmentPatchRequest) (e *Environment, resp *APIResponse, err error)
Patch an environments configuration by adding or removing pipelines, agents, environment variables
type ExtensionCapabilities ¶
type ExtensionCapabilities struct { SupportStatusReport bool `json:"supports_status_report,omitempty"` SupportAgentStatusReport bool `json:"supports_agent_status_report,omitempty"` CanSearch bool `json:"can_search,omitempty"` SupportedAuthType string `json:"supported_auth_type,omitempty"` CanAuthorize bool `json:"can_authorize,omitempty"` ID string `json:"id,omitempty"` Title string `json:"title,omitempty"` Type string `json:"type,omitempty"` }
ExtensionCapabilities describes the enhancements that the plugin provides. codebeat:disable[TOO_MANY_IVARS]
type ExtensionSettings ¶
type ExtensionSettings struct { View PluginView `json:"view,omitempty"` Configurations []*PluginConfiguration `json:"configurations,omitempty"` }
ExtensionSettings describes the html view for the plugin and the list of properties required to be configured on a plugin.
type GitRepositoryMaterial ¶
type GitRepositoryMaterial struct { URL string `xml:"url,attr"` Filters []ConfigFilter `xml:"filter>ignore,omitempty"` }
GitRepositoryMaterial part of cruise-control.xml. @TODO better documentation
type HALContainer ¶
type HALContainer interface { RemoveLinks() GetLinks() *HALLinks }
HALContainer represents objects with HAL _link and _embedded resources.
type HALLinks ¶
type HALLinks struct {
// contains filtered or unexported fields
}
HALLinks describes a collection of HALLinks
func (HALLinks) MarshallJSON ¶
MarshallJSON allows the encoding of links into JSON
func (*HALLinks) UnmarshalJSON ¶
UnmarshalJSON allows the decoding of links from JSON
type Job ¶
type Job struct { AgentUUID string `json:"agent_uuid,omitempty"` Name string `json:"name"` JobStateTransitions []*JobStateTransition `json:"job_state_transitions,omitempty"` ScheduledDate int `json:"scheduled_date,omitempty"` OriginalJobID string `json:"original_job_id,omitempty"` PipelineCounter int `json:"pipeline_counter,omitempty"` Rerun bool `json:"rerun,omitempty"` PipelineName string `json:"pipeline_name,omitempty"` Result string `json:"result,omitempty"` State string `json:"state,omitempty"` ID int `json:"id,omitempty"` StageCounter string `json:"stage_counter,omitempty"` StageName string `json:"stage_name,omitempty"` RunInstanceCount int `json:"run_instance_count,omitempty"` Timeout TimeoutField `json:"timeout,omitempty"` EnvironmentVariables []*EnvironmentVariable `json:"environment_variables,omitempty"` Properties []*JobProperty `json:"properties,omitempty"` Resources []string `json:"resources,omitempty"` Tasks []*Task `json:"tasks,omitempty"` Tabs []*Tab `json:"tabs,omitempty"` Artifacts []*Artifact `json:"artifacts,omitempty"` ElasticProfileID string `json:"elastic_profile_id,omitempty"` }
Job describes a job which can be performed in GoCD codebeat:disable[TOO_MANY_IVARS]
func (*Job) JSONString ¶
JSONString returns a string of this stage as a JSON object.
type JobProperty ¶
type JobProperty struct { Name string `json:"name"` Source string `json:"source"` XPath string `json:"xpath"` }
JobProperty describes the property for a job
type JobRunHistoryResponse ¶
type JobRunHistoryResponse struct { Jobs []*Job `json:"jobs,omitempty"` Pagination *PaginationResponse `json:"pagination,omitempty"` }
JobRunHistoryResponse describes the api response from
type JobSchedule ¶
type JobSchedule struct { Name string `xml:"name,attr"` ID string `xml:"id,attr"` Link JobScheduleLink `xml:"link"` BuildLocator string `xml:"buildLocator"` Resources []string `xml:"resources>resource"` EnvironmentVariables *[]JobScheduleEnvVar `xml:"environmentVariables,omitempty>variable"` }
JobSchedule describes the event causes for a job
type JobScheduleEnvVar ¶
JobScheduleEnvVar describes the environmnet variables for a job schedule
type JobScheduleLink ¶
JobScheduleLink describes the HAL links for a job schedule
type JobScheduleResponse ¶
type JobScheduleResponse struct {
Jobs []*JobSchedule `xml:"job"`
}
JobScheduleResponse contains a collection of jobs
type JobStateTransition ¶
type JobStateTransition struct { StateChangeTime int `json:"state_change_time,omitempty"` ID int `json:"id,omitempty"` State string `json:"state,omitempty"` }
JobStateTransition describes a State Transition object in a GoCD api response
type JobsService ¶
type JobsService service
JobsService describes actions which can be performed on jobs
func (*JobsService) ListScheduled ¶
func (js *JobsService) ListScheduled(ctx context.Context) (jobs []*JobSchedule, resp *APIResponse, err error)
ListScheduled lists Pipeline groups
type MailHost ¶
type MailHost struct { Hostname string `xml:"hostname,attr"` Port int `xml:"port,attr"` TLS bool `xml:"tls,attr"` From string `xml:"from,attr"` Admin string `xml:"admin,attr"` }
MailHost part of cruise-control.xml. @TODO better documentation
type Material ¶
type Material struct { Type string `json:"type"` Fingerprint string `json:"fingerprint,omitempty"` Description string `json:"description,omitempty"` Attributes MaterialAttribute `json:"attributes"` }
Material describes an artifact dependency for a pipeline object.
func (Material) Equal ¶
Equal is true if the two materials are logically equivalent. Not neccesarily literally equal.
func (*Material) IngestAttributeGenerics ¶
IngestAttributeGenerics to Material and perform some error checking
func (*Material) IngestAttributes ¶
IngestAttributes to Material from an abstract structure
func (*Material) IngestType ¶
IngestType of Material if it is provided
func (*Material) UnmarshalJSON ¶
UnmarshalJSON string into a Material struct
type MaterialAttribute ¶
type MaterialAttribute interface { GenerateGeneric() map[string]interface{} HasFilter() bool GetFilter() *MaterialFilter // contains filtered or unexported methods }
MaterialAttribute describes the behaviour of the GoCD material structures for a pipeline
type MaterialAttributesDependency ¶
type MaterialAttributesDependency struct { Name string `json:"name,omitempty"` Pipeline string `json:"pipeline"` Stage string `json:"stage"` AutoUpdate bool `json:"auto_update,omitempty"` }
MaterialAttributesDependency describes a Pipeline dependency material
func (MaterialAttributesDependency) GenerateGeneric ¶
func (mad MaterialAttributesDependency) GenerateGeneric() (ma map[string]interface{})
GenerateGeneric form (map[string]interface) of the material filter
func (MaterialAttributesDependency) GetFilter ¶
func (mad MaterialAttributesDependency) GetFilter() *MaterialFilter
GetFilter from material attribute
func (MaterialAttributesDependency) HasFilter ¶
func (mad MaterialAttributesDependency) HasFilter() bool
HasFilter in this material attribute
type MaterialAttributesGit ¶
type MaterialAttributesGit struct { Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` Branch string `json:"branch,omitempty"` SubmoduleFolder string `json:"submodule_folder,omitempty"` ShallowClone bool `json:"shallow_clone,omitempty"` Destination string `json:"destination,omitempty"` Filter *MaterialFilter `json:"filter,omitempty"` InvertFilter bool `json:"invert_filter"` AutoUpdate bool `json:"auto_update,omitempty"` }
MaterialAttributesGit describes a git material codebeat:disable[TOO_MANY_IVARS]
func (MaterialAttributesGit) GenerateGeneric ¶
func (mag MaterialAttributesGit) GenerateGeneric() (ma map[string]interface{})
GenerateGeneric form (map[string]interface) of the material filter
func (MaterialAttributesGit) GetFilter ¶
func (mag MaterialAttributesGit) GetFilter() *MaterialFilter
GetFilter from material attribute
func (MaterialAttributesGit) HasFilter ¶
func (mag MaterialAttributesGit) HasFilter() bool
HasFilter in this material attribute
type MaterialAttributesHg ¶
type MaterialAttributesHg struct { Name string `json:"name,omitempty"` URL string `json:"url"` Destination string `json:"destination"` Filter *MaterialFilter `json:"filter,omitempty"` InvertFilter bool `json:"invert_filter"` AutoUpdate bool `json:"auto_update,omitempty"` }
MaterialAttributesHg describes a Mercurial material type
func (MaterialAttributesHg) GenerateGeneric ¶
func (mhg MaterialAttributesHg) GenerateGeneric() (ma map[string]interface{})
GenerateGeneric form (map[string]interface) of the material filter
func (MaterialAttributesHg) GetFilter ¶
func (mhg MaterialAttributesHg) GetFilter() *MaterialFilter
GetFilter from material attribute
func (MaterialAttributesHg) HasFilter ¶
func (mhg MaterialAttributesHg) HasFilter() bool
HasFilter in this material attribute
type MaterialAttributesP4 ¶
type MaterialAttributesP4 struct { Name string `json:"name,omitempty"` Port string `json:"port"` UseTickets bool `json:"use_tickets"` View string `json:"view"` Username string `json:"username"` Password string `json:"password"` EncryptedPassword string `json:"encrypted_password"` Destination string `json:"destination"` Filter *MaterialFilter `json:"filter,omitempty"` InvertFilter bool `json:"invert_filter"` AutoUpdate bool `json:"auto_update,omitempty"` }
MaterialAttributesP4 describes a Perforce material type codebeat:disable[TOO_MANY_IVARS]
func (MaterialAttributesP4) GenerateGeneric ¶
func (mp4 MaterialAttributesP4) GenerateGeneric() (ma map[string]interface{})
GenerateGeneric form (map[string]interface) of the material filter
func (MaterialAttributesP4) GetFilter ¶
func (mp4 MaterialAttributesP4) GetFilter() *MaterialFilter
GetFilter from material attribute
func (MaterialAttributesP4) HasFilter ¶
func (mp4 MaterialAttributesP4) HasFilter() bool
HasFilter in this material attribute
type MaterialAttributesPackage ¶
type MaterialAttributesPackage struct {
Ref string `json:"ref"`
}
MaterialAttributesPackage describes a package reference
func (MaterialAttributesPackage) GenerateGeneric ¶
func (mapk MaterialAttributesPackage) GenerateGeneric() (ma map[string]interface{})
GenerateGeneric form (map[string]interface) of the material filter
func (MaterialAttributesPackage) GetFilter ¶
func (mapk MaterialAttributesPackage) GetFilter() *MaterialFilter
GetFilter from material attribute
func (MaterialAttributesPackage) HasFilter ¶
func (mapk MaterialAttributesPackage) HasFilter() bool
HasFilter in this material attribute
type MaterialAttributesPlugin ¶
type MaterialAttributesPlugin struct { Ref string `json:"ref"` Destination string `json:"destination"` Filter *MaterialFilter `json:"filter,omitempty"` InvertFilter bool `json:"invert_filter"` }
MaterialAttributesPlugin describes a plugin material
func (MaterialAttributesPlugin) GenerateGeneric ¶
func (mapp MaterialAttributesPlugin) GenerateGeneric() (ma map[string]interface{})
GenerateGeneric form (map[string]interface) of the material filter
func (MaterialAttributesPlugin) GetFilter ¶
func (mapp MaterialAttributesPlugin) GetFilter() *MaterialFilter
GetFilter from material attribute
func (MaterialAttributesPlugin) HasFilter ¶
func (mapp MaterialAttributesPlugin) HasFilter() bool
HasFilter in this material attribute
type MaterialAttributesSvn ¶
type MaterialAttributesSvn struct { Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` Username string `json:"username"` Password string `json:"password"` EncryptedPassword string `json:"encrypted_password"` CheckExternals bool `json:"check_externals"` Destination string `json:"destination,omitempty"` Filter *MaterialFilter `json:"filter,omitempty"` InvertFilter bool `json:"invert_filter"` AutoUpdate bool `json:"auto_update,omitempty"` }
MaterialAttributesSvn describes a material type codebeat:disable[TOO_MANY_IVARS]
func (MaterialAttributesSvn) GenerateGeneric ¶
func (mas MaterialAttributesSvn) GenerateGeneric() (ma map[string]interface{})
GenerateGeneric form (map[string]interface) of the material filter
func (MaterialAttributesSvn) GetFilter ¶
func (mas MaterialAttributesSvn) GetFilter() *MaterialFilter
GetFilter from material attribute
func (MaterialAttributesSvn) HasFilter ¶
func (mas MaterialAttributesSvn) HasFilter() bool
HasFilter in this material attribute
type MaterialAttributesTfs ¶
type MaterialAttributesTfs struct { Name string `json:"name,omitempty"` URL string `json:"url"` ProjectPath string `json:"project_path"` Domain string `json:"domain"` Username string `json:"username"` Password string `json:"password"` EncryptedPassword string `json:"encrypted_password"` Destination string `json:"destination"` Filter *MaterialFilter `json:"filter,omitempty"` InvertFilter bool `json:"invert_filter"` AutoUpdate bool `json:"auto_update,omitempty"` }
MaterialAttributesTfs describes a Team Foundation Server material codebeat:disable[TOO_MANY_IVARS]
func (MaterialAttributesTfs) GenerateGeneric ¶
func (mtfs MaterialAttributesTfs) GenerateGeneric() (ma map[string]interface{})
GenerateGeneric form (map[string]interface) of the material filter
func (MaterialAttributesTfs) GetFilter ¶
func (mtfs MaterialAttributesTfs) GetFilter() *MaterialFilter
GetFilter from material attribute
func (MaterialAttributesTfs) HasFilter ¶
func (mtfs MaterialAttributesTfs) HasFilter() bool
HasFilter in this material attribute
type MaterialFilter ¶
type MaterialFilter struct {
Ignore []string `json:"ignore"`
}
MaterialFilter describes which globs to ignore
func (*MaterialFilter) GenerateGeneric ¶
func (mf *MaterialFilter) GenerateGeneric() (g map[string]interface{})
GenerateGeneric form (map[string]interface) of the material filter
type MaterialRevision ¶
type MaterialRevision struct { Modifications []Modification `json:"modifications"` Material struct { Description string `json:"description"` Fingerprint string `json:"fingerprint"` Type string `json:"type"` ID int `json:"id"` } `json:"material"` Changed bool `json:"changed"` }
MaterialRevision describes the uniquely identifiable version for the material which was pulled for this build
type Modification ¶
type Modification struct { EmailAddress string `json:"email_address"` ID int `json:"id"` ModifiedTime int `json:"modified_time"` UserName string `json:"user_name"` Comment string `json:"comment"` Revision string `json:"revision"` }
Modification describes the commit/revision for the material which kicked off the build.
type PaginationResponse ¶
type PaginationResponse struct { Offset int `json:"offset"` Total int `json:"total"` PageSize int `json:"page_size"` }
PaginationResponse is a struct used to handle paging through resposnes.
type PasswordFilePath ¶
type PasswordFilePath struct {
Path string `xml:"path,attr"`
}
PasswordFilePath describes the location to set of user/passwords on disk
type PatchStringAction ¶
PatchStringAction describes a collection of resources to add or remove.
type Pipeline ¶
type Pipeline struct { Links *HALLinks `json:"_links,omitempty"` Group string `json:"group,omitempty"` // Group is only used/set when creating or editing a pipeline config LabelTemplate string `json:"label_template,omitempty"` // LabelTemplate is available for the pipeline config API since v1 (GoCD >= 15.3.0). EnablePipelineLocking bool `json:"enable_pipeline_locking,omitempty"` // EnablePipelineLocking is available for the pipeline config API v1 to v4 (GoCD >= 15.3.0 to GoCD < 17.12.0). Use LockBehavior after that. Name string `json:"name"` // Name is available for the pipeline config API since v1 (GoCD >= 15.3.0). LockBehavior string `json:"lock_behavior,omitempty"` // LockBehavior is available for the pipeline config API v5 and v6 only (GoCD >= 17.12.0). Template string `json:"template,omitempty"` // Template is available for the pipeline config API since v1 (GoCD >= 15.3.0). Origin *PipelineConfigOrigin `json:"origin,omitempty"` // Origin is available for the pipeline config API since v3 (GoCD >= 17.4.0). Parameters []*Parameter `json:"parameters,omitempty"` // Parameters is available for the pipeline config API since v1 (GoCD >= 15.3.0). EnvironmentVariables []*EnvironmentVariable `json:"environment_variables,omitempty"` // EnvironmentVariables is available for the pipeline config API since v1 (GoCD >= 15.3.0). Materials []Material `json:"materials,omitempty"` // Materials is available for the pipeline config API since v1 (GoCD >= 15.3.0). Label string `json:"label,omitempty"` // Label is only available for the pipeline instance Stages []*Stage `json:"stages,omitempty"` // Stages is available for the pipeline config API since v1 (GoCD >= 15.3.0). TrackingTool *TrackingTool `json:"tracking_tool"` // TrackingTool is available for the pipeline config API since v1 (GoCD >= 15.3.0). Timer *Timer `json:"timer"` // Timer is available for the pipeline config API since v1 (GoCD >= 15.3.0). Version string `json:"version,omitempty"` // Version corresponds to the ETag header used when updating a pipeline config }
Pipeline describes a pipeline object codebeat:disable[TOO_MANY_IVARS]
func (*Pipeline) GetVersion ¶
GetVersion retrieves a version string for this pipeline
func (*Pipeline) RemoveLinks ¶
func (p *Pipeline) RemoveLinks()
RemoveLinks from the pipeline object for json marshalling.
func (*Pipeline) SetVersion ¶
SetVersion sets a version string for this pipeline
type PipelineConfigOrigin ¶
PipelineConfigOrigin describes where a pipeline config is being loaded from
type PipelineConfigRequest ¶
type PipelineConfigRequest struct { Group string `json:"group,omitempty"` Pipeline *Pipeline `json:"pipeline"` }
PipelineConfigRequest describes a request object for creating or updating pipelines
func (*PipelineConfigRequest) GetVersion ¶
func (pr *PipelineConfigRequest) GetVersion() (version string)
GetVersion of pipeline config
func (*PipelineConfigRequest) SetVersion ¶
func (pr *PipelineConfigRequest) SetVersion(version string)
SetVersion of pipeline config
type PipelineConfigsService ¶
type PipelineConfigsService service
PipelineConfigsService describes the HAL _link resource for the api response object for a pipelineconfig
func (*PipelineConfigsService) Create ¶
func (pcs *PipelineConfigsService) Create(ctx context.Context, group string, p *Pipeline) (pr *Pipeline, resp *APIResponse, err error)
Create a pipeline configuration
func (*PipelineConfigsService) Delete ¶
func (pcs *PipelineConfigsService) Delete(ctx context.Context, name string) (string, *APIResponse, error)
Delete a pipeline configuration
Example ¶
package main import ( "context" "github.com/beamly/go-gocd/gocd" ) func main() { // This example deletes the pipeline "my_pipeline_name" cfg := gocd.Configuration{ Server: "https://my_gocd/go/", // don't forget the "/go/" at the end of the url to avoid issues! Username: "ApiUser", Password: "MySecretPassword", } c := cfg.Client() _, _, err := c.PipelineConfigs.Delete(context.Background(), "my_pipeline_name") if err != nil { panic(err) } }
Output:
func (*PipelineConfigsService) Get ¶
func (pcs *PipelineConfigsService) Get(ctx context.Context, name string) (p *Pipeline, resp *APIResponse, err error)
Get a single Pipeline object in the GoCD API.
Example ¶
package main import ( "context" "fmt" "github.com/beamly/go-gocd/gocd" ) func main() { // This example prints out the entire configuration of a pipeline cfg := gocd.Configuration{ Server: "https://my_gocd/go/", // don't forget the "/go/" at the end of the url to avoid issues! Username: "ApiUser", Password: "MySecretPassword", } c := cfg.Client() p, _, err := c.PipelineConfigs.Get(context.Background(), "my_pipeline_name") if err != nil { panic(err) } fmt.Printf("Pipeline configuration:\n") fmt.Printf(" - Name: %s\n", p.Name) fmt.Printf(" - Group: %s\n", p.Group) fmt.Printf(" - Label: %s\n", p.Label) fmt.Printf(" - Label template: %s\n", p.LabelTemplate) pLocking := "disabled" if p.EnablePipelineLocking { pLocking = "enabled" } fmt.Printf(" - Pipeline locking: %s\n", pLocking) fmt.Printf(" - Template: %s\n", p.Template) if p.Origin != nil { fmt.Printf(" - Origin (%s): %s", p.Origin.Type, p.Origin.File) } fmt.Printf(" - Parameters:\n") for _, item := range p.Parameters { fmt.Printf(" - %s: %s\n", item.Name, item.Value) } fmt.Printf(" - Environment variables:\n") for _, item := range p.EnvironmentVariables { fmt.Printf(" - %s: %s %s (%t)\n", item.Name, item.Value, item.EncryptedValue, item.Secure) } fmt.Printf(" - Materials:\n") for _, item := range p.Materials { fmt.Printf(" - Type: %s\n", item.Type) fmt.Printf(" Fingerprint: %s\n", item.Fingerprint) fmt.Printf(" Description: %s\n", item.Description) fmt.Printf(" Attributes:\n") m := item.Attributes.GenerateGeneric() for k, v := range m { fmt.Printf(" - %s: %#v\n", k, v) } } fmt.Printf(" - Stages:\n") for _, item := range p.Stages { fmt.Printf(" - Name: %s\n", item.Name) fmt.Printf(" FetchMaterials: %t\n", item.FetchMaterials) fmt.Printf(" CleanWorkingDirectory: %t\n", item.CleanWorkingDirectory) fmt.Printf(" NeverCleanupArtifacts: %t\n", item.NeverCleanupArtifacts) if item.Approval != nil { fmt.Printf(" Approval:\n Type: %s\n", item.Approval.Type) if item.Approval.Authorization != nil { fmt.Printf(" Users: %q\n", item.Approval.Authorization.Users) fmt.Printf(" Roles: %q\n", item.Approval.Authorization.Roles) } } fmt.Printf(" EnvironmentVariables:\n") for _, i := range item.EnvironmentVariables { fmt.Printf(" - %s: %s %s (%t)\n", i.Name, i.Value, i.EncryptedValue, i.Secure) } fmt.Printf(" Resources: %#v\n", item.Resources) fmt.Printf(" Jobs:\n") for _, i := range item.Jobs { fmt.Printf(" - %#v\n", i) } } fmt.Printf(" - Version: %s\n", p.Version) }
Output:
func (*PipelineConfigsService) Update ¶
func (pcs *PipelineConfigsService) Update(ctx context.Context, name string, p *Pipeline) (pr *Pipeline, resp *APIResponse, err error)
Update a pipeline configuration
type PipelineGroup ¶
PipelineGroup describes a pipeline group API response.
type PipelineGroups ¶
type PipelineGroups []*PipelineGroup
PipelineGroups represents a collection of pipeline groups
func (*PipelineGroups) GetGroupByPipeline ¶
func (pg *PipelineGroups) GetGroupByPipeline(pipeline *Pipeline) *PipelineGroup
GetGroupByPipeline finds the pipeline group for the pipeline supplied
func (*PipelineGroups) GetGroupByPipelineName ¶
func (pg *PipelineGroups) GetGroupByPipelineName(pipelineName string) *PipelineGroup
GetGroupByPipelineName finds the pipeline group for the name of the pipeline supplied
type PipelineGroupsService ¶
type PipelineGroupsService service
PipelineGroupsService describes the HAL _link resource for the api response object for a pipeline group response.
func (*PipelineGroupsService) List ¶
func (pgs *PipelineGroupsService) List(ctx context.Context, name string) (*PipelineGroups, *APIResponse, error)
List Pipeline groups
Example ¶
package main import ( "context" "fmt" "github.com/beamly/go-gocd/gocd" ) func main() { // This example list the pipeline names that belong to the group "foo" cfg := gocd.Configuration{ Server: "https://my_gocd/go/", // don't forget the "/go/" at the end of the url to avoid issues! Username: "ApiUser", Password: "MySecretPassword", } c := cfg.Client() groupName := "foo" // If you set your group name to an empty string you will get all the groups g, _, err := c.PipelineGroups.List(context.Background(), groupName) if err != nil { panic(err) } for _, grp := range *g { fmt.Printf("Pipelines in the %s group:\n", grp.Name) for _, elt := range grp.Pipelines { fmt.Printf(" - %s\n", elt.Name) } } }
Output:
type PipelineHistory ¶
type PipelineHistory struct {
Pipelines []*PipelineInstance `json:"pipelines"`
}
PipelineHistory describes the history of runs for a pipeline
type PipelineInstance ¶
type PipelineInstance struct { BuildCause BuildCause `json:"build_cause"` Label string `json:"label"` Counter int `json:"counter"` PreparingToSchedule bool `json:"preparing_to_schedule"` CanRun bool `json:"can_run"` Name string `json:"name"` NaturalOrder float32 `json:"natural_order"` Comment string `json:"comment"` Stages []*Stage `json:"stages"` }
PipelineInstance describes a single pipeline run codebeat:disable[TOO_MANY_IVARS]
type PipelineMaterial ¶
type PipelineMaterial struct { Name string `xml:"pipelineName,attr"` StageName string `xml:"stageName,attr"` MaterialName string `xml:"materialName,attr"` }
PipelineMaterial part of cruise-control.xml. @TODO better documentation
type PipelineRequest ¶
PipelineRequest describes a pipeline request object
type PipelineStatus ¶
type PipelineStatus struct { Locked bool `json:"locked"` Paused bool `json:"paused"` Schedulable bool `json:"schedulable"` }
PipelineStatus describes whether a pipeline can be run or scheduled.
type PipelineTemplate ¶
type PipelineTemplate struct { Links *HALLinks `json:"_links,omitempty"` Name string `json:"name"` Embedded *embeddedPipelineTemplate `json:"_embedded,omitempty"` Version string `json:"template_version"` Stages []*Stage `json:"stages,omitempty"` }
PipelineTemplate describes a response from the API for a pipeline template object.
func (*PipelineTemplate) AddStage ¶
func (pt *PipelineTemplate) AddStage(stage *Stage)
AddStage appends a stage to this pipeline
func (PipelineTemplate) GetName ¶
func (pt PipelineTemplate) GetName() string
GetName of the pipeline template
func (PipelineTemplate) GetStage ¶
func (pt PipelineTemplate) GetStage(stageName string) *Stage
GetStage from the pipeline template
func (PipelineTemplate) GetStages ¶
func (pt PipelineTemplate) GetStages() []*Stage
GetStages from the pipeline template
func (PipelineTemplate) GetVersion ¶
func (pt PipelineTemplate) GetVersion() (version string)
GetVersion retrieves a version string for this pipeline
func (PipelineTemplate) Pipelines ¶
func (pt PipelineTemplate) Pipelines() []*Pipeline
Pipelines returns a list of Pipelines attached to this PipelineTemplate object.
func (*PipelineTemplate) RemoveLinks ¶
func (pt *PipelineTemplate) RemoveLinks()
RemoveLinks gets the PipelineTemplate ready to be submitted to the GoCD API.
func (*PipelineTemplate) SetStage ¶
func (pt *PipelineTemplate) SetStage(newStage *Stage)
SetStage replaces a stage if it already exists
func (*PipelineTemplate) SetStages ¶
func (pt *PipelineTemplate) SetStages(stages []*Stage)
SetStages overwrites any existing stages
func (*PipelineTemplate) SetVersion ¶
func (pt *PipelineTemplate) SetVersion(version string)
SetVersion sets a version string for this pipeline
type PipelineTemplateRequest ¶
type PipelineTemplateRequest struct { Name string `json:"name"` Stages []*Stage `json:"stages"` Version string `json:"version"` }
PipelineTemplateRequest describes a PipelineTemplate
func (PipelineTemplateRequest) GetVersion ¶
func (pt PipelineTemplateRequest) GetVersion() (version string)
GetVersion retrieves a version string for this pipeline
func (*PipelineTemplateRequest) SetVersion ¶
func (pt *PipelineTemplateRequest) SetVersion(version string)
SetVersion sets a version string for this pipeline
type PipelineTemplateResponse ¶
type PipelineTemplateResponse struct { Name string `json:"name"` Embedded *struct { Pipelines []*struct { Name string `json:"name"` } } `json:"_embedded,omitempty"` }
PipelineTemplateResponse describes an api response for a single pipeline templates
type PipelineTemplatesResponse ¶
type PipelineTemplatesResponse struct { Links *HALLinks `json:"_links,omitempty"` Embedded *struct { Templates []*PipelineTemplate `json:"templates"` } `json:"_embedded,omitempty"` }
PipelineTemplatesResponse describes an api response for multiple pipeline templates
type PipelineTemplatesService ¶
type PipelineTemplatesService service
PipelineTemplatesService describes the HAL _link resource for the api response object for a pipeline configuration objects.
func (*PipelineTemplatesService) Create ¶
func (pts *PipelineTemplatesService) Create(ctx context.Context, name string, st []*Stage) (ptr *PipelineTemplate, resp *APIResponse, err error)
Create a new PipelineTemplate object in the GoCD API.
func (*PipelineTemplatesService) Delete ¶
func (pts *PipelineTemplatesService) Delete(ctx context.Context, name string) (string, *APIResponse, error)
Delete a PipelineTemplate from the GoCD API.
func (*PipelineTemplatesService) Get ¶
func (pts *PipelineTemplatesService) Get(ctx context.Context, name string) (pt *PipelineTemplate, resp *APIResponse, err error)
Get a single PipelineTemplate object in the GoCD API.
func (*PipelineTemplatesService) List ¶
func (pts *PipelineTemplatesService) List(ctx context.Context) (pt []*PipelineTemplate, resp *APIResponse, err error)
List all PipelineTemplate objects in the GoCD API.
func (*PipelineTemplatesService) Update ¶
func (pts *PipelineTemplatesService) Update(ctx context.Context, name string, template *PipelineTemplate) (ptr *PipelineTemplate, resp *APIResponse, err error)
Update an PipelineTemplate object in the GoCD API.
type PipelinesService ¶
type PipelinesService service
PipelinesService describes the HAL _link resource for the api response object for a pipelineconfig
func (*PipelinesService) GetHistory ¶
func (pgs *PipelinesService) GetHistory(ctx context.Context, name string, offset int) (pt *PipelineHistory, resp *APIResponse, err error)
GetHistory returns a list of pipeline instances describing the pipeline history.
func (*PipelinesService) GetInstance ¶
func (pgs *PipelinesService) GetInstance(ctx context.Context, name string, counter int) (pt *PipelineInstance, resp *APIResponse, err error)
GetInstance of a pipeline run.
func (*PipelinesService) GetStatus ¶
func (pgs *PipelinesService) GetStatus(ctx context.Context, name string, offset int) (ps *PipelineStatus, resp *APIResponse, err error)
GetStatus returns a list of pipeline instanves describing the pipeline history.
func (*PipelinesService) Pause ¶
func (pgs *PipelinesService) Pause(ctx context.Context, name string) (bool, *APIResponse, error)
Pause allows a pipeline to handle new build events
Example ¶
package main import ( "context" "github.com/beamly/go-gocd/gocd" ) func main() { // This example pauses the pipeline "my_pipeline_name" cfg := gocd.Configuration{ Server: "https://my_gocd/go/", // don't forget the "/go/" at the end of the url to avoid issues! Username: "ApiUser", Password: "MySecretPassword", } c := cfg.Client() _, _, err := c.Pipelines.Pause(context.Background(), "my_pipeline_name") if err != nil { panic(err) } }
Output:
func (*PipelinesService) ReleaseLock ¶
func (pgs *PipelinesService) ReleaseLock(ctx context.Context, name string) (bool, *APIResponse, error)
ReleaseLock frees a pipeline to handle new build events
func (*PipelinesService) Schedule ¶
func (pgs *PipelinesService) Schedule(ctx context.Context, name string, body *ScheduleRequestBody) (bool, *APIResponse, error)
Schedule allows to trigger a specific pipeline.
func (*PipelinesService) Unpause ¶
func (pgs *PipelinesService) Unpause(ctx context.Context, name string) (bool, *APIResponse, error)
Unpause allows a pipeline to handle new build events
Example ¶
package main import ( "context" "github.com/beamly/go-gocd/gocd" ) func main() { // This example unpauses the pipeline "my_pipeline_name" cfg := gocd.Configuration{ Server: "https://my_gocd/go/", // don't forget the "/go/" at the end of the url to avoid issues! Username: "ApiUser", Password: "MySecretPassword", } c := cfg.Client() _, _, err := c.Pipelines.Unpause(context.Background(), "my_pipeline_name") if err != nil { panic(err) } }
Output:
type PluggableInstanceSettings ¶
type PluggableInstanceSettings struct { Configurations []PluginConfiguration `json:"configurations"` View PluginView `json:"view"` }
PluggableInstanceSettings describes plugin configuration.
type Plugin ¶
type Plugin struct { Links *HALLinks `json:"_links"` ID string `json:"id"` Name string `json:"name,omitempty"` // Name is available for the plugin API v1 and v2 only (GoCD >= 16.7.0 to < 17.9.0). DisplayName string `json:"display_name,omitempty"` // DisplayName is available for the plugin API v1 and v2 only (GoCD >= 16.7.0 to < 17.9.0). Version string `json:"version,omitempty"` // Version is available for the plugin API v1 and v2 only (GoCD >= 16.7.0 to < 17.9.0). Type string `json:"type,omitempty"` // Type is available for the plugin API v1, v2 and v3 only (GoCD >= 16.7.0 to < 18.3.0). Can be one of `authentication`, `notification`, `package-repository`, `task`, `scm`. PluggableInstanceSettings PluggableInstanceSettings `json:"pluggable_instance_settings,omitempty"` // PluggableInstanceSettings is available for the plugin API v1 and v2 only (GoCD >= 16.7.0 to < 17.9.0). Image PluginIcon `json:"image,omitempty"` // Image is available for the plugin API v2 only (GoCD >= 16.12.0 to < 17.9.0). Status PluginStatus `json:"status,omitempty"` // Status is available for the plugin API v3 and v4 (GoCD >= 17.9.0). PluginFileLocation string `json:"plugin_file_location,omitempty"` // PluginFileLocation is available for the plugin API v3 and v4 (GoCD >= 17.9.0). BundledPlugin bool `json:"bundled_plugin,omitempty"` // BundledPlugin is available for the plugin API v3 and v4 (GoCD >= 17.9.0). About PluginAbout `json:"about,omitempty"` // About is available for the plugin API v3 and v4 (GoCD >= 17.9.0). ExtensionInfo *PluginExtensionInfo `json:"extension_info,omitempty"` // ExtensionInfo is available for the plugin API v3 only (GoCD >= 17.9.0 to < 18.3.0). Extensions []*PluginExtension `json:"extensions,omitempty"` //Extensions is available for the plugin API v4 (GoCD >= 18.3.0). }
Plugin describes a single plugin resource. codebeat:disable[TOO_MANY_IVARS]
type PluginAbout ¶
type PluginAbout struct { Name string `json:"name"` Version string `json:"version,omitempty"` TargetGoVersion string `json:"target_go_version,omitempty"` Description string `json:"description,omitempty"` TargetOperatingSystems []string `json:"target_operating_systems,omitempty"` Vendor PluginVendor `json:"vendor,omitempty"` }
PluginAbout provides additional details about the plugin.
type PluginConfiguration ¶
type PluginConfiguration struct { Key string `json:"key"` Metadata PluginConfigurationMetadata `json:"metadata"` }
PluginConfiguration describes the configuration related to a plugin extension.
type PluginConfigurationKVPair ¶
PluginConfigurationKVPair describes a key/value pair of plugin configurations.
type PluginExtension ¶
type PluginExtension struct { Type string `json:"type,omitempty"` PluginSettings ExtensionSettings `json:"plugin_settings,omitempty"` ProfileSettings ExtensionSettings `json:"profile_settings,omitempty"` Capabilities ExtensionCapabilities `json:"capabilities,omitempty"` AuthConfigSettings ExtensionSettings `json:"auth_config_settings,omitempty"` RoleSettings ExtensionSettings `json:"role_settings,omitempty"` DisplayName string `json:"display_name,omitempty"` ScmSettings ExtensionSettings `json:"scm_settings,omitempty"` TaskSettings ExtensionSettings `json:"task_settings,omitempty"` PackageSettings ExtensionSettings `json:"package_settings,omitempty"` RepositorySettings ExtensionSettings `json:"repository_settings,omitempty"` }
PluginExtension describes the different extensions available for a plugin. It is used for the plugin API v4 (GoCD >= 18.3.0). codebeat:disable[TOO_MANY_IVARS]
type PluginExtensionInfo ¶
type PluginExtensionInfo struct { PluginSettings PluggableInstanceSettings `json:"plugin_settings,omitempty"` ProfileSettings PluggableInstanceSettings `json:"profile_settings,omitempty"` Capabilities ExtensionCapabilities `json:"capabilities,omitempty"` AuthConfigSettings PluggableInstanceSettings `json:"auth_config_settings,omitempty"` RoleSettings PluggableInstanceSettings `json:"role_settings,omitempty"` DisplayName string `json:"display_name,omitempty"` ScmSettings PluggableInstanceSettings `json:"scm_settings,omitempty"` TaskSettings PluggableInstanceSettings `json:"task_settings,omitempty"` PackageSettings PluggableInstanceSettings `json:"package_settings,omitempty"` RepositorySettings PluggableInstanceSettings `json:"repository_settings,omitempty"` DisplayImageURL string `json:"display_image_url,omitempty"` SupportPasswordBasedAuthentication bool `json:"supports_password_based_authentication"` SupportWebBasedAuthentication bool `json:"supports_web_based_authentication"` }
PluginExtensionInfo describes the extension info for the plugin API v3 only (GoCD >= 17.9.0 to < 18.3.0). codebeat:disable[TOO_MANY_IVARS]
type PluginIcon ¶
PluginIcon describes the content type of the plugin icon and the base-64 encoded byte array of the byte-sequence that composes the image. It is used for the plugin API v2 only (GoCD >= 16.12.0 to < 17.9.0).
type PluginStatus ¶
type PluginStatus struct { // State can be one of `active`, `invalid`. State string `json:"state"` Messages []string `json:"messages,omitempty"` }
PluginStatus describes the status of a plugin.
type PluginVendor ¶
PluginVendor describes the author of a plugin.
type PluginView ¶
type PluginView struct {
Template string `json:"template"`
}
PluginView describes any view attached to a plugin.
type PluginsResponse ¶
type PluginsResponse struct { Links *HALLinks `json:"_links"` Embedded struct { PluginInfo []*Plugin `json:"plugin_info"` } `json:"_embedded"` }
PluginsResponse describes the response obejct for a plugin API call.
type PluginsService ¶
type PluginsService service
PluginsService exposes calls for interacting with Plugin objects in the GoCD API.
func (*PluginsService) Get ¶
func (ps *PluginsService) Get(ctx context.Context, name string) (p *Plugin, resp *APIResponse, err error)
Get retrieves information about a specific plugin.
func (*PluginsService) List ¶
func (ps *PluginsService) List(ctx context.Context) (*PluginsResponse, *APIResponse, error)
List retrieves all plugins
type Properties ¶
type Properties struct { UnmarshallWithHeader bool IsDatum bool Header []string DataFrame [][]string }
Properties describes a properties resource in the GoCD API.
func NewPropertiesFrame ¶
func NewPropertiesFrame(frame [][]string) *Properties
NewPropertiesFrame generate a new data frame for properties on a gocd job.
func (*Properties) AddRow ¶
func (pr *Properties) AddRow(r []string)
AddRow to an existing properties data frame
func (Properties) Get ¶
func (pr Properties) Get(row int, column string) string
Get a single parameter value for a given run of the job.
func (*Properties) MarshalJSON ¶
func (pr *Properties) MarshalJSON() ([]byte, error)
MarshalJSON converts the properties structure to a list of maps
func (Properties) MarshallCSV ¶
func (pr Properties) MarshallCSV() (string, error)
MarshallCSV returns the data frame as a string
func (*Properties) SetRow ¶
func (pr *Properties) SetRow(row int, r []string)
SetRow in an existing data frame
func (*Properties) UnmarshallCSV ¶
func (pr *Properties) UnmarshallCSV(raw string) error
UnmarshallCSV returns the data frame from a string
type PropertiesService ¶
type PropertiesService service
PropertiesService describes Actions which can be performed on agents
func (*PropertiesService) Create ¶
func (ps *PropertiesService) Create(ctx context.Context, name string, value string, pr *PropertyRequest) (responseIsValid bool, resp *APIResponse, err error)
Create a specific property for the given job/pipeline/stage run.
func (*PropertiesService) Get ¶
func (ps *PropertiesService) Get(ctx context.Context, name string, pr *PropertyRequest) (*Properties, *APIResponse, error)
Get a specific property for the given job/pipeline/stage run.
func (*PropertiesService) List ¶
func (ps *PropertiesService) List(ctx context.Context, pr *PropertyRequest) (*Properties, *APIResponse, error)
List the properties for the given job/pipeline/stage run.
func (*PropertiesService) ListHistorical ¶
func (ps *PropertiesService) ListHistorical(ctx context.Context, pr *PropertyRequest) (*Properties, *APIResponse, error)
ListHistorical properties for a given pipeline, stage, job.
type PropertyCreateResponse ¶
PropertyCreateResponse handles the parsing of the response when creating a property
type PropertyRequest ¶
type PropertyRequest struct { Pipeline string PipelineCounter int Stage string StageCounter int Job string LimitPipeline string Limit int Single bool }
PropertyRequest describes the parameters to be submitted when calling/creating properties. codebeat:disable[TOO_MANY_IVARS]
type Role ¶
type Role struct { Name string `json:"name"` Type string `json:"type"` Attributes *RoleAttributesGoCD `json:"attributes"` Version string `json:"version"` Links *HALLinks `json:"_links,omitempty"` }
Role represents a type of agent/actor who can access resources perform operations
func (Role) GetVersion ¶
GetVersion retrieves a version string for this role
func (*Role) RemoveLinks ¶
func (r *Role) RemoveLinks()
RemoveLinks from the pipeline object for json marshalling.
func (*Role) SetVersion ¶
SetVersion sets a version string for this role
type RoleAttributeProperties ¶
RoleAttributeProperties describes properties attached to a role
type RoleAttributesGoCD ¶
type RoleAttributesGoCD struct { Users []string `json:"users,omitempty"` AuthConfigID *string `json:"auth_config_id,omitempty"` Properties []*RoleAttributeProperties `json:"properties,omitempty"` }
RoleAttributesGoCD are attributes describing a role, in this cae, which users are present in the role.
type RoleListWrapper ¶
type RoleListWrapper struct { Embedded struct { Roles []*Role `json:"roles"` } `json:"_embedded"` }
RoleListWrapper describes a container for the result of a role list operation
type RoleService ¶
type RoleService service
RoleService describes Actions which can be performed on roles
func (*RoleService) Create ¶
func (rs *RoleService) Create(ctx context.Context, role *Role) (r *Role, resp *APIResponse, err error)
Create a role
func (*RoleService) Delete ¶
func (rs *RoleService) Delete(ctx context.Context, roleName string) (result string, resp *APIResponse, err error)
Delete a role by name
func (*RoleService) Get ¶
func (rs *RoleService) Get(ctx context.Context, roleName string) (r *Role, resp *APIResponse, err error)
Get a single role by name
func (*RoleService) List ¶
func (rs *RoleService) List(ctx context.Context) (r []*Role, resp *APIResponse, err error)
List all roles
func (*RoleService) Update ¶
func (rs *RoleService) Update(ctx context.Context, roleName string, role *Role) ( r *Role, resp *APIResponse, err error)
Update a role by name
type ScheduleMaterial ¶
type ScheduleMaterial struct { Name string `json:"name,omitempty"` // Name is used to build a post query for GoCD version < 18.2.0 Fingerprint string `json:"fingerprint"` Revision string `json:"revision"` }
ScheduleMaterial describes a material that must be used to trigger a new instance of the pipeline.
type ScheduleRequestBody ¶
type ScheduleRequestBody struct { EnvironmentVariables []*EnvironmentVariable `json:"environment_variables,omitempty"` Materials []*ScheduleMaterial `json:"materials,omitempty"` UpdateMaterialsBeforeScheduling bool `json:"update_materials_before_scheduling"` }
ScheduleRequestBody describes properties to trigger a new instance of the pipeline.
type ServerVersion ¶
type ServerVersion struct { Version string `json:"version"` VersionParts *version.Version BuildNumber string `json:"build_number"` GitSha string `json:"git_sha"` FullVersion string `json:"full_version"` CommitURL string `json:"commit_url"` }
ServerVersion of the GoCD installation
func (*ServerVersion) Equal ¶
func (sv *ServerVersion) Equal(v *ServerVersion) bool
Equal if the two versions are identical
func (*ServerVersion) GetAPIVersion ¶
func (sv *ServerVersion) GetAPIVersion(endpoint string) (apiVersion string, err error)
GetAPIVersion for a given endpoint and method
func (*ServerVersion) LessThan ¶
func (sv *ServerVersion) LessThan(v *ServerVersion) bool
LessThan compares this server version and determines if it is older than the provided server version
type ServerVersionService ¶
type ServerVersionService service
ServerVersionService exposes calls for interacting with ServerVersion objects in the GoCD API.
func (*ServerVersionService) Get ¶
func (svs *ServerVersionService) Get(ctx context.Context) (v *ServerVersion, resp *APIResponse, err error)
Get retrieves information about a specific plugin.
type Stage ¶
type Stage struct { Name string `json:"name"` FetchMaterials bool `json:"fetch_materials"` CleanWorkingDirectory bool `json:"clean_working_directory"` NeverCleanupArtifacts bool `json:"never_cleanup_artifacts"` Approval *Approval `json:"approval,omitempty"` EnvironmentVariables []*EnvironmentVariable `json:"environment_variables,omitempty"` Resources []string `json:"resource,omitempty"` Jobs []*Job `json:"jobs,omitempty"` }
Stage represents a GoCD Stage object. codebeat:disable[TOO_MANY_IVARS]
func (*Stage) JSONString ¶
JSONString returns a string of this stage as a JSON object.
type StageContainer ¶
type StageContainer interface { GetName() string SetStage(stage *Stage) GetStage(string) *Stage SetStages(stages []*Stage) GetStages() []*Stage AddStage(stage *Stage) Versioned }
StageContainer describes structs which contain stages, eg Pipelines and PipelineTemplates
type StageInstance ¶
type StageInstance struct { Name string `json:"name"` ID int `json:"id"` Jobs []*Job `json:"jobs,omitempty"` CanRun bool `json:"can_run"` Scheduled bool `json:"scheduled"` ApprovalType string `json:"approval_type,omitempty"` ApprovedBy string `json:"approved_by,omitempty"` Counter string `json:"counter,omitempty"` OperatePermission bool `json:"operate_permission,omitempty"` Result string `json:"result,omitempty"` RerunOfCounter *int `json:"rerun_of_counter,omitempty"` }
StageInstance represents the stage from the result from a pipeline run codebeat:disable[TOO_MANY_IVARS]
func (*StageInstance) JSONString ¶
func (s *StageInstance) JSONString() (string, error)
JSONString returns a string of this stage as a JSON object.
func (*StageInstance) Validate ¶
func (s *StageInstance) Validate() error
Validate ensures the attributes attached to this structure are ready for submission to the GoCD API.
type StagesService ¶
type StagesService service
StagesService exposes calls for interacting with Stage objects in the GoCD API.
type StringResponse ¶
type StringResponse struct {
Message string `json:"message"`
}
StringResponse handles the unmarshaling of the single string response from DELETE requests.
type Task ¶
type Task struct { Type string `json:"type"` Attributes TaskAttributes `json:"attributes"` }
Task Describes a Task object in the GoCD api.
type TaskAttributes ¶
type TaskAttributes struct { RunIf []string `json:"run_if,omitempty"` Command string `json:"command,omitempty"` WorkingDirectory string `json:"working_directory,omitempty"` Arguments []string `json:"arguments,omitempty"` BuildFile string `json:"build_file,omitempty"` Target string `json:"target,omitempty"` NantPath string `json:"nant_path,omitempty"` Pipeline string `json:"pipeline,omitempty"` Stage string `json:"stage,omitempty"` Job string `json:"job,omitempty"` Source string `json:"source,omitempty"` IsSourceAFile bool `json:"is_source_a_file,omitempty"` Destination string `json:"destination,omitempty"` PluginConfiguration *TaskPluginConfiguration `json:"plugin_configuration,omitempty"` Configuration []PluginConfigurationKVPair `json:"configuration,omitempty"` ArtifactOrigin string `json:"artifact_origin,omitempty"` }
TaskAttributes describes all the properties for a Task. codebeat:disable[TOO_MANY_IVARS]
func (*TaskAttributes) ValidateAnt ¶
func (t *TaskAttributes) ValidateAnt() error
ValidateAnt checks that the specified values for the Task struct are correct for a an Ant task
func (*TaskAttributes) ValidateExec ¶
func (t *TaskAttributes) ValidateExec() error
ValidateExec checks that the specified values for the Task struct are correct for a cli exec task
type TaskPluginConfiguration ¶
TaskPluginConfiguration is for specifying options for pluggable task
type TimeoutField ¶
type TimeoutField int
TimeoutField helps manage the marshalling of the timoeut field which can be both "never" and an integer
func (TimeoutField) MarshalJSON ¶
func (tf TimeoutField) MarshalJSON() (b []byte, err error)
MarshalJSON of TimeoutField into a string
func (*TimeoutField) UnmarshalJSON ¶
func (tf *TimeoutField) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON and handle "never", "null", and integers.
type Timer ¶
type Timer struct { Spec string `json:"spec,omitempty"` OnlyOnChanges bool `json:"only_on_changes,omitempty"` }
Timer describes the cron-like schedule to build a pipeline
type TrackingTool ¶
type TrackingTool struct { Type string `json:"type,omitempty"` Attributes TrackingToolAttributes `json:"attributes,omitempty"` }
TrackingTool describes the type of a tracking tool and its attributes
type TrackingToolAttributes ¶
type TrackingToolAttributes struct { URLPattern string `json:"url_pattern,omitempty"` Regex string `json:"regex,omitempty"` BaseURL string `json:"base_url,omitempty"` ProjectIdentifier string `json:"project_identifier,omitempty"` MqlGroupingConditions string `json:"mql_grouping_conditions,omitempty"` }
TrackingToolAttributes describes the attributes of a tracking tool
type Version ¶
type Version struct { Links *HALLinks `json:"_links"` Version string `json:"version"` BuildNumber string `json:"build_number"` GitSHA string `json:"git_sha"` FullVersion string `json:"full_version"` CommitURL string `json:"commit_url"` }
Version part of cruise-control.xml. @TODO better documentation
Source Files ¶
- agent.go
- approval.go
- authentication.go
- config.go
- config_repo.go
- configuration.go
- configuration_task.go
- doc.go
- encryption.go
- environment.go
- genericactions.go
- gocd.go
- jobs.go
- jobs_validation.go
- links.go
- logging.go
- pipeline.go
- pipeline_material.go
- pipelineconfig.go
- pipelinegroups.go
- pipelinetemplate.go
- plugin.go
- properties.go
- resource.go
- resource_agent.go
- resource_config_repo.go
- resource_environment.go
- resource_jobs.go
- resource_pipeline.go
- resource_pipeline_material.go
- resource_pipeline_material_dependency.go
- resource_pipeline_material_git.go
- resource_pipeline_material_hg.go
- resource_pipeline_material_p4.go
- resource_pipeline_material_pkg.go
- resource_pipeline_material_plugin.go
- resource_pipeline_material_svn.go
- resource_pipeline_material_tfs.go
- resource_pipelinegroups.go
- resource_pipelinetemplate.go
- resource_properties.go
- resource_role.go
- resource_server_version.go
- resource_stage_instance.go
- resource_stages.go
- resource_task.go
- role.go
- server_version.go
- stage_instance.go
- stages.go