Documentation ¶
Index ¶
- Constants
- Variables
- type Image
- type Organisation
- type Owner
- type Repository
- type Token
- type User
- func (u *User) Create(session *mgo.Session) error
- func (u *User) EncryptPassword() error
- func (u *User) Exists(session *mgo.Session) bool
- func (u *User) GetAccessToken(session *mgo.Session, path string) (*Token, error)
- func (u *User) GetID() bson.ObjectId
- func (u *User) GetOrganisations(session *mgo.Session) (*[]Organisation, error)
- func (u *User) GetStorageProvider() storage.StorageProvider
- func (u *User) String() string
- func (u *User) Validate(session *mgo.Session) error
Constants ¶
const TokenDuration = 1 * time.Hour
TokenDuration is the default token expiration time
Variables ¶
var OwnerPattern = `[a-zA-Z0-9\._]{4,30}`
OwnerPattern is a regexp for matching and validating repository owners
var RepositoryPattern = `[a-zA-Z0-9\._]{4,30}`
RepositoryPattern is a regexp that can be used for matching and validating repository names.
var TokenPattern = `[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`
TokenPattern is a regexp pattern that can be used for matching tokens (UUIDs)
Functions ¶
This section is empty.
Types ¶
type Image ¶
type Image struct { ID bson.ObjectId `bson:"_id,omitempty"` Identifier string `json:"id"` Checksum string Author string Parent string Created time.Time Container string DockerVersion string Tag string Architecture string OperatingSystem string Size int64 Config interface{} `json:"config"` ContainerConfig interface{} `json:"container_config"` }
Image stores a Docker image and it's checksum
func LoadImage ¶
LoadImage loads an image from the database based on the provided identifier. Returns the loaded image if successful otherwise returns an error.
type Organisation ¶
func (*Organisation) GetID ¶
func (o *Organisation) GetID() bson.ObjectId
func (*Organisation) String ¶
func (o *Organisation) String() string
type Owner ¶
Owner is somebody who can access a repository. Either a user, or maybe in the future an organisation.
func LoadOwnerByID ¶
LoadOwner loads an owner from either a username or organisation name
type Repository ¶
type Repository struct { ID bson.ObjectId `bson:"_id,omitempty"` Created time.Time Modified time.Time Public bool Name string Owner bson.ObjectId `bson:"owner_id"` Images []string Tags map[string]string }
Repository is a docker repository. It is owned by either a user or an organisation.
func LoadRepository ¶
LoadRepository loads a repository based on the provided owner and repository name
func NewRepository ¶
func NewRepository(owner Owner, name string) *Repository
NewRepository creates a new repository object
func (*Repository) Create ¶
func (r *Repository) Create(session *mgo.Session) error
Create saves a repository to the database
func (*Repository) Exists ¶
func (r *Repository) Exists(session *mgo.Session) bool
Exists checks if a repository already exists
func (*Repository) String ¶
func (r *Repository) String() string
String provides a textual representation of the repository
type Token ¶
type Token struct { ID bson.ObjectId `bson:"_id,omitempty"` Created time.Time Modified time.Time User bson.ObjectId `bson:"user_id"` Path string Signature string ReadAccess bool WriteAccess bool Expires time.Time }
Token provides access for a user to a repository
func LoadTokenBySignature ¶
LoadTokenBySignature loads a token from the database
type User ¶
type User struct { ID bson.ObjectId `bson:"_id,omitempty"` Created time.Time Modified time.Time Email string Username string Password string StorageProvider int AwsAccessKey string AwsSecretKey string AwsBucket string Organisations []bson.ObjectId }
User encapulates an authenticated user and is used by the various contexts/handlers
func AuthenticateUser ¶
AuthenticateUser loads a user from the database session provided, queryinng by username and verifies the password. Returns an error if the user is unable to be authenticated.
func (*User) EncryptPassword ¶
EncryptPassword converts a plaintext password (as delivered by the 'docker login' program) to a bcrypted one, ready for storing in our DB.
func (*User) GetAccessToken ¶
GetAccessToken fetches a previously created token that allows this user access to the provided repository path - if it finds a valid one in the database that hasn't expired.
func (*User) GetOrganisations ¶
func (u *User) GetOrganisations(session *mgo.Session) (*[]Organisation, error)
GetOrganisations returns the organisations that this user is a member of
func (*User) GetStorageProvider ¶
func (u *User) GetStorageProvider() storage.StorageProvider
GetStorageProvider fetches a storage provider configured to the user's preference (eg: AWS S3)