Documentation ¶
Index ¶
- type AzureReposExtra
- type BitbucketExtra
- type Comment
- type CommentHandler
- func NewAzureReposPRHandler(ctx context.Context, repoURL string, targetRef string, extra AzureReposExtra) (*CommentHandler, error)
- func NewBitbucketCommitHandler(ctx context.Context, repo string, targetRef string, extra BitbucketExtra) (*CommentHandler, error)
- func NewBitbucketPRHandler(ctx context.Context, repo string, targetRef string, extra BitbucketExtra) (*CommentHandler, error)
- func NewCommentHandler(ctx context.Context, platformHandler PlatformHandler, tag string) *CommentHandler
- func NewGitHubCommitHandler(ctx context.Context, project, targetRef string, extra GitHubExtra) (*CommentHandler, error)
- func NewGitHubPRHandler(ctx context.Context, project, targetRef string, extra GitHubExtra) (*CommentHandler, error)
- func NewGitLabCommitHandler(ctx context.Context, project string, targetRef string, extra GitLabExtra) (*CommentHandler, error)
- func NewGitLabPRHandler(ctx context.Context, project string, targetRef string, extra GitLabExtra) (*CommentHandler, error)
- func (h *CommentHandler) CommentWithBehavior(ctx context.Context, behavior, body string) error
- func (h *CommentHandler) DeleteAndNewComment(ctx context.Context, body string) error
- func (h *CommentHandler) HideAndNewComment(ctx context.Context, body string) error
- func (h *CommentHandler) LatestMatchingComment(ctx context.Context) (Comment, error)
- func (h *CommentHandler) NewComment(ctx context.Context, body string) error
- func (h *CommentHandler) UpdateComment(ctx context.Context, body string) error
- type GitHubExtra
- type GitLabExtra
- type PlatformHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AzureReposExtra ¶
type AzureReposExtra struct { // Token is the Azure DevOps access token. Token string // Tag is used to identify the Infracost comment. Tag string }
AzureReposExtra contains any extra inputs that can be passed to the Azure Repos comment handlers.
type BitbucketExtra ¶ added in v0.9.18
type BitbucketExtra struct { // ServerURL is the URL of the Bitbucket server. This can be set to a custom URL if // using Bitbucket Server/Data Center. If not set, the default Bitbucket server URL will be used. ServerURL string // Tag is used to identify the Infracost comment. Tag string // Token is the Bitbucket access token. Token string }
BitbucketExtra contains any extra inputs that can be passed to the Bitbucket comment handlers.
type Comment ¶
type Comment interface { // Body returns the body of the comment. Body() string // Ref returns the reference of the comment, this can be a URL to the HTML page of the comment. Ref() string // Less compares the comment to another comment and returns true if this // comment should be sorted before the other comment. Less(c Comment) bool // IsHidden returns true if the comment is hidden or minimized. IsHidden() bool }
Comment is an interface that represents a comment on any platform. It wraps the platform specific comment structures and is used to abstract the logic for finding, creating, updating, and deleting the comments.
type CommentHandler ¶
type CommentHandler struct { PlatformHandler PlatformHandler Tag string }
CommentHandler contains the logic for finding, creating, updating and deleting comments on any platform. It uses a PlatformHandler to call the platform-specific APIs.
func NewAzureReposPRHandler ¶
func NewAzureReposPRHandler(ctx context.Context, repoURL string, targetRef string, extra AzureReposExtra) (*CommentHandler, error)
NewAzureReposPRHandler creates a new PlatformHandler for Azure Repos pull requests.
func NewBitbucketCommitHandler ¶ added in v0.9.18
func NewBitbucketCommitHandler(ctx context.Context, repo string, targetRef string, extra BitbucketExtra) (*CommentHandler, error)
NewBitbucketCommitHandler creates a new PlatformHandler for Bitbucket commits.
func NewBitbucketPRHandler ¶ added in v0.9.18
func NewBitbucketPRHandler(ctx context.Context, repo string, targetRef string, extra BitbucketExtra) (*CommentHandler, error)
NewBitbucketPRHandler creates a new PlatformHandler for Bitbucket pull requests.
func NewCommentHandler ¶
func NewCommentHandler(ctx context.Context, platformHandler PlatformHandler, tag string) *CommentHandler
NewCommentHandler creates a new CommentHandler.
func NewGitHubCommitHandler ¶
func NewGitHubCommitHandler(ctx context.Context, project, targetRef string, extra GitHubExtra) (*CommentHandler, error)
NewGitHubCommitHandler creates a new PlatformHandler for GitHub commits.
func NewGitHubPRHandler ¶
func NewGitHubPRHandler(ctx context.Context, project, targetRef string, extra GitHubExtra) (*CommentHandler, error)
NewGitHubPRHandler creates a new CommentHandler for GitHub pull requests.
func NewGitLabCommitHandler ¶
func NewGitLabCommitHandler(ctx context.Context, project string, targetRef string, extra GitLabExtra) (*CommentHandler, error)
NewGitLabCommitHandler creates a new PlatformHandler for GitLab commits.
func NewGitLabPRHandler ¶
func NewGitLabPRHandler(ctx context.Context, project string, targetRef string, extra GitLabExtra) (*CommentHandler, error)
NewGitLabPRHandler creates a new PlatformHandler for GitLab merge requests.
func (*CommentHandler) CommentWithBehavior ¶
func (h *CommentHandler) CommentWithBehavior(ctx context.Context, behavior, body string) error
CommentWithBehavior parses the behavior and calls the corresponding *Comment method.
func (*CommentHandler) DeleteAndNewComment ¶
func (h *CommentHandler) DeleteAndNewComment(ctx context.Context, body string) error
DeleteAndNewComment deletes all existing matching comments and creates a new one with the given body.
func (*CommentHandler) HideAndNewComment ¶
func (h *CommentHandler) HideAndNewComment(ctx context.Context, body string) error
HideAndNewComment hides/minimizes all existing matching comment and creates a new one with the given body.
func (*CommentHandler) LatestMatchingComment ¶
func (h *CommentHandler) LatestMatchingComment(ctx context.Context) (Comment, error)
LatestMatchingComment returns the latest matching comment.
func (*CommentHandler) NewComment ¶
func (h *CommentHandler) NewComment(ctx context.Context, body string) error
NewComment creates a new comment with the given body.
func (*CommentHandler) UpdateComment ¶
func (h *CommentHandler) UpdateComment(ctx context.Context, body string) error
UpdateComment updates the comment with the given body.
type GitHubExtra ¶
type GitHubExtra struct { // APIURL is the URL of the GitHub API. This can be set to a custom URL if // using GitHub Enterprise. If not set, the default GitHub API URL will be used. APIURL string // Token is the GitHub API token. Token string // Tag used to identify the Infracost comment Tag string }
GitHubExtra contains any extra inputs that can be passed to the GitHub comment handlers.
type GitLabExtra ¶
type GitLabExtra struct { // ServerURL is the URL of the GitLab server. This can be set to a custom URL if // using GitLab enterprise. If not set, the default GitLab server URL will be used. ServerURL string // Token is the GitLab API token. Token string // Tag used to identify the Infracost comment Tag string }
GitLabExtra contains any extra inputs that can be passed to the GitLab comment handlers.
type PlatformHandler ¶
type PlatformHandler interface { // CallFindMatchingComments calls the platform-specific API to find // comments that match the given tag, which has been embedded at the beginning // of the comment. CallFindMatchingComments(ctx context.Context, tag string) ([]Comment, error) // CallCreateComment calls the platform-specific API to create a new comment. CallCreateComment(ctx context.Context, body string) (Comment, error) // CallUpdateComment calls the platform-specific API to update the body of a comment. CallUpdateComment(ctx context.Context, comment Comment, body string) error // CallDeleteComment calls the platform-specific API to delete the comment. CallDeleteComment(ctx context.Context, comment Comment) error // CallHideComment calls the platform-specific API to minimize the comment. // This functionality is not supported by all platforms, in which case this // will throw a NotImplemented error. CallHideComment(ctx context.Context, comment Comment) error // AddMarkdownTag adds a tag to the given string. AddMarkdownTag(s string, tag string) string }
PlatformHandler is an interface that represents a platform specific handler. It is used to call the platform-specific APIs for finding, creating, updating and deleting comments.