api

package
v0.4.0-preview Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAuthorized

func CheckAuthorized(env *Env, namespace string, accessToken string) error

CheckAuthorized checks if a user is authorized to update a namespace.

func GetAuthorizedNamespace

func GetAuthorizedNamespace(env *Env, r *http.Request) (string, error)

GetAuthorizedNamespace returns a namespace only if user is admin.

Types

type API

type API struct {
	Author   string
	Name     string
	Image    string
	Versions []Version
}

API stores an API.

type Auth

type Auth interface {
	VerifyIDToken(string) (string, error)
}

Auth is an interface for authentication providers.

type ContainerBuilder

type ContainerBuilder interface {
	GetBuildType() *v1.BuildType
}

ContainerBuilder is an interface for Docker container builders.

type ContainerRegistry

type ContainerRegistry interface {
	GetDockerImagePath(ImageName) string
	ListImageTags(string) error
}

ContainerRegistry is an interface for Docker container registries.

type DB

type DB interface {
	IsUserAdminOfNamespace(uid string, namespace string) (bool, error)

	UpdateAPIMetadata(imageID string, metadata *map[string]interface{}) error

	GetVersionnedAPI(ImageName) (*Version, error)
	UpdateVersionnedAPI(imageID string, version string, template *Version) error
}

DB is an interface for manipulating DB resources.

type Env

type Env struct {
	DB                DB
	ContainerRegistry ContainerRegistry
	ContainerBuilder  ContainerBuilder
	Auth              Auth
}

Env stores our application-wide configuration.

type Error

type Error interface {
	error
	Status() int
}

Error represents a handler error. It provides methods for a HTTP status code and embeds the built-in error interface.

type Handler

type Handler struct {
	*Env
	H func(e *Env, w http.ResponseWriter, r *http.Request) error
}

Handler takes a configured Env and a function matching our signature.

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP allows our Handler type to satisfy http.Handler.

type ImageName

type ImageName struct {
	Author  string
	Name    string
	Version string
}

ImageName represent a docker container template name.

func (*ImageName) GetID

func (im *ImageName) GetID() string

GetID returns the formated id from the author & name fields.

func (*ImageName) ParseFrom

func (im *ImageName) ParseFrom(imageName string) error

ParseFrom sets an imagename fields from a fully qualified name.

type StatusError

type StatusError struct {
	Code int
	Err  error
}

StatusError represents an error with an associated HTTP status code.

func (StatusError) Error

func (se StatusError) Error() string

Allows StatusError to satisfy the error interface.

func (StatusError) Status

func (se StatusError) Status() int

Status returns our HTTP status code.

type Version

type Version struct {
	IsPublic bool             `firestore:"isPublic"`
	Version  string           `firestore:"version"`
	Manifest *latest.Manifest `firestore:"manifest"`
}

Version stores an API version.

Jump to

Keyboard shortcuts

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