Documentation
¶
Overview ¶
package common contains common types and functions used by implementations
Index ¶
- Constants
- func CheckAuthorised(originalHandler http.Handler, authToken string) http.Handler
- func CreateServer(mux *http.ServeMux, registryH IRegistryClient, authToken string, ...)
- func ImageGetNameAndTag(r *http.Request) (string, string, error)
- func InternalServerError(w http.ResponseWriter, r *http.Request, errorResponse error)
- func NotAuthorised(w http.ResponseWriter, r *http.Request)
- func NotFound(w http.ResponseWriter, r *http.Request)
- func RepoGetName(r *http.Request) (string, error)
- func Run(registryH IRegistryClient, healthInfo map[string]string, listen string, ...)
- type IRegistryClient
- type RegistryServer
- type RegistryToken
Constants ¶
const AUTH_TOKEN_ENV_VAR = "BINDERHUB_AUTH_TOKEN" // #nosec G101 -- Name of an env-var, not a secret
Variables ¶
This section is empty.
Functions ¶
func CheckAuthorised ¶
CheckAuthorised wraps originalHandler to check for a valid Authorization header and returns a http.Handler
func CreateServer ¶
func CreateServer(mux *http.ServeMux, registryH IRegistryClient, authToken string, promRegistry *prometheus.Registry)
CreateServer configures a new http handler for the registry helper
func ImageGetNameAndTag ¶
ImageGetNameAndTag extracts the repository name and tag from the request path
func InternalServerError ¶
func InternalServerError(w http.ResponseWriter, r *http.Request, errorResponse error)
InternalServerError is a handler that returns a 500 HTTP error
func NotAuthorised ¶
func NotAuthorised(w http.ResponseWriter, r *http.Request)
NotAuthorised is a handler that returns a 403 HTTP error
func NotFound ¶
func NotFound(w http.ResponseWriter, r *http.Request)
NotFound is a handler that returns a 404 HTTP error
func RepoGetName ¶
RepoGetName extracts the repository name from the request path
func Run ¶
func Run(registryH IRegistryClient, healthInfo map[string]string, listen string, promRegistry *prometheus.Registry)
The main entrypoint for the service
Types ¶
type IRegistryClient ¶
type IRegistryClient interface { ListRepositories(w http.ResponseWriter, r *http.Request) GetRepository(w http.ResponseWriter, r *http.Request) GetImage(w http.ResponseWriter, r *http.Request) CreateRepository(w http.ResponseWriter, r *http.Request) DeleteRepository(w http.ResponseWriter, r *http.Request) GetToken(w http.ResponseWriter, r *http.Request) }
IRegistryClient is an interface that all registry helpers must implement
type RegistryServer ¶
type RegistryServer struct {
Client IRegistryClient
}
RegistryServer is http.handler that passes requests to the registry helper implementation
func (*RegistryServer) ServeHTTP ¶
func (h *RegistryServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP passes requests to the registry helper implementation
type RegistryToken ¶
type RegistryToken struct { Username string `json:"username"` Password string `json:"password"` Registry string `json:"registry"` Expires time.Time `json:"expires"` }
RegistryToken is an object containing a username and password that can be used to login to a registry and an Expires time when the token will expire