scm

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GITHUB    = "github"
	GITLAB    = "gitlab"
	BITBUCKET = "bitbucket"
)
View Source
const (
	BASE_URL           = "https://github.com"
	GITHUB_BASE_URL    = "https://api.github.com"
	CLIENT_ID          = "ca711ca70149e4948032"
	GRANT_TYPE         = "urn:ietf:params:oauth:grant-type:device_code"
	ACCESS_TOKEN       = "/access_token"
	SCOPES             = "repo"
	ACCEPT_JSON        = "application/json"
	ACCEPT_VDN         = "application/vnd.github+json"
	GITHUB_API_VERSION = "2022-11-28"
)

Variables

This section is empty.

Functions

func ExtractUserRepoName added in v0.10.3

func ExtractUserRepoName(out []byte) (string, string, error)

ExtractUserRepoName takes the output from <git remote --verbose> command as input and attempts to extract the user name and repository name from out

func ReadAccessToken added in v0.8.0

func ReadAccessToken(scm string) (string, error)

func WriteToken

func WriteToken(token string, scm string) error

WriteToken accepts an access token and the source code management platform (GitHub, GitLab etc...) and will write the token to a configuration file. This will be used to authorize future requests for reporting issues.

Types

type GitConfigManager

type GitConfigManager interface {
	Authorize() error
	Report(issues []GitIssue) <-chan Reporter
}

GitConfigManager provides flexibility to have different implementations of Authorize and Report for each source code management platform supported

func NewGitManager added in v0.10.0

func NewGitManager(scm, userName, repoName string) (GitConfigManager, error)

@TODO add other source code management structs to NewGitManager once their implementations are created

type GitHubManager

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

func (*GitHubManager) Authorize

func (gh *GitHubManager) Authorize() error

Authorize satisfies the GitManager interface. Each source code management platform will have their own version of how to authorize so that the program can submit issues on the users behalf. This implementation uses GitHubs device oauth flow. See their docs for more detailed information. First, a user code is created and a browser opens to GitHubs verification url. While the program is waiting for the user to enter the code, we poll an endpoint and check if the user has authorized the app. Once they have done so, an access token is returned from the service and is then written to ~/.config/issue-summoner/config.json

func (*GitHubManager) Report added in v0.8.0

func (gh *GitHubManager) Report(issues []GitIssue) <-chan Reporter

type GitIssue added in v0.10.3

type GitIssue struct {
	Title      string `json:"title"`
	Body       string `json:"body"`
	QueueIndex int
}

type IssueSummonerConfig

type IssueSummonerConfig = map[string]ScmTokenConfig

type Reporter added in v0.11.0

type Reporter struct {
	ID         int64
	QueueIndex int
}

type ScmTokenConfig

type ScmTokenConfig struct {
	AccessToken string
}

Jump to

Keyboard shortcuts

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