client

package
v1.25.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package client contains the client implementations for several providers.

Index

Constants

View Source
const DefaulGitSSHCommand = `ssh -i "{{ .KeyPath }}" -o StrictHostKeyChecking=accept-new -F /dev/null`

DefaulGitSSHCommand used for git over SSH.

View Source
const DefaultGitHubDownloadURL = "https://github.com"
View Source
const DefaultGitLabDownloadURL = "https://gitlab.com"

Variables

View Source
var ErrNotImplemented = fmt.Errorf("not implemented")

ErrNotImplemented is returned when a client does not implement certain feature.

View Source
var ErrReleaseDisabled = fmt.Errorf("release is disabled, cannot use default url_template")

ErrReleaseDisabled happens when a configuration tries to use the default url_template even though the release is disabled.

Functions

func TemplateRef added in v1.13.0

func TemplateRef(apply func(s string) (string, error), ref config.RepoRef) (config.RepoRef, error)

TemplateRef templates a config.RepoFromRef

Types

type Client

type Client interface {
	CloseMilestone(ctx *context.Context, repo Repo, title string) (err error)
	// Creates a release. It's marked as draft if possible (should call PublishRelease to finish publishing).
	CreateRelease(ctx *context.Context, body string) (releaseID string, err error)
	PublishRelease(ctx *context.Context, releaseID string) (err error)
	Upload(ctx *context.Context, releaseID string, artifact *artifact.Artifact, file *os.File) (err error)
	Changelog(ctx *context.Context, repo Repo, prev, current string) (string, error)
	ReleaseURLTemplater
	FileCreator
}

Client interface.

func New added in v0.112.0

func New(ctx *context.Context) (Client, error)

New creates a new client depending on the token type.

func NewIfToken added in v0.180.0

func NewIfToken(ctx *context.Context, cli Client, token string) (Client, error)

type ErrNoMilestoneFound added in v0.140.0

type ErrNoMilestoneFound struct {
	Title string
}

ErrNoMilestoneFound is an error when no milestone is found.

func (ErrNoMilestoneFound) Error added in v0.140.0

func (e ErrNoMilestoneFound) Error() string

type FileCreator added in v1.18.0

type FileCreator interface {
	CreateFile(ctx *context.Context, commitAuthor config.CommitAuthor, repo Repo, content []byte, path, message string) (err error)
}

FileCreator can create the given file to some code repository.

type FilesCreator added in v1.19.0

type FilesCreator interface {
	FileCreator
	CreateFiles(ctx *context.Context, commitAuthor config.CommitAuthor, repo Repo, message string, files []RepoFile) (err error)
}

FilesCreator can create the multiple files in some repository and in a single commit.

func NewGitUploadClient added in v1.18.0

func NewGitUploadClient(branch string) FilesCreator

NewGitUploadClient

type ForkSyncer added in v1.25.0

type ForkSyncer interface {
	SyncFork(ctx *context.Context, head, base Repo) error
}

ForkSyncer can sync forks.

type Info

type Info struct {
	Description string
	Homepage    string
	URL         string
}

Info of the repository.

type Mock added in v0.181.0

type Mock struct {
	CreatedFile          bool
	Content              string
	Path                 string
	Messages             []string
	FailToCreateRelease  bool
	FailToUpload         bool
	CreatedRelease       bool
	UploadedFile         bool
	ReleasePublished     bool
	UploadedFileNames    []string
	UploadedFilePaths    map[string]string
	FailFirstUpload      bool
	Lock                 sync.Mutex
	ClosedMilestone      string
	FailToCloseMilestone bool
	Changes              string
	ReleaseNotes         string
	ReleaseNotesParams   []string
	OpenedPullRequest    bool
	SyncedFork           bool
}

func NewMock added in v0.181.0

func NewMock() *Mock

func (*Mock) Changelog added in v0.181.0

func (c *Mock) Changelog(_ *context.Context, _ Repo, _, _ string) (string, error)

func (*Mock) CloseMilestone added in v0.181.0

func (c *Mock) CloseMilestone(_ *context.Context, _ Repo, title string) error

func (*Mock) CreateFile added in v0.181.0

func (c *Mock) CreateFile(_ *context.Context, _ config.CommitAuthor, _ Repo, content []byte, path, msg string) error

func (*Mock) CreateRelease added in v0.181.0

func (c *Mock) CreateRelease(_ *context.Context, _ string) (string, error)

func (*Mock) GenerateReleaseNotes added in v1.0.0

func (c *Mock) GenerateReleaseNotes(_ *context.Context, _ Repo, prev, current string) (string, error)

func (*Mock) OpenPullRequest added in v1.17.0

func (c *Mock) OpenPullRequest(_ *context.Context, _, _ Repo, _ string, _ bool) error

func (*Mock) PublishRelease added in v1.25.0

func (c *Mock) PublishRelease(_ *context.Context, _ string) (err error)

func (*Mock) ReleaseURLTemplate added in v0.181.0

func (c *Mock) ReleaseURLTemplate(_ *context.Context) (string, error)

func (*Mock) SyncFork added in v1.25.0

func (c *Mock) SyncFork(_ *context.Context, _ Repo, _ Repo) error

func (*Mock) Upload added in v0.181.0

func (c *Mock) Upload(_ *context.Context, _ string, artifact *artifact.Artifact, file *os.File) error

type PullRequestOpener added in v1.17.0

type PullRequestOpener interface {
	OpenPullRequest(ctx *context.Context, base, head Repo, title string, draft bool) error
}

PullRequestOpener can open pull requests.

type ReleaseNotesGenerator added in v1.17.0

type ReleaseNotesGenerator interface {
	GenerateReleaseNotes(ctx *context.Context, repo Repo, prev, current string) (string, error)
}

ReleaseNotesGenerator can generate release notes.

func NewGitHubReleaseNotesGenerator added in v1.17.0

func NewGitHubReleaseNotesGenerator(ctx *context.Context, token string) (ReleaseNotesGenerator, error)

NewGitHubReleaseNotesGenerator returns a GitHub client that can generate changelogs.

type ReleaseURLTemplater added in v1.21.0

type ReleaseURLTemplater interface {
	ReleaseURLTemplate(ctx *context.Context) (string, error)
}

ReleaseURLTemplater provides the release URL as a template, containing the artifact name as well.

func NewReleaseClient added in v1.21.0

func NewReleaseClient(ctx *context.Context) (ReleaseURLTemplater, error)

NewReleaseClient returns a ReleaserURLTemplater, handling the possibility of the release being disabled.

type Repo added in v0.139.0

type Repo struct {
	Owner         string
	Name          string
	Branch        string
	GitURL        string
	GitSSHCommand string
	PrivateKey    string
}

func RepoFromRef added in v0.139.0

func RepoFromRef(ref config.RepoRef) Repo

RepoFromRef converts a config.RepoRef into a Repo.

func (Repo) String added in v0.139.0

func (r Repo) String() string

type RepoFile added in v1.19.0

type RepoFile struct {
	Content    []byte
	Path       string
	Identifier string // for the use of the caller.
}

RepoFile is a file to be created.

type RetriableError added in v0.130.0

type RetriableError struct {
	Err error
}

RetriableError is an error that will cause the action to be retried.

func (RetriableError) Error added in v0.130.0

func (e RetriableError) Error() string

Jump to

Keyboard shortcuts

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