client

package
v1.21.95 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 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

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)
	CreateRelease(ctx *context.Context, body string) (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

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

New creates a new client depending on the token type.

func NewIfToken

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

type ErrNoMilestoneFound

type ErrNoMilestoneFound struct {
	Title string
}

ErrNoMilestoneFound is an error when no milestone is found.

func (ErrNoMilestoneFound) Error

func (e ErrNoMilestoneFound) Error() string

type FileCreator

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.21.90

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

func NewGitUploadClient(branch string) FilesCreator

NewGitUploadClient

type Info

type Info struct {
	Description string
	Homepage    string
	URL         string
}

Info of the repository.

type Mock

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

func NewMock

func NewMock() *Mock

func (*Mock) Changelog

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

func (*Mock) CloseMilestone

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

func (*Mock) CreateFile

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

func (*Mock) CreateRelease

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

func (*Mock) GenerateReleaseNotes

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

func (*Mock) OpenPullRequest

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

func (*Mock) ReleaseURLTemplate

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

func (*Mock) Upload

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

type PullRequestOpener

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

PullRequestOpener can open pull requests.

type ReleaseNotesGenerator

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

ReleaseNotesGenerator can generate release notes.

func NewGitHubReleaseNotesGenerator

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

NewGitHubReleaseNotesGenerator returns a GitHub client that can generate changelogs.

type ReleaseURLTemplater added in v1.21.90

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.90

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

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

type Repo

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

func RepoFromRef

func RepoFromRef(ref config.RepoRef) Repo

RepoFromRef converts a config.RepoRef into a Repo.

func (Repo) String

func (r Repo) String() string

type RepoFile added in v1.21.90

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

RepoFile is a file to be created.

type RetriableError

type RetriableError struct {
	Err error
}

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

func (RetriableError) Error

func (e RetriableError) Error() string

Jump to

Keyboard shortcuts

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