platform

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package platform defines interfaces for interacting with code review platforms.

Index

Constants

View Source
const (
	TypeUnspecified = ""
	TypeGitHub      = "github"
	TypeGitLab      = "gitlab"
)

Variables

View Source
var (

	// SortedTypes are the sorted Platform types for printing messages and prediction.
	SortedTypes = func() []string {
		allowed := append([]string{}, TypeGitHub, TypeGitLab)
		sort.Strings(allowed)
		return allowed
	}()
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Type string

	GitHub gitHubConfig
	GitLab gitLabConfig
}

Config is the configuration needed to generate different Platform types.

func (*Config) RegisterFlagsContext added in v0.0.7

func (c *Config) RegisterFlagsContext(ctx context.Context, set *cli.FlagSet)

type GitHub

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

GitHub implements the Platform interface.

func NewGitHub

func NewGitHub(ctx context.Context, cfg *gitHubConfig) (*GitHub, error)

NewGitHub creates a new GitHub client.

func (*GitHub) GetIssueBody

func (g *GitHub) GetIssueBody(ctx context.Context) (string, error)

GetIssueBody gets the Issue body.

func (*GitHub) GetRequestBody

func (g *GitHub) GetRequestBody(ctx context.Context) (string, error)

GetRequestBody gets the Pull Request body.

type GitLab

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

GitLab implements the Platform interface.

func NewGitLab

func NewGitLab(ctx context.Context, cfg *gitLabConfig) (*GitLab, error)

NewGitLab creates a new GitLab client.

func (*GitLab) GetIssueBody

func (g *GitLab) GetIssueBody(ctx context.Context) (string, error)

GetIssueBody gets the body of the issue.

func (*GitLab) GetRequestBody

func (g *GitLab) GetRequestBody(ctx context.Context) (string, error)

GetRequestBody gets the Merge Request description.

type MockPlatform

type MockPlatform struct {
	Reqs []*Request

	IsPullRequest bool
	IncludeTeams  bool

	GetRequestBodyErr      error
	GetRequestBodyResponse string
	GetIssueBodyErr        error
	GetIssueBodyResponse   string
	// contains filtered or unexported fields
}

func (*MockPlatform) GetIssueBody

func (m *MockPlatform) GetIssueBody(ctx context.Context) (string, error)

func (*MockPlatform) GetRequestBody

func (m *MockPlatform) GetRequestBody(ctx context.Context) (string, error)

type Platform

type Platform interface {
	// GetRequestBody gets the Pull Request or Merge Request body.
	GetRequestBody(ctx context.Context) (string, error)

	// GetIssueBody gets the body of the issue.
	GetIssueBody(ctx context.Context) (string, error)
}

Platform defines the minimum interface for a code review platform.

func NewPlatform

func NewPlatform(ctx context.Context, cfg *Config) (Platform, error)

NewPlatform creates a new platform based on the provided type.

type Request

type Request struct {
	Name   string
	Params []any
}

Jump to

Keyboard shortcuts

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