genericScm

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoScmHelper

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

func NewGoScmHelper

func NewGoScmHelper(config *config.Config, tokenUpdateCallback func(token *scm.Token)) *GoScmHelper

func (*GoScmHelper) Content added in v0.4.0

func (helper *GoScmHelper) Content(accessToken string, repo string, path string, branch string) (string, string, error)

func (*GoScmHelper) CreateContent added in v0.4.0

func (helper *GoScmHelper) CreateContent(
	accessToken string,
	repo string,
	path string,
	content []byte,
	branch string,
	message string,
) error

func (*GoScmHelper) DirectoryContents added in v0.4.0

func (helper *GoScmHelper) DirectoryContents(accessToken string, repo string, directoryPath string) (map[string]string, error)

DirectoryContents returns a map of file paths as keys and their file contents in the values

func (*GoScmHelper) Organizations

func (helper *GoScmHelper) Organizations(accessToken string, refreshToken string) ([]*scm.Organization, error)

func (*GoScmHelper) Parse

func (helper *GoScmHelper) Parse(req *http.Request, fn scm.SecretFunc) (scm.Webhook, error)

func (*GoScmHelper) RegisterWebhook

func (helper *GoScmHelper) RegisterWebhook(
	host string,
	token string,
	webhookSecret string,
	owner string,
	repo string,
) error

func (*GoScmHelper) UpdateContent added in v0.4.0

func (helper *GoScmHelper) UpdateContent(
	accessToken string,
	repo string,
	path string,
	content []byte,
	blobID string,
	branch string,
	message string,
) error

func (*GoScmHelper) User

func (helper *GoScmHelper) User(accessToken string, refreshToken string) (*scm.User, error)

func (*GoScmHelper) UserRepos

func (helper *GoScmHelper) UserRepos(accessToken string, refreshToken string, expires time.Time) ([]string, error)

type Refresher added in v0.3.0

type Refresher struct {
	ClientID     string
	ClientSecret string
	Endpoint     string

	Source scm.TokenSource
	Client *http.Client
	// contains filtered or unexported fields
}

Refresher is an http.RoundTripper that refreshes oauth tokens, wrapping a base RoundTripper and refreshing the token if expired.

IMPORTANT the Refresher is NOT safe for concurrent use by multiple goroutines.

func (*Refresher) Refresh added in v0.3.0

func (t *Refresher) Refresh(token *scm.Token) error

Refresh refreshes the expired token.

func (*Refresher) Token added in v0.3.0

func (t *Refresher) Token(ctx context.Context) (*scm.Token, error)

Token returns a token. If the token is missing or expired, the token is refreshed.

Jump to

Keyboard shortcuts

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