github_service

package
v0.0.0-...-8b10149 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2016 License: MIT Imports: 7 Imported by: 0

README

Github integration

Describe policies for repositories managed on github

Configuration

To use the github integration, obtain an access token for your service and add it to your environment.

$ export HUBBUB_GITHUB_ACCESS_TOKEN=<your token>

Goals

github_file

Manage a file within an existing git ref (API documentation).

Parameters
key type description
state string one of "absent" OR "present"
ref string a valid ref (e.g. "heads/master" for the master branch)
name string the filename within the repo
content string (optional) the content
filename string (optional) the local file to copy to the repo

NOTE: Specifying both content and filename is ambiguous and will cause an error.

Example
"github_file": {
  "state": "present",
  "ref": "heads/master",
  "name": ".gitignore",
  "content":"npm-debug.log\nhumans.txt"
}
github_webhook

Manage a github webhook (API documentation).

Parameters
key type description
state string one of "absent" OR "present"
active boolean whether the hook should be enabled
events array[string] events to apply the hook to (see full list)
name string (optional) default "web"; override for service hooks
config object settings for the hook; format varies by service (see docs)

NOTE: hook "uniqueness" is currently determined by config.url, which may not be available for all third-party services.

Example

Example configuration for a simple web (i.e., non-service) hook:

"github_webhook": {
  "state": "present",
  "config": {
    "url": "https://my-service.com/hooks/github",
    "content_type": "json",
    "insecure_ssl": 0,
    "secret": "abc123"
  },
  "active": true,
  "events": [
    "pull_request"
  ]
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GithubServiceFactory

func GithubServiceFactory(facts *hubbub.Facts) (*hubbub.Service, error)

Types

type FileService

type FileService struct {
	Client    *github.Client
	RepoOwner string
	RepoName  string
	RefTrees  map[sha]*github.Tree
}

func NewFileService

func NewFileService(client *github.Client, owner, name string) *FileService

func (*FileService) CommitTree

func (fs *FileService) CommitTree(tree *github.Tree, refName, parentSHA, msg string) error

CommitTree commits the provided tree

func (*FileService) CreateOrUpdate

func (fs *FileService) CreateOrUpdate(parentSHA sha, params fileParams) error

CreateOrUpdate updates an existing file or creates it if it does not exist. The new file conforms to the specified params.

func (*FileService) Remove

func (fs *FileService) Remove(parentSHA sha, params fileParams) error

Remove attempts to delete a file from the parent SHA

func (*FileService) TreeFacts

func (fs *FileService) TreeFacts(SHA sha) error

RefFacts fetches the current state (SHA, tree) of the reference

type GithubService

type GithubService struct {
	Client      *github.Client
	HookService *HookService
	FileService *FileService
	RepoOwner   string
	RepoName    string
}

Serves policy goals related to github

func (*GithubService) Do

func (s *GithubService) Do(goal string, msg *json.RawMessage) error

type HookService

type HookService struct {
	Client    *github.Client
	RepoOwner string
	RepoName  string
	Hooks     *[]github.Hook
}

func NewHookService

func NewHookService(client *github.Client, owner, name string) (*HookService, error)

func (*HookService) CreateOrUpdate

func (hs *HookService) CreateOrUpdate(params *github.Hook) error

func (*HookService) Remove

func (hs *HookService) Remove(params *github.Hook) error

Jump to

Keyboard shortcuts

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