controller

package
v6.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommentController

type CommentController struct {
	GitHub   GitHub
	Expr     Expr
	Getenv   func(string) string
	Platform Platform
}

func (*CommentController) Post

func (c *CommentController) Post(ctx context.Context, cmt *github.Comment) error

type ExecCommentParams

type ExecCommentParams struct {
	Stdout         string
	Stderr         string
	CombinedOutput string
	Command        string
	JoinCommand    string
	ExitCode       int
	// PRNumber is the pull request number where the comment is posted
	PRNumber int
	// Org is the GitHub Organization or User name
	Org string
	// Repo is the GitHub Repository name
	Repo string
	// SHA1 is the commit SHA1
	SHA1        string
	TemplateKey string
	Template    string
	Vars        map[string]any
	Outputs     []*option.Output
}

type ExecController

type ExecController struct {
	Wd       string
	Stdin    io.Reader
	Stdout   io.Writer
	Stderr   io.Writer
	Getenv   func(string) string
	Reader   Reader
	GitHub   GitHub
	Renderer Renderer
	Executor Executor
	Expr     Expr
	Platform Platform
	Config   *config.Config
	Fs       afero.Fs
}

func (*ExecController) Exec

func (c *ExecController) Exec(ctx context.Context, logger *slog.Logger, opts *option.ExecOptions) error

type Executor

type Executor interface {
	Run(ctx context.Context, params *execute.Params) (*execute.Result, error)
}

type Expr

type Expr interface {
	Match(expression string, params any) (bool, error)
	Compile(expression string) (expr.Program, error)
}

type Fsys

type Fsys interface {
	Exist(path string) bool
	Write(path string, content []byte) error
}

type GitHub

type GitHub interface {
	CreateComment(ctx context.Context, cmt *github.Comment) error
	ListComments(ctx context.Context, pr *github.PullRequest) ([]*github.IssueComment, error)
	HideComment(ctx context.Context, nodeID string) error
	GetAuthenticatedUser(ctx context.Context) (string, error)
	PRNumberWithSHA(ctx context.Context, owner, repo, sha string) (int, error)
}

GitHub is API to post a comment to GitHub

type HideController

type HideController struct {
	// Wd is a path to the working directory
	Wd string
	// Getenv returns the environment variable. os.Getenv
	Getenv func(string) string
	// HasStdin returns true if there is the standard input
	// If there is the standard input, it is treated as the comment template
	HasStdin func() bool
	Stderr   io.Writer
	GitHub   GitHub
	Platform Platform
	Config   *config.Config
	Expr     Expr
}

func (*HideController) Hide

func (c *HideController) Hide(ctx context.Context, logger *slog.Logger, opts *option.HideOptions) error

type InitController

type InitController struct {
	Fsys Fsys
}

func (InitController) Run

type ParamListHiddenComments

type ParamListHiddenComments struct {
	Condition string
	HideKey   string
	Org       string
	Repo      string
	SHA1      string
	PRNumber  int
	Vars      map[string]any
}

type Platform

type Platform interface {
	ComplementPost(opts *option.PostOptions) error
	ComplementExec(opts *option.ExecOptions) error
	ComplementHide(opts *option.HideOptions) error
	CI() string
}

type PostController

type PostController struct {
	// Wd is a path to the working directory
	Wd string
	// Getenv returns the environment variable. os.Getenv
	Getenv func(string) string
	// HasStdin returns true if there is the standard input
	// If there is the standard input, it is treated as the comment template
	HasStdin func() bool
	Stdin    io.Reader
	Stderr   io.Writer
	GitHub   GitHub
	Renderer Renderer
	Platform Platform
	Config   *config.Config
	Expr     Expr
}

func (*PostController) Post

func (c *PostController) Post(ctx context.Context, logger *slog.Logger, opts *option.PostOptions) error

type PostTemplateParams

type PostTemplateParams struct {
	// PRNumber is the pull request number where the comment is posted
	PRNumber int
	// Org is the GitHub Organization or User name
	Org string
	// Repo is the GitHub Repository name
	Repo string
	// SHA1 is the commit SHA1
	SHA1        string
	TemplateKey string
	Vars        map[string]any
}

type Reader

type Reader interface {
	FindAndRead(cfgPath, wd string) (config.Config, error)
}

Reader is API to find and read the configuration file of github-comment

type Renderer

type Renderer interface {
	Render(tpl string, templates map[string]string, params any) (string, error)
}

Jump to

Keyboard shortcuts

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