gocd

package module
v0.0.0-...-9d3ee0a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2017 License: MIT Imports: 9 Imported by: 2

README

GoCD Client

Go Lang library to access GoCD API

Usage

package main

import (
  "github.com/mhanygin/go-gocd"
)

func main() {
  client := gocd.New("http://gocd.com:8153", "login", "password")
  // ... do whatever you want with the client
}

## API Endpoints Pending
- Agents
  - [x] Get all Agents
  - [x] Get one Agent
  - [x] Update an Agent
  - [x] Delete an Agent
  - [ ] Agent job run history
- Users
  - [x] Get all Users
  - [x] Get one user
  - [x] Create a user
  - [x] Update a user
  - [x] Delete a user
- Materials
  - [ ] Get all Materials
  - [ ] Get material modifications
  - [ ] Notify SVN materials
  - [ ] Notify git materials
- Backups
  - [ ] Create a backup
- Pipeline Group
  - [x] Config listing
- Artifacts
  - [ ] Get all Artifacts
  - [ ] Get artifact file
  - [ ] Get artifact directory
  - [ ] Create artifact
  - [ ] Append to artifact
- Pipelines
  - [x] Get pipeline instance
  - [ ] Get pipeline status
  - [x] Pause a pipeline
  - [x] Unpause a pipeline
  - [ ] Releasing a pipeline lock
  - [x] Scheduling Pipelines
- Stages
  - [x] Cancel Stage
  - [x] Get Stage instance
  - [x] Get stage history
- Jobs
  - [ ] Get Scheduled Jobs
  - [ ] Get Job history
- Properties
  - [ ] Get all job Properties
  - [ ] Get one property
  - [ ] Get historical properties
  - [ ] Create property
- Configurations
  - [ ] List all modifications
  - [ ] Get repository modification diff
  - [ ] Get Configuration  
- Environment Config
  - [x] Get all environments
  - [x] Get environment config
  - [x] Create an environment
  - [x] Update an environment
  - [x] Delete an environment
- [ ] Dashboard
  - [ ] Get Dashboard
- Pipeline Config
  - [x] Get pipeline Configuration
  - [x] Edit Pipeline configuration
  - [x] Create Pipeline
  - [x] Delete Pipeline

Documentation

Index

Constants

View Source
const VERSION = "0.1.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Uuid            string `json:"uuid"`
	HostName        string `json:"hostname"`
	IpAddress       string `json:"ip_address"`
	Sandbox         string `json:"sandbox"`
	OperatingSystem string `json:"operating_system"`
	//FreeSpace        int   `json:"free_space,omitempty"`
	AgentConfigState string   `json:"agent_config_state"`
	AgentState       string   `json:"agent_state"`
	BuildState       string   `json:"build_state"`
	Resources        []string `json:"resources"`
	Environments     []string `json:"environments"`
}

func NewAgent

func NewAgent() *Agent

func (Agent) Diff

func (p Agent) Diff(agent Agent) map[string]interface{}

type BuildCause

type BuildCause struct {
	Approver          string             `json:"approver, omitempty"`
	MaterialRevisions []MaterialRevision `json:"material_revisions,omitempty"`
	TriggerForced     bool               `json:"trigger_forced,omitempty"`
	TriggerMessage    string             `json:"trigger_message,omitempty"`
}

type Client

type Client struct {
	Etag    string
	EtagEnv string
	// contains filtered or unexported fields
}

func New

func New(host, login, password string) *Client

func (*Client) DeleteAgent

func (p *Client) DeleteAgent(uuid string) error

func (*Client) DeleteEnvironment

func (p *Client) DeleteEnvironment(name string) error

func (*Client) DeletePipelineConfig

func (p *Client) DeletePipelineConfig(name string) error

func (*Client) DeleteUser

func (p *Client) DeleteUser(login string) error

func (*Client) FindPipelineConfig

func (p *Client) FindPipelineConfig(name string) (*PipelineConfig, *Environment, error)

func (*Client) GetAgent

func (p *Client) GetAgent(uuid string) (*Agent, error)

func (*Client) GetAllAgents

func (p *Client) GetAllAgents() ([]*Agent, error)

func (*Client) GetAllUsers

func (p *Client) GetAllUsers() ([]*User, error)

func (*Client) GetEnvironment

func (p *Client) GetEnvironment(name string) (*Environment, error)

func (*Client) GetEnvironments

func (p *Client) GetEnvironments() (*Environments, error)

func (*Client) GetGroups

func (p *Client) GetGroups() (*[]*Group, error)

func (*Client) GetHistoryPipelineInstance

func (p *Client) GetHistoryPipelineInstance(name string) ([]*PipelineInstance, error)

func (*Client) GetPipelineConfig

func (p *Client) GetPipelineConfig(name string) (*PipelineConfig, error)

func (*Client) GetPipelineInstance

func (p *Client) GetPipelineInstance(name string, inst int) (*PipelineInstance, error)

func (*Client) GetStageInstance

func (p *Client) GetStageInstance(pipeline string, pInst int, stage string, sInst int) (*Stage, error)

func (*Client) GetStageInstanceHystory

func (p *Client) GetStageInstanceHystory(pipeline string, stage string) ([]*Stage, error)

func (*Client) GetUser

func (p *Client) GetUser(login string) (*User, error)

func (*Client) NewEnvironment

func (p *Client) NewEnvironment(env *Environment) error

func (*Client) NewPipelineConfig

func (p *Client) NewPipelineConfig(pipeline *PipelineConfig, group string) error

func (*Client) NewPipelineConfigRaw

func (p *Client) NewPipelineConfigRaw(data []byte) error

func (*Client) NewUser

func (p *Client) NewUser(user *User) error

func (*Client) PausePipeline

func (p *Client) PausePipeline(name string) error

func (*Client) SchedulePipeline

func (p *Client) SchedulePipeline(name string, data []byte) error

func (*Client) SetAgent

func (p *Client) SetAgent(agent Agent) error

func (*Client) SetEnvironment

func (p *Client) SetEnvironment(env *Environment) error

func (*Client) SetPipelineConfig

func (p *Client) SetPipelineConfig(pipeline *PipelineConfig) error

func (*Client) SetPipelineConfigRaw

func (p *Client) SetPipelineConfigRaw(name string, data []byte) error

func (*Client) SetUser

func (p *Client) SetUser(user *User) error

func (*Client) StageCancel

func (p *Client) StageCancel(pipeline string, stage string) error

func (*Client) UnpausePipeline

func (p *Client) UnpausePipeline(name string) error

func (*Client) Version

func (p *Client) Version() (*Version, error)

type Environment

type Environment struct {
	Links                Links                    `json:"_links"`
	Name                 string                   `json:"name"`
	Agents               []ShortAgent             `json:"agents"`
	EnvironmentVariables []map[string]interface{} `json:"environment_variables"`
	Pipelines            []ShortPipeline          `json:"pipelines"`
}

func NewEnvironment

func NewEnvironment() *Environment

func (*Environment) AddEnvironmentVariables

func (p *Environment) AddEnvironmentVariables(env *EnvironmentVariable) error

func (*Environment) AddPipeline

func (p *Environment) AddPipeline(pipeline string) error

func (*Environment) DeleteEnvironmentVariables

func (p *Environment) DeleteEnvironmentVariables(name string) error

func (*Environment) DeletePipeline

func (p *Environment) DeletePipeline(pipeline string) error

func (*Environment) ExistPipeline

func (p *Environment) ExistPipeline(pipeline string) bool

func (*Environment) GetEnvironmentVariables

func (p *Environment) GetEnvironmentVariables(name string) (*EnvironmentVariable, error)

type EnvironmentVariable

type EnvironmentVariable struct {
	Secure bool
	Crypt  bool
	Name   string
	Value  string
}

type Environments

type Environments struct {
	Links   Links `json:"_links"`
	Embeded struct {
		Environments []Environment `json:"environments"`
	} `json:"_embedded"`
}

func NewEnvironments

func NewEnvironments() *Environments

type Group

type Group struct {
	Name      string `json:"name"`
	Pipelines []struct {
		Name string `json:"name"`
	} `json:"pipelines"`
}

func (*Group) Exist

func (p *Group) Exist(pipeline string) bool

type Job

type Job struct {
	AgentUUID           string                `json:"agent_uuid,omitempty"`
	Name                string                `json:"name,omitempty"`
	JobStateTransitions []JobStateTransitions `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"`
}

type JobConfig

type JobConfig struct {
	Name                 string                   `json:"name"`
	RunInstanceCount     int                      `json:"run_instance_count"`
	Timeout              int                      `json:"timeout"`
	EnvironmentVariables []map[string]interface{} `json:"environment_variables"`
	Resources            []string                 `json:"resources"`
	Tasks                []map[string]interface{} `json:"tasks"`
}

func (*JobConfig) AddTask

func (p *JobConfig) AddTask(task interface{}) error

type JobStateTransitions

type JobStateTransitions struct {
	StateChangeTime int    `json:"state_change_time,omitempty"`
	ID              int    `json:"id,omitempty"`
	State           string `json:"state,omitempty"`
}
type Link struct {
	HRef string `json:"href"`
}
type Links struct {
	Self Link `json:"self"`
	Doc  Link `json:"doc"`
	Find Link `json:"find"`
}

type Material

type Material struct {
	Description string `json:"description,omitempty"`
	Fingerprint string `json:"fingerprint,omitempty"`
	Type        string `json:"type,omitempty"`
	ID          int    `json:"id,omitempty"`
}

type MaterialGitConfig

type MaterialGitConfig struct {
	Type       string `json:"type"`
	Attributes struct {
		Name        string `json:"name"`
		URL         string `json:"url"`
		Branch      string `json:"branch"`
		Destination string `json:"destination"`
		AutoUpdate  bool   `json:"auto_update"`
		Filter      struct {
			Ignore []string `json:"ignore"`
		} `json:"filter"`
		InvertFilter    bool   `json:"invert_filter"`
		SubmoduleFolder string `json:"submodule_folder"`
		ShallowClone    bool   `json:"shallow_clone"`
	} `json:"attributes"`
}

type MaterialRevision

type MaterialRevision struct {
	Modifications []Modification `json:"modifications,omitempty"`
	Material      Material       `json:"material,omitempty"`
	Changed       bool           `json:"changed,omitempty"`
}

type Modification

type Modification struct {
	EmailAddress string `json:"email_address,omitempty"`
	ID           int    `json:"id,omitempty"`
	ModifiedTime int    `json:"modified_time,omitempty"`
	UserName     string `json:"user_name,omitempty"`
	Comment      string `json:"comment,omitempty"`
	Revision     string `json:"revision,omitempty"`
}

type PipelineConfig

type PipelineConfig struct {
	LabelTemplate         string                   `json:"label_template,omitempty"`
	EnablePipelineLocking bool                     `json:"enable_pipeline_locking"`
	Name                  string                   `json:"name"`
	Template              string                   `json:"template"`
	Params                []map[string]string      `json:"parameters"`
	EnvironmentVariables  []map[string]interface{} `json:"environment_variables"`
	Materials             []MaterialGitConfig      `json:"materials"`
	Stages                []StageConfig            `json:"stages"`
}

func NewPipelineConfig

func NewPipelineConfig() *PipelineConfig

type PipelineInstance

type PipelineInstance struct {
	Name         string     `json:"name,omitempty"`
	NaturalOrder float64    `json:"natural_order,omitempty"`
	CanRun       bool       `json:"can_run,omitempty"`
	Comment      string     `json:"comment,omitempty"`
	Stages       []Stage    `json:"stages,omitempty"`
	Counter      int        `json:"counter,omitempty"`
	ID           int        `json:"id,omitempty"`
	Label        string     `json:"label,omitempty"`
	BuildCause   BuildCause `json:"build_cause,omitempty"`
}

func NewPipelineInstance

func NewPipelineInstance() *PipelineInstance

type ShortAgent

type ShortAgent struct {
	Links Links  `json:"_links"`
	Uuid  string `json:"uuid"`
}

type ShortPipeline

type ShortPipeline struct {
	Links Links  `json:"_links"`
	Name  string `json:"name"`
}

type Stage

type Stage struct {
	Name                  string `json:"name,omitempty"`
	CleanWorkingDirectory bool   `json:"clean_working_directory,omitempty"`
	ApprovedBy            string `json:"approved_by,omitempty"`
	Jobs                  []Job  `json:"jobs,omitempty"`
	PipelineCounter       int    `json:"pipeline_counter,omitempty"`
	PipelineName          string `json:"pipeline_name,omitempty"`
	ApprovalType          string `json:"approval_type,omitempty"`
	Result                string `json:"result,omitempty"`
	Counter               int    `json:"counter,omitempty"`
	ID                    int    `json:"id,omitempty"`
	RerunOfCounter        int    `json:"rerun_of_counter,omitempty"`
	FetchMaterials        bool   `json:"fetch_materials,omitempty"`
	ArtifactsDeleted      bool   `json:"artifacts_deleted,omitempty"`
}

func NewStage

func NewStage() *Stage

type StageConfig

type StageConfig struct {
	Name                  string `json:"name"`
	FetchMaterials        bool   `json:"fetch_materials"`
	CleanWorkingDirectory bool   `json:"clean_working_directory"`
	NeverCleanupArtifacts bool   `json:"never_cleanup_artifacts"`
	Approval              struct {
		Type          string `json:"type"`
		Authorization struct {
			Roles []string `json:"roles"`
			Users []string `json:"users"`
		} `json:"authorization"`
	} `json:"approval"`
	EnvironmentVariables []EnvironmentVariable `json:"environment_variables"`
	Jobs                 []JobConfig           `json:"jobs"`
}

type TaskAntConfig

type TaskAntConfig struct {
	Type string `json:"type"`
	// contains filtered or unexported fields
}

func NewTaskAntConfig

func NewTaskAntConfig() *TaskAntConfig

type TaskExecConfig

type TaskExecConfig struct {
	Type string
	// contains filtered or unexported fields
}

func NewTaskExecConfig

func NewTaskExecConfig() *TaskExecConfig

type TaskNantConfig

type TaskNantConfig struct {
	Type string `json:"type"`
	// contains filtered or unexported fields
}

func NewTaskNantConfig

func NewTaskNantConfig() *TaskNantConfig

type User

type User struct {
	LoginName      string   `json:"login_name"`
	DisplayName    string   `json:"display_name"`
	Enabled        bool     `json:"enabled"`
	Email          string   `json:"email"`
	EmailMe        bool     `json:"email_me"`
	CheckinAliases []string `json:"checkin_aliases"`
}

func NewUser

func NewUser() *User

func (User) Diff

func (p User) Diff(user *User) map[string]interface{}

type Value

type Value struct {
	Value string `json:"value"`
}

type Version

type Version struct {
	ClientVersion string
	Links         struct {
		Self Link `json:"self"`
		Doc  Link `json:"doc"`
	} `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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL