github

package
v0.0.0-...-7d92a45 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeFile = "file"
	ContentTypeDir  = "dir"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationType

type AuthorizationType string

AuthorizationType represents the usergroup that is allowed to do the action

const (
	AuthorizationAll        AuthorizationType = "all"
	AuthorizationOrg        AuthorizationType = "org"
	AuthorizationTeam       AuthorizationType = "team"
	AuthorizationCodeOwners AuthorizationType = "codeowners"
	AuthorizationOrgAdmin   AuthorizationType = "org-admin"
)

type Client

type Client interface {
	Client() *github.Client

	GetHead(ctx context.Context, event *GenericRequestEvent) (string, error)
	GetIssue(event *GenericRequestEvent) (*github.Issue, error)
	GetPullRequest(ctx context.Context, event *GenericRequestEvent) (*github.PullRequest, error)
	GetVersions(owner, repo string) ([]*semver.Version, error)
	GetContent(ctx context.Context, event *GenericRequestEvent, path string) ([]byte, error)

	IsAuthorized(authorizationType AuthorizationType, event *GenericRequestEvent) bool

	GetConfig(name string, obj interface{}) error
	GetRawConfig(name string) (json.RawMessage, error)
	ResolveConfigValue(ctx context.Context, event *GenericRequestEvent, value *ghval.GitHubValue) (string, error)

	UpdateComment(event *GenericRequestEvent, commentID int64, message string) error
	Comment(ctx context.Context, event *GenericRequestEvent, message string) (int64, error)
	UpdateStatus(ctx context.Context, event *GenericRequestEvent, state State, statusContext, description string) error
}

Client is the github client interface

func NewClient

func NewClient(log logr.Logger, ghClient *github.Client, httpClient *http.Client, owner, defaultTeamName string, config map[string]json.RawMessage) (Client, error)

type ContentType

type ContentType string

ContentType represents the type of a content response

type EventActionType

type EventActionType string

EventActionType represents the action type of a github event

const (
	EventActionTypeCreated EventActionType = "created"
	EventActionTypeDeleted EventActionType = "deleted"
	EventActionTypeEdited  EventActionType = "edited"
)

type GenericRequestEvent

type GenericRequestEvent struct {
	// InstallationID is the github app ID
	InstallationID int64

	// ID is the unique github id of the comment
	ID int64

	// Number is the number of the PR
	Number int

	// Head is the sha of the current PR's head commit
	Head string

	// Repository is the event's source repository
	Repository *github.Repository

	// Body comprises the message body of the commit
	Body string

	// Author is the event's author
	Author *github.User
}

GenericRequestEvent is the generic request from github triggering the tm bot

func (*GenericRequestEvent) GetAuthorName

func (e *GenericRequestEvent) GetAuthorName() string

func (*GenericRequestEvent) GetMessage

func (e *GenericRequestEvent) GetMessage() string

func (*GenericRequestEvent) GetOwnerName

func (e *GenericRequestEvent) GetOwnerName() string

func (*GenericRequestEvent) GetRepositoryKey

func (e *GenericRequestEvent) GetRepositoryKey() RepositoryKey

func (*GenericRequestEvent) GetRepositoryName

func (e *GenericRequestEvent) GetRepositoryName() string

type Manager

type Manager interface {
	GetClient(event *GenericRequestEvent) (Client, error)
}

func NewManager

func NewManager(log logr.Logger, cfg config.GitHubBot) (Manager, error)

type MembershipRole

type MembershipRole string

MembershipRole represents the membership role of organizations and teams

const (
	MembershipRoleAdmin      MembershipRole = "admin"
	MembershipRoleMember     MembershipRole = "member"
	MembershipRoleMaintainer MembershipRole = "maintainer"
)

type MembershipStatus

type MembershipStatus string

MembershipStatus represents the current membership status of a user

const (
	MembershipStatusActive MembershipStatus = "active"
)

type RepositoryKey

type RepositoryKey struct {
	Owner      string
	Repository string
}

RepositoryKey is the unique name for a repository

type State

type State string

Status state of a commit

const (
	StateError   State = "error"
	StateFailure State = "failure"
	StatePending State = "pending"
	StateSuccess State = "success"
)

type UserType

type UserType string

UserType represents the type of an owner

const (
	UserTypeUser         UserType = "User"
	UserTypeBot          UserType = "Bot"
	UserTypeOrganization UserType = "Organization"
)

Directories

Path Synopsis
Package mock_github is a generated GoMock package.
Package mock_github is a generated GoMock package.

Jump to

Keyboard shortcuts

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