model

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.1.0

type Client interface {
	// DownloadContents downloads the contents of a file from a repository. (implementation of github.RepositoriesService.DownloadContents)
	DownloadContents(ctx context.Context, owner, repo, filepath string, opts *github.RepositoryContentGetOptions) (io.ReadCloser, *github.Response, error)

	// CreateComment creates a comment on the specified issue. Specifying an issue number of 0 will create a comment on the repository.
	// (implementation of github.IssuesService.CreateComment)
	CreateComment(ctx context.Context, owner string, repo string, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)

	// AddLabelsToIssue adds labels to the specified issue. Specifying an issue number of 0 will add labels to the repository.
	// (implementation of github.IssuesService.AddLabelsToIssue)
	AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*github.Label, *github.Response, error)

	// GetIssue retrieves the specified issue. Specifying an issue number of 0 will return the repository's default issue.
	// (implementation of github.IssuesService.Get)
	GetIssue(ctx context.Context, owner string, repo string, number int) (*github.Issue, *github.Response, error)

	// GetPullRequest retrieves the specified pull request. Specifying a pull request number of 0 will return the repository's default pull request.
	// (implementation of github.PullRequestsService.Get)
	GetPullRequest(ctx context.Context, owner string, repo string, number int) (*github.PullRequest, *github.Response, error)
}

type Comments

type Comments struct {
	Issues       *string `yaml:"issues,omitempty"`
	PullRequests *string `yaml:"prs,omitempty"`
}

Comments are optional comment text to be added to the issue or pull request when labels are applied

func (Comments) Ptr

func (c Comments) Ptr() *Comments

Ptr gets the pointer to a Comments object

type Config

type Config interface {
	// FromBytes is used to parse bytes into the Config instance
	FromBytes(b []byte) error

	// LabelsFor allows config implementations to determine the labels to be applied to the input strings
	LabelsFor(text ...string) map[string]Label
}

Config is the interface used by simple and full config objects

type Enable

type Enable struct {
	Issues       *bool `yaml:"issues,omitempty"`
	PullRequests *bool `yaml:"prs,omitempty"`
}

Enable is a structure to hold options around enabling the labeler

func (Enable) Ptr

func (e Enable) Ptr() *Enable

Ptr gets the pointer to an Enable object

type FieldOverrides added in v0.1.4

type FieldOverrides interface {
	// IncludedFields returns the fields that are used for labeling, if not defined, it returns an empty slice
	IncludedFields() []string
}

type FullConfig

type FullConfig struct {
	Enable   *Enable          `yaml:"enable,omitempty"`
	Comments *Comments        `yaml:"comments,omitempty"`
	Labels   map[string]Label `yaml:"labels,flow"`
	Fields   []string         `yaml:"fields,omitempty,flow"`
}

FullConfig is the container defining how the configuration object is structured

func (*FullConfig) FromBytes

func (f *FullConfig) FromBytes(b []byte) error

FromBytes is used to parse bytes into the Config instance

func (*FullConfig) IncludedFields added in v0.1.4

func (f *FullConfig) IncludedFields() []string

IncludedFields returns the fields that are used for labeling, if not defined, it returns an empty slice

func (*FullConfig) LabelsFor

func (f *FullConfig) LabelsFor(text ...string) map[string]Label

LabelsFor allows config implementations to determine the labels to be applied to the input strings

func (FullConfig) Ptr

func (f FullConfig) Ptr() *FullConfig

Ptr gets the pointer to a FullConfig object

type Label

type Label struct {
	Include  []string `yaml:"include,omitempty,flow"`
	Exclude  []string `yaml:"exclude,omitempty,flow"`
	Branches []string `yaml:"branches,omitempty,flow"`
}

Label holds the rules around how labels will be applied

func (Label) Ptr

func (l Label) Ptr() *Label

Ptr gets the pointer to a Label object

type RichClient added in v0.1.0

type RichClient struct {
	*github.Client
}

RichClient is a wrapper around the github.Client that provides additional methods for downloading contents, creating comments, adding labels, and retrieving issues and pull requests.

func (*RichClient) AddLabelsToIssue added in v0.1.0

func (r *RichClient) AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*github.Label, *github.Response, error)

AddLabelsToIssue adds labels to the specified issue. It implements the github.IssuesService.AddLabelsToIssue method.

func (*RichClient) CreateComment added in v0.1.0

func (r *RichClient) CreateComment(ctx context.Context, owner string, repo string, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)

CreateComment creates a comment on the specified issue. It implements the github.IssuesService.CreateComment method.

func (*RichClient) DownloadContents added in v0.1.0

func (r *RichClient) DownloadContents(ctx context.Context, owner, repo, filepath string, opts *github.RepositoryContentGetOptions) (io.ReadCloser, *github.Response, error)

DownloadContents downloads the contents of a file from a repository. It implements the github.RepositoriesService.DownloadContents method.

func (*RichClient) GetIssue added in v0.1.0

func (r *RichClient) GetIssue(ctx context.Context, owner string, repo string, number int) (*github.Issue, *github.Response, error)

GetIssue retrieves the specified issue. It implements the github.IssuesService.Get method.

func (*RichClient) GetPullRequest added in v0.1.0

func (r *RichClient) GetPullRequest(ctx context.Context, owner string, repo string, number int) (*github.PullRequest, *github.Response, error)

GetPullRequest retrieves the specified pull request. It implements the github.PullRequestsService.Get method.

type SimpleConfig

type SimpleConfig struct {
	// Comment will be applied to any issue or pull request matching the target labels
	Comment string `yaml:"comment,omitempty"`

	// Labels are keyed by the label to be applied, and valued by the array of regular expression patterns to match before applying
	Labels map[string][]string `yaml:"labels,omitempty,flow"`

	// Branches are keyed by the label name, and valued by the array of branch names to match before applying
	Branches map[string][]string `yaml:"branches,omitempty,flow"`
}

SimpleConfig is the simplest supported config structure. See FullConfig for more functionality.

func (*SimpleConfig) FromBytes

func (s *SimpleConfig) FromBytes(b []byte) error

FromBytes parses the bytes into the SimpleConfig object

func (*SimpleConfig) LabelsFor

func (s *SimpleConfig) LabelsFor(text ...string) map[string]Label

LabelsFor allows config implementations to determine the labels to be applied to the input strings

Jump to

Keyboard shortcuts

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