Documentation ¶
Index ¶
- Variables
- func Adapt(h http.Handler, adapters ...Adapter) http.Handler
- type Adapter
- type GHInteractor
- type GithubRepository
- func (repo GithubRepository) AddDeployKey(username, reponame string, key *domain.Key) error
- func (repo GithubRepository) AddFiles(files []domain.File, author domain.Author, username, reponame string) error
- func (repo GithubRepository) CreateFile(file domain.File, author domain.Author, username, repoName string) error
- func (repo GithubRepository) CreateKey(username string, key *domain.Key) error
- func (repo GithubRepository) CreateRepo(username, reponame, org string, private bool) (*domain.Repository, error)
- func (repo GithubRepository) GetAllRepos(username string) ([]domain.Repository, error)
- func (repo GithubRepository) GetKey(username string, id int) (*domain.Key, error)
- func (repo GithubRepository) GetOauthURL() (string, string)
- func (repo GithubRepository) GetRepo(username, reponame string) (*domain.Repository, error)
- func (repo GithubRepository) GetToken(code, givenState, incomingStates string) (*domain.User, error)
- func (repo *GithubRepository) GetUser(username string) (*domain.User, error)
- func (repo *GithubRepository) SetToken(token string)
- func (repo GithubRepository) ShowKeys(username string) ([]domain.Key, error)
- type WebServiceHandler
- func (handler WebServiceHandler) AddFileToRepository(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) AddMultipleFilesToRepository(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) Callback(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) CreateKey(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) CreateRepo(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) CreateRepoDeployKey(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) Login(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) Root(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) ShowKey(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) ShowKeys(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) ShowRepo(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) ShowRepos(res http.ResponseWriter, req *http.Request)
- func (handler WebServiceHandler) ShowUser(res http.ResponseWriter, req *http.Request)
Constants ¶
This section is empty.
Variables ¶
var README = domain.File{ Path: "README.md", Content: []byte("# This is a README"), }
README defines a readme to be written in a repository
Functions ¶
Types ¶
type Adapter ¶
Adapter is the signature of an HTTPHandler for middlewares
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) 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
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