github

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commit

type Commit struct {
	ID       string   `json:"id"`
	Added    []string `json:"added"`
	Modified []string `json:"modified"`
}

Commit is a commit received from Github webhook

type FileService

type FileService struct {
	GitHub GitHubClient
	Logger logrus.FieldLogger
	// contains filtered or unexported fields
}

FileService is for working with repositories

func (*FileService) DecodeURL

func (f *FileService) DecodeURL(url string) (org, repo, path, branch string)

DecodeURL takes a url and returns the org, repo, path and branch

func (*FileService) Download

func (f *FileService) Download(org, repo, path, branch string) (string, error)

Download a file from github note that "path" is the full path relative to the repo root eg: src/foo/bar/filename

func (*FileService) EncodeURL

func (f *FileService) EncodeURL(org, repo, path, branch string) string

EncodeURL returns the git url for a given org, repo, path and branch

type GitHub

type GitHub struct {
	Endpoint string
	Token    string
}

func (*GitHub) CreateStatus

func (g *GitHub) CreateStatus(status *Status, org, repo, ref string) error

func (*GitHub) DownloadContents

func (g *GitHub) DownloadContents(org, repo, path, branch string) (string, error)

func (*GitHub) GetEndpoint

func (g *GitHub) GetEndpoint() string

type GitHubClient

type GitHubClient interface {
	DownloadContents(string, string, string, string) (string, error)
	CreateStatus(*Status, string, string, string) error
	GetEndpoint() string
}

type Push

type Push struct {
	Commits     []Commit   `json:"commits"`
	Repository  Repository `json:"repository"`
	Ref         string     `json:"ref"`
	GitHub      GitHub
	DeckBaseURL string
	Logger      logrus.FieldLogger
}

Push is the payload received from a GitHub webhook.

func (*Push) Branch

func (p *Push) Branch() string

Branch returns the branch of the push

func (*Push) ContainsFile

func (p *Push) ContainsFile(file string) bool

ContainsFile checks to see if a given file is in the push.

func (*Push) Files

func (p *Push) Files() []string

Files returns a slice containing filenames that were added/modified

func (*Push) IsMaster

func (p *Push) IsMaster() bool

IsMaster detects if the branch is master.

func (*Push) Name

func (p *Push) Name() string

Name returns the name of the provider to be used in configuration

func (*Push) Org

func (p *Push) Org() string

Org returns the organization of the push

func (*Push) Repo

func (p *Push) Repo() string

Repo returns the name of the repo.

func (*Push) SetCommitStatus

func (p *Push) SetCommitStatus(status git.Status)

SetCommitStatus sets the commit status TODO: this function needs to return an error but it's currently attached to an interface that does not and changes will affect other types

type Repository

type Repository struct {
	Name         string          `json:"name"`
	Organization string          `json:"organization"`
	Owner        RepositoryOwner `json:"owner"`
}

Repository is a repo received from Github webhook

type RepositoryOwner

type RepositoryOwner struct {
	Login string `json:"login"`
}

type Status

type Status struct {
	State       string
	DeckBaseURL string
	Description string
	Context     string
}

Status is a type that contains information relevant to the commit status

Jump to

Keyboard shortcuts

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