steps

package
v0.0.0-...-9e9b4ff Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTarball

func CreateTarball(path string, w io.Writer) (string, error)

CreateTarball will create a step tarball based on path.

func PublishStep

func PublishStep(ps Publisher, manifest *StepManifest, tarball io.Reader, username, checksum string, size int64, private bool) error

PublishStep uses ps to create a new step using manifest, tarball.

func ValidateManifest

func ValidateManifest(manifest *StepManifest) error

ValidateManifest checks for some common issues, before sending the manifest to the Wercker steps server.

Types

type PublishStepRequest

type PublishStepRequest struct {
	// checksum of the tarball containing the step
	Checksum string `json:"checksum,omitempty"`
	// size of the tarball containing the step
	Size int64 `json:"size,omitempty"`
	// manifest contains the manifest of the step
	Manifest *StepManifest `json:"manifest,omitempty"`
	// username
	Username string `json:"username,omitempty"`
	// specifies whether the step is private or public
	Private bool `json:"private,omitempty"`
}

type PublishStepResponse

type PublishStepResponse struct {
	// uploadUrl is the URL the client has to post the tarball to
	UploadUrl string `json:"uploadUrl,omitempty"`
	// token is the token to send to the done endpoint to notify the upload has
	// been finished
	Token string `json:"token,omitempty"`
	// expires is the expiration date of the uploadUrl
	Expires string `json:"expires,omitempty"`
}

type Publisher

type Publisher interface {
	// CreateDraft implements the first step of the publication flow. It requires
	// a manifest, the checksum and size of the tarball.
	CreateDraft(req *PublishStepRequest) (*PublishStepResponse, error)

	// UploadTarball uploads the step tarball using the response from the
	// CreateDraft endpoint.
	UploadTarball(uploadURL string, body io.Reader, size int64) error

	// FinishPublish post to the publish endpoint and the tarball is uploaded to
	// indicate that the step can be published.
	FinishPublish(token string) error
}

Publisher contains the steps to publish a step.

type RESTPublisher

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

RESTPublisher contains the steps to publish a step.

func NewRESTPublisher

func NewRESTPublisher(endpoint string, client *http.Client, stepsClient *http.Client) *RESTPublisher

NewRESTPublisher creates a publisher that uses the REST API.

func (*RESTPublisher) CreateDraft

func (s *RESTPublisher) CreateDraft(createDraftRequest *PublishStepRequest) (*PublishStepResponse, error)

CreateDraft implements the first step of the publication flow. It requires a manifest, the checksum and size of the tarball.

func (*RESTPublisher) FinishPublish

func (s *RESTPublisher) FinishPublish(token string) error

FinishPublish post to the publish endpoint and the tarball is uploaded to indicate that the step can be published.

func (*RESTPublisher) UploadTarball

func (s *RESTPublisher) UploadTarball(uploadURL string, body io.Reader, size int64) error

UploadTarball uploads the step tarball using the response from the CreateDraft endpoint.

type Step

type Step struct {
	// owner is the user owning the step
	Owner string `json:"owner,omitempty"`
	// name of the step
	Name string `json:"name,omitempty"`
	// version of the step
	Version *StepVersion `json:"version,omitempty"`
	// summary of the step. Should never exceed 140 characters
	Summary string `json:"summary,omitempty"`
	// tags of the step
	Tags []string `json:"tags,omitempty"`
	// checksum of the tarball containing the step
	Checksum string `json:"checksum,omitempty"`
	// size of the tarball containing the step
	Size int64 `json:"size,omitempty"`
	// license of the step
	License string `json:"license,omitempty"`
	// properties of the step
	Properties []*StepProperty `json:"properties,omitempty"`
	// repository of the step. URL where to find the source of the step
	Repository string `json:"repository,omitempty"`
	// tarballUrl points to the step download link
	TarballURL string `json:"tarballUrl,omitempty"`
	// readmeUrl point to the step README
	ReadmeURL string `json:"readmeUrl,omitempty"`
}

type StepManifest

type StepManifest struct {
	// name of the step
	Name string `json:"name,omitempty"`
	// version of the step
	Version string `json:"version,omitempty"`
	// summary of the step
	Summary string `json:"summary,omitempty"`
	// tags of the step
	Tags []string `json:"tags,omitempty"`
	// properties of the step
	Properties []*StepProperty `json:"properties,omitempty"`
}

func ParseManifest

func ParseManifest(b []byte) (*StepManifest, error)

ParseManifest parse b as a StepManifest.

func ParseManifestReader

func ParseManifestReader(r io.Reader) (*StepManifest, error)

ParseManifestReader first reads all of r into memory before using ParseManifest to unmarshall the content.

type StepProperty

type StepProperty struct {
	// name of the property
	Name string `json:"name,omitempty"`
	// type of the property
	Type string `json:"type,omitempty"`
	// required whether the property is required or not
	Required bool `json:"required,omitempty"`
	// default property
	Default string `json:"default,omitempty"`
}

type StepVersion

type StepVersion struct {
	// number is the semantic version representation of the step
	Number string `json:"number,omitempty"`
	// published is the ISO8601 string representation of the publish date
	Published string `json:"published,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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