github

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InfoLevel    Level = "info"
	WarningLevel Level = "warning"
	ErrorLevel   Level = "error"

	WorkspacePathEnvVar      = "GITHUB_WORKSPACE"
	EventPathEnvVar          = "GITHUB_EVENT_PATH"
	BaseRefEnvVar            = "GITHUB_BASE_REF"
	NightfallAPIKeyEnvVar    = "NIGHTFALL_API_KEY"
	MaxAnnotationsPerRequest = 50 // https://developer.github.com/v3/checks/runs/#output-object

)

Variables

This section is empty.

Functions

func NewAuthenticatedGithubService

func NewAuthenticatedGithubService(githubToken, baseURL string) diffreviewer.DiffReviewer

NewAuthenticatedGithubService creates a new authenticated github service with the github token

Types

type CheckRequest

type CheckRequest struct {
	// Commit SHA.
	// Required.
	SHA string `json:"sha,omitempty"`
	// PullRequest number.
	// Optional.
	PullRequest int `json:"pull_request,omitempty"`
	// Owner of the repository.
	// Required.
	Owner string `json:"owner,omitempty"`
	// Repository name.
	// Required.
	Repo string `json:"repo,omitempty"`

	// Name of the annotation tool.
	// Optional.
	Name string `json:"name,omitempty"`
}

CheckRequest represents a nightfallDLP GitHub check request.

type Client

type Client struct {
	*github.Client
}

Client is a wrapper around github.Client

func NewAuthenticatedClient

func NewAuthenticatedClient(token string, baseUrl string) *Client

NewAuthenticatedClient generates an authenticated github client

func (*Client) ChecksService

func (c *Client) ChecksService() githubintf.GithubChecks

ChecksService gets the github client's checks service

func (*Client) PullRequestsService

func (c *Client) PullRequestsService() githubintf.GithubPullRequests

PullRequestsService gets the github client's pull requests service

func (*Client) RepositoriesService

func (c *Client) RepositoriesService() githubintf.GithubRepositories

RepositoriesService gets the github client's repositories service

type Level

type Level string

type Service

type Service struct {
	Client       githubintf.GithubClient
	Logger       logger.Logger
	CheckRequest *CheckRequest
	GitDiff      gitdiffintf.GitDiff
}

Service contains the github client that makes Github api calls

func (*Service) GetDiff

func (s *Service) GetDiff() ([]*diffreviewer.FileDiff, error)

GetDiff retrieves the file diff from the requested pull request

func (*Service) GetLogger

func (s *Service) GetLogger() logger.Logger

GetLogger gets the github service logger

func (*Service) LoadConfig

func (s *Service) LoadConfig(nightfallConfigFileName string) (*nightfallconfig.Config, error)

LoadConfig gets all config values from files or environment and creates a config

func (*Service) WriteComments

func (s *Service) WriteComments(comments []*diffreviewer.Comment) error

WriteComments posts the findings as annotations to the github check

Jump to

Keyboard shortcuts

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