common

package
v0.0.0-...-38f047e Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2016 License: AGPL-3.0 Imports: 4 Imported by: 1

Documentation

Overview

Package common houses data structures and interfaces shared between gohstd and potential clients

Index

Constants

View Source
const InvalidBasicAuthError = `Basic Auth header was missing or malformed and could not be parsed`
View Source
const UserExistsError = `a user by that name already exists`

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command string

type CommandRepo

type CommandRepo interface {
	// InsertInvocations writes Invocations to storage
	InsertInvocations(user string, invocs Invocations) (err error)

	// GetInvocations returns the [n] most recent Invocations for the given
	// user
	GetInvocations(user string, n int) (result Invocations, err error)

	// GetCommands returns the [n] most recent Commands for the given user
	GetCommands(user string, n int) (result Commands, err error)
}

CommandRepo [sitory] is an interface wrapping the functions for working with command and invocation data

type Commands

type Commands []Command

type Invocation

type Invocation struct {
	Id        int       `json:"id"`
	Command   string    `json:"command"`
	Directory string    `json:"directory"`
	User      string    `json:"user"`
	Host      string    `json:"host"`
	Shell     string    `json:"shell"`
	ExitCode  int8      `json:"exitcode,string"`
	Timestamp time.Time `json:"timestamp"`
	Tags      []string  `json:"tags"`
}

Invocation represents a single execution of a command, including its context, exit code and time of execution.

type Invocations

type Invocations []Invocation

type NewPost

type NewPost struct {
	Message string `json:"message"`
	Title   string `json:"title"`
}

type Post

type Post struct {
	Message   string    `json:"message"`
	Title     string    `json:"title"`
	Username  string    `json:"username"`
	Timestamp time.Time `json:"timestamp"`
}

type Posts

type Posts []Post

type Secret

type Secret []byte

Secret indicates an encrypted user password

type User

type User struct {
	Username string `json:"username"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

func (User) Validate

func (u User) Validate() (err error)

Validate returns an error if a User struct does not satisfy the following conditions:

  • Username is 3 or more characters
  • Username is composed solely of alphanumeric characters
  • Email is a valid email address
  • Password is 8 or more characters

type UserRepo

type UserRepo interface {
	// InsertUser commits a User to the storage, returning an error if the user
	// already exists
	InsertUser(user User, secret Secret) (err error)

	// GetUserByName queries the storage for a representation of a User, returning
	// nil and an error if the user does not exist
	GetUserByName(username string) (user User, err error)

	UpdateUserPicture(username string, location string) error
}

UserRepo [sitory] is an interface wrapping the functions for working with user data

Jump to

Keyboard shortcuts

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