resource

package module
v0.9.3-0...-be2e0e5 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: MIT Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GitHub Deployment Resource

Fetches and creates GitHub Deployments and Deployment Statuses. For more about Github Deployments see the API documentation.

Source Configuration

  • user: Required. The GitHub username or organization name for the repository that you are deploying.

  • repository: Required. The repository name that you are deploying.

  • access_token: Required. Used for accessing deployment data and creating deployments and deployment statuses.

  • github_api_url: Optional. If you use a non-public GitHub deployment then you can set your API URL here.

  • environments: Optional. A list of environments to get versions for.

Example
resource_types:
  - name: github-deployment
    type: docker-image
    source:
      repository: andyhume/github-deployment-resource
      tag: "v0.8.0"
      
resources:
  - name: deployment
    type: github-deployment
    source:
      user: BrandwatchLtd
      repository: analytics
      access_token: abcdef1234567890
- get: deployment
- put: deployment
  params:
    id:
      file: deployment/id # path to a file containing the deployment ID
    state: success

Behavior

check: Check for Deployments

/check always returns the single latest deployment. It assumes that any preceding deployments are invalidated by the existence of a later deployment.

in: Fetch Deployment

Fetches the latest deployment and creates the following files:

  • id containing the id of the deployment being fetched.
  • ref containting the name of the ref the deployment is relating to. A branch, tag, or SHA.
  • sha containg the SHA that was recorded at deployment creation time.
  • task containing the name of the task for the deployment.
  • environment containing the name of the environment that is being deployed to.
  • description containing the description of the deployment
  • deploymentJSON containing the full JSON of the deployment as received from the API.
out: Create a Deployment or DeploymentStatus

Create a new Deployment, or update a given Deployment with a new DeploymentStatus

Parameters
  • type: Optional. Either deployment or status. Defaults to status.
If type=status
  • id: Required. The ID of the deployment to update with the new status. NB: You'll most likely want to reference a file with this ID stored in (see below).

  • state: Required. The state of the new deployment status. Must be one of pending, success, error, inactive, or failure.

If type=deployment
  • ref: Optional. The ref of the deployment. A branch name, a tag, or SHA.

  • environment: Optional. The name of the environment that is being deployed to.

  • description: Optional. The description of the deployment.

  • payload: Optional. Additional data about the deployment.

  • payload_path: Optional. Path to a file containing additional JSON data to add to the payload.

NB: If there are duplicate keys in data from payload and payload_path, then the data from payload_path takes precedence.

  • task: Optional. The name of the task for the deployment.
Reading values from files

All of the above parameters can be used to pass the name of a file to read the applicable value from. For example...

- put: deployment
  params:
    id:
      file: path/to/the/id/file
    state: success
    description:
      file: path/to/the/description

The above configuration, would read in the id and description values from files, but use the state value which has been passed in directly as a string.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fatal

func Fatal(doing string, err error)

func Sayf

func Sayf(message string, args ...interface{})

Types

type CheckCommand

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

func NewCheckCommand

func NewCheckCommand(github GitHub, writer io.Writer) *CheckCommand

func (*CheckCommand) Run

func (c *CheckCommand) Run(request CheckRequest) ([]Version, error)

type CheckRequest

type CheckRequest struct {
	Source  Source  `json:"source"`
	Version Version `json:"version"`
}

func NewCheckRequest

func NewCheckRequest() CheckRequest

type DeploymentOutCommand

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

func NewDeploymentOutCommand

func NewDeploymentOutCommand(github GitHub, writer io.Writer) *DeploymentOutCommand

func (*DeploymentOutCommand) Run

func (c *DeploymentOutCommand) Run(sourceDir string, request OutRequest) (OutResponse, error)

type GitHub

type GitHub interface {
	ListDeployments() ([]*github.Deployment, error)
	ListDeploymentStatuses(ID int64) ([]*github.DeploymentStatus, error)
	GetDeployment(ID int64) (*github.Deployment, error)
	CreateDeployment(request *github.DeploymentRequest) (*github.Deployment, error)
	CreateDeploymentStatus(ID int64, request *github.DeploymentStatusRequest) (*github.DeploymentStatus, error)
}

type GitHubClient

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

func NewGitHubClient

func NewGitHubClient(source Source) (*GitHubClient, error)

func (*GitHubClient) CreateDeployment

func (g *GitHubClient) CreateDeployment(request *github.DeploymentRequest) (*github.Deployment, error)

func (*GitHubClient) CreateDeploymentStatus

func (g *GitHubClient) CreateDeploymentStatus(ID int64, request *github.DeploymentStatusRequest) (*github.DeploymentStatus, error)

func (*GitHubClient) GetDeployment

func (g *GitHubClient) GetDeployment(ID int64) (*github.Deployment, error)

func (*GitHubClient) ListDeploymentStatuses

func (g *GitHubClient) ListDeploymentStatuses(ID int64) ([]*github.DeploymentStatus, error)

func (*GitHubClient) ListDeployments

func (g *GitHubClient) ListDeployments() ([]*github.Deployment, error)

type InCommand

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

func NewInCommand

func NewInCommand(github GitHub, writer io.Writer) *InCommand

func (*InCommand) Run

func (c *InCommand) Run(destDir string, request InRequest) (InResponse, error)

type InRequest

type InRequest struct {
	Source  Source  `json:"source"`
	Version Version `json:"version"`
}

func NewInRequest

func NewInRequest() InRequest

type InResponse

type InResponse struct {
	Version  Version        `json:"version"`
	Metadata []MetadataPair `json:"metadata"`
}

type MetadataPair

type MetadataPair struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type OutCommand

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

func NewOutCommand

func NewOutCommand(github GitHub, writer io.Writer) *OutCommand

func (*OutCommand) Run

func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, error)

type OutParams

type OutParams struct {
	Type        *string `json:"type"`
	ID          *string
	Ref         *string
	Environment *string
	Task        *string
	State       *string
	Description *string
	AutoMerge   *bool
	Payload     *map[string]interface{}
	PayloadPath *string `json:"payload_path"`

	RawID          json.RawMessage `json:"id"`
	RawState       json.RawMessage `json:"state"`
	RawRef         json.RawMessage `json:"ref"`
	RawTask        json.RawMessage `json:"task"`
	RawEnvironment json.RawMessage `json:"environment"`
	RawDescription json.RawMessage `json:"description"`
	RawAutoMerge   json.RawMessage `json:"auto_merge"`
	RawPayload     json.RawMessage `json:"payload"`
}

func (*OutParams) UnmarshalJSON

func (p *OutParams) UnmarshalJSON(b []byte) (err error)

type OutRequest

type OutRequest struct {
	Source Source    `json:"source"`
	Params OutParams `json:"params"`
}

func NewOutRequest

func NewOutRequest() OutRequest

type OutResponse

type OutResponse struct {
	Version  Version        `json:"version"`
	Metadata []MetadataPair `json:"metadata"`
}

type Source

type Source struct {
	User         string   `json:"user"`
	Repository   string   `json:"repository"`
	AccessToken  string   `json:"access_token"`
	GitHubAPIURL string   `json:"github_api_url"`
	Environments []string `json:"environments"`
}

type Version

type Version struct {
	ID       string `json:"id"`
	Statuses string `json:"status"`
}

Directories

Path Synopsis
cmd
check command
in command
out command
This file was generated by counterfeiter
This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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