interfaces

package
v0.0.0-...-81ff50b Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2017 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var README = domain.File{
	Path:    "README.md",
	Content: []byte("# This is a README"),
}

README defines a readme to be written in a repository

Functions

func Adapt

func Adapt(h http.Handler, adapters ...Adapter) http.Handler

Adapt takes several Adapters and calls them in order

Types

type Adapter

type Adapter func(http.Handler) http.Handler

Adapter is the signature of an HTTPHandler for middlewares

func GetToken

func GetToken(repo repository, apiURL string, salt string) Adapter

GetToken gets the token from the users microservice

func Notify

func Notify() Adapter

Notify is a middleware to measure the time that a request takes

func SetToken

func SetToken(repo repository) Adapter

SetToken injects the token from the request

type GHInteractor

type GHInteractor interface {
	GHCallback(code, state, incomingState string) (*domain.User, error)
	GHLogin() (string, string)
	ShowUser(username string) (*domain.User, error)
	ShowRepos(username string) ([]domain.Repository, error)
	CreateRepo(username, reponame, org string, private bool) (*domain.Repository, error)
	ShowRepo(username, repo string) (*domain.Repository, error)
	ShowKeys(username string) ([]domain.Key, error)
	CreateKey(username string, key *domain.Key) error
	ShowKey(username string, id int) (*domain.Key, error)
	CreateFile(file domain.File, author domain.Author, username, repo string) error
	AddFiles(files []domain.File, author domain.Author, username, repo string) error
	AddDeployKey(username, reponame string, key *domain.Key) error
}

GHInteractor defines all the functions the Github Interactor should have

type GithubRepository

type GithubRepository struct {
	// contains filtered or unexported fields
}

GithubRepository receives a github client and performs the necessary operations within an user account

func NewGithubRepository

func NewGithubRepository(clientID, clientSecret string, scopes []string) (*GithubRepository, error)

NewGithubRepository initializes the GithubRepository

func (GithubRepository) AddDeployKey

func (repo GithubRepository) AddDeployKey(username, reponame string, key *domain.Key) error

func (GithubRepository) AddFiles

func (repo GithubRepository) AddFiles(files []domain.File, author domain.Author, username, reponame string) error

AddFiles inserts multiple files inside a github repository

func (GithubRepository) CreateFile

func (repo GithubRepository) CreateFile(file domain.File, author domain.Author, username, repoName string) error

CreateFile creates file inside an user repository

func (GithubRepository) CreateKey

func (repo GithubRepository) CreateKey(username string, key *domain.Key) error

CreateKey creates a key in the github repository

func (GithubRepository) CreateRepo

func (repo GithubRepository) CreateRepo(username, reponame, org string, private bool) (*domain.Repository, error)

CreateRepo creates a repository in the github user account

func (GithubRepository) GetAllRepos

func (repo GithubRepository) GetAllRepos(username string) ([]domain.Repository, error)

GetAllRepos returns all the repos from an user account

func (GithubRepository) GetKey

func (repo GithubRepository) GetKey(username string, id int) (*domain.Key, error)

GetKey returns a Key from the user github account

func (GithubRepository) GetOauthURL

func (repo GithubRepository) GetOauthURL() (string, string)

GetOauthURL returns the OATH URL based on the configuration

func (GithubRepository) GetRepo

func (repo GithubRepository) GetRepo(username, reponame string) (*domain.Repository, error)

GetRepo gets the information from a single repo

func (GithubRepository) GetToken

func (repo GithubRepository) GetToken(code, givenState, incomingStates string) (*domain.User, error)

GetToken returns a token from Github with the code received from the GET request

func (*GithubRepository) GetUser

func (repo *GithubRepository) GetUser(username string) (*domain.User, error)

GetUser retrieves the github user information

func (*GithubRepository) SetToken

func (repo *GithubRepository) SetToken(token string)

SetToken sets the token for the client

func (GithubRepository) ShowKeys

func (repo GithubRepository) ShowKeys(username string) ([]domain.Key, error)

ShowKeys returns all the keys in a user github account

type WebServiceHandler

type WebServiceHandler struct {
	GHInteractor GHInteractor
	APIHost      string
}

WebServiceHandler has all the necessary fields to run a web-based interface

func (WebServiceHandler) AddFileToRepository

func (handler WebServiceHandler) AddFileToRepository(res http.ResponseWriter, req *http.Request)

AddFileToRepository adds a single file within an user repository

func (WebServiceHandler) AddMultipleFilesToRepository

func (handler WebServiceHandler) AddMultipleFilesToRepository(res http.ResponseWriter, req *http.Request)

AddMultipleFilesToRepository add multiple files into a repository

func (WebServiceHandler) Callback

func (handler WebServiceHandler) Callback(res http.ResponseWriter, req *http.Request)

Callback manages the Github OAUTH callback TODO: refactor this function, it has grown to big

func (WebServiceHandler) CreateKey

func (handler WebServiceHandler) CreateKey(res http.ResponseWriter, req *http.Request)

CreateKey creates a key in the user repository

func (WebServiceHandler) CreateRepo

func (handler WebServiceHandler) CreateRepo(res http.ResponseWriter, req *http.Request)

CreateRepo creates a repository in the user account and returns a JSON response

func (WebServiceHandler) CreateRepoDeployKey

func (handler WebServiceHandler) CreateRepoDeployKey(res http.ResponseWriter, req *http.Request)

func (WebServiceHandler) Login

func (handler WebServiceHandler) Login(res http.ResponseWriter, req *http.Request)

Login is a helper method to test the Github oauth login

func (WebServiceHandler) Root

func (handler WebServiceHandler) Root(res http.ResponseWriter, req *http.Request)

Root is a function for the index of the microservice

func (WebServiceHandler) ShowKey

func (handler WebServiceHandler) ShowKey(res http.ResponseWriter, req *http.Request)

ShowKey shows a single key whithin the user account on github

func (WebServiceHandler) ShowKeys

func (handler WebServiceHandler) ShowKeys(res http.ResponseWriter, req *http.Request)

ShowKeys returns all the keys within github in a JSON response

func (WebServiceHandler) ShowRepo

func (handler WebServiceHandler) ShowRepo(res http.ResponseWriter, req *http.Request)

ShowRepo returns a JSON response of a single repository

func (WebServiceHandler) ShowRepos

func (handler WebServiceHandler) ShowRepos(res http.ResponseWriter, req *http.Request)

ShowRepos returns a JSON with all the repositories within an user account

func (WebServiceHandler) ShowUser

func (handler WebServiceHandler) ShowUser(res http.ResponseWriter, req *http.Request)

ShowUser returns the current logged user

Jump to

Keyboard shortcuts

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