models

package
v0.0.0-...-88c5504 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SaltSize is the lenght of the salt string
	SaltSize = 32
	// HashSize is the lenght of the hash string
	HashSize = 64
)

Variables

View Source
var (
	// InvalidInputCode : provided input is not valid
	InvalidInputCode = "M0001" // => ErrBadReqBody
	// InternalCode : internal error
	InternalCode = "M0002" // => ErrInternal
	// TimeoutCode : A timeout on microservice communication happened
	TimeoutCode = "M0003" // => ErrGatewayTimeout
)
View Source
var EnvNameSeparator = "/"

EnvNameSeparator : environment name separator

N : Nats connection

Functions

func IsAlphaNumeric

func IsAlphaNumeric(s string) bool

func NewJSONError

func NewJSONError(message string) []byte

NewJSONError : constructs a json payload

func NewJSONValidationError

func NewJSONValidationError(message string, validation *validation.Validation) []byte

NewJSONValidationError : constructs a json payload

Types

type Action

type Action struct {
	ID           int    `json:"id"`
	Type         string `json:"type,omitempty"`
	Status       string `json:"status,omitempty"`
	ResourceID   string `json:"resource_id,omitempty"`
	ResourceType string `json:"resource_type,omitempty"`
	Error        string `json:"error,omitempty"`
	Options      struct {
		Filters     []string `json:"filters,omitempty"`
		BuildID     string   `json:"build_id,omitempty"`
		Environment string   `json:"environment,omitempty"`
		Resolution  string   `json:"resolution,omitempty"`
	} `json:"options,omitempty"`
}

Action : action

type AuthResponse

type AuthResponse struct {
	OK      bool   `json:"ok"`
	Token   string `json:"token,omitempty"`
	Message string `json:"message,omitempty"`
}

AuthResponse : Describes an Authenticator service response

type BaseModel

type BaseModel struct {
	Type string
}

BaseModel : Abstraction layer to interact with data stores

func NewBaseModel

func NewBaseModel(t string) *BaseModel

NewBaseModel : Constructor

func (*BaseModel) CallStoreBy

func (b *BaseModel) CallStoreBy(verb string, query map[string]interface{}, o interface{}) (err error)

CallStoreBy : ...

func (*BaseModel) CallStoreByRaw

func (b *BaseModel) CallStoreByRaw(verb string, query map[string]interface{}, res *[]byte) (err error)

CallStoreByRaw : ...

func (*BaseModel) Delete

func (b *BaseModel) Delete(query map[string]interface{}) (err error)

Delete : interface to call component.del on the specific store

func (*BaseModel) FindBy

func (b *BaseModel) FindBy(query map[string]interface{}, o interface{}) (err error)

FindBy : interface to call component.find on the specific store

func (*BaseModel) GetBy

func (b *BaseModel) GetBy(query map[string]interface{}, o interface{}) (err error)

GetBy : interface to call component.get on the specific store

func (*BaseModel) Query

func (b *BaseModel) Query(subject, query string) ([]byte, error)

Query : Allows a free query by subject

func (*BaseModel) Save

func (b *BaseModel) Save(o interface{}) (err error)

Save : interface to call component.set on the specific store

func (*BaseModel) Set

func (b *BaseModel) Set(query map[string]interface{}) (err error)

Set : interface to call component.set on the specific store

type Build

type Build struct {
	ID            string                 `json:"id"`
	EnvironmentID int                    `json:"environment_id"`
	UserID        int                    `json:"user_id"`
	Username      string                 `json:"user_name"`
	Type          string                 `json:"type"`
	Status        string                 `json:"status"`
	Definition    string                 `json:"definition"`
	Mapping       map[string]interface{} `json:"mapping"`
	Validation    *BuildValidateResponse `json:"validation,omitempty"`
	Errors        []string               `json:"errors,omitempty"`
	CreatedAt     time.Time              `json:"created_at"`
	UpdatedAt     time.Time              `json:"updated_at"`
}

Build : holds the build response from service store

func (*Build) Delete

func (b *Build) Delete() (err error)

Delete : will delete a builds by its id

func (*Build) Find

func (b *Build) Find(query map[string]interface{}, builds *[]Build) (err error)

Find : Searches for all builds with filters

func (*Build) FindAll

func (b *Build) FindAll(au User, builds *[]Build) (err error)

FindAll : Searches for all builds on the store current user has access to

func (*Build) FindByEnvironmentName

func (b *Build) FindByEnvironmentName(name string, builds *[]Build) (err error)

FindByEnvironmentName : find a builds for the given environment name

func (*Build) FindByID

func (b *Build) FindByID(id string) (err error)

FindByID : Gets a model by its id

func (*Build) FindByName

func (b *Build) FindByName(env string) (builds []Build, err error)

FindByName : Searches for all builds with by env name

func (*Build) FindLastByName

func (b *Build) FindLastByName(env string) (err error)

FindLastByName : Searches for all environments with a name equal to the specified

func (*Build) GetDefinition

func (b *Build) GetDefinition() ([]byte, error)

GetDefinition : will get a builds mapping

func (*Build) GetID

func (b *Build) GetID() string

GetID : ID getter

func (*Build) GetMapping

func (b *Build) GetMapping() (*graph.Graph, error)

GetMapping : will get a builds mapping

func (*Build) GetRawMapping

func (b *Build) GetRawMapping() (map[string]interface{}, error)

GetRawMapping : will get a builds mapping

func (*Build) GetType

func (b *Build) GetType() string

GetType : Gets the resource type

func (*Build) LoadMappingErrors

func (b *Build) LoadMappingErrors() error

LoadMappingErrors : loads all errors from a build and maps them to the build model

func (*Build) Map

func (b *Build) Map(data []byte) error

Map : maps a build from a request's body and validates the input

func (*Build) RequestCreation

func (b *Build) RequestCreation(mapping *Mapping) error

RequestCreation : calls env.create with the given raw message

func (*Build) RequestDeletion

func (b *Build) RequestDeletion(mapping *Mapping) error

RequestDeletion : calls build.delete with the given raw message

func (*Build) RequestImport

func (b *Build) RequestImport(mapping *Mapping) error

RequestImport : calls build.import with the given raw message

func (*Build) Reset

func (b *Build) Reset() error

Reset : will reset the builds status to errored

func (*Build) Save

func (b *Build) Save() (err error)

Save : calls build.set with the marshalled

func (*Build) Validate

func (b *Build) Validate() error

Validate the env

type BuildDetails

type BuildDetails struct {
	ID         string                 `json:"id,omitempty"`
	Status     string                 `json:"status,omitempty"`
	Validation *validation.Validation `json:"validation"`
}

BuildDetails : for returning build information to the user

type BuildValidate

type BuildValidate struct {
	Mapping  *Mapping `json:"mapping"`
	Policies []Policy `json:"policies"`
}

BuildValidate describes a request to the build validate service.

type BuildValidateResponse

type BuildValidateResponse struct {
	Version    string     `json:"version"`
	Controls   []Control  `json:"controls"`
	Profiles   []Profile  `json:"profiles"`
	Statistics Statistics `json:"statistics"`
}

BuildValidateReponse describes a response from the build validate service.

func (*BuildValidateResponse) Passed

func (b *BuildValidateResponse) Passed() bool

Passed : returns true if validation rules passed

type Config

type Config struct {
	JWT string `json:"jwt_token"`
}

Config : TODO

func (*Config) FindByKey

func (c *Config) FindByKey(key string) (value string, err error)

FindByKey : Searches for a specific config by key

func (*Config) GetJWTToken

func (c *Config) GetJWTToken() (token string, err error)

GetJWTToken : Gets the config value for the key jwt_token

func (*Config) GetNatsURI

func (c *Config) GetNatsURI() string

GetNatsURI : Gets the nats uri

func (*Config) GetServerPort

func (c *Config) GetServerPort() (token string)

GetServerPort : Get the port to serve from

type Control

type Control struct {
	ID        string  `json:"id"`
	ProfileID string  `json:"profile_id"`
	Status    string  `json:"status"`
	CodeDesc  string  `json:"code_desc"`
	RunTime   float64 `json:"run_time"`
	StartTime string  `json:"start_time"`
	Message   string  `json:"message"`
}

Control describes an individual test within a build validation.

type ControlDetails

type ControlDetails struct {
	ID             string            `json:"id"`
	Title          string            `json:"title"`
	Description    string            `json:"desc"`
	Impact         float32           `json:"impact"`
	References     []string          `json:"refs"`
	Tags           map[string]string `json:"tags"`
	Code           string            `json:"code"`
	Results        []Control         `json:"results"`
	Groups         []Group           `json:"groups"`
	Attributes     []string          `json:"attribues"`
	SHA256         string            `json:"sha256"`
	SourceLocation struct {
		Reference string `json:"ref"`
		Line      int    `json:"line"`
	} `json:"source_location"`
}

ControlDetails describes additional information about a control

type Diff

type Diff struct {
	FromID string `json:"from_id,omitempty"`
	ToID   string `json:"to_id,omitempty"`
}

Diff : diff request

type Env

type Env struct {
	ID          int                    `json:"id"`
	ProjectID   int                    `json:"project_id"`
	Project     string                 `json:"project,omitempty"`
	Provider    string                 `json:"provider,omitempty"`
	Name        string                 `json:"name"`
	Type        string                 `json:"type"`
	Status      string                 `json:"status"`
	Options     map[string]interface{} `json:"options,omitempty"`
	Schedules   map[string]interface{} `json:"schedules,omitempty"`
	Credentials map[string]interface{} `json:"credentials,omitempty"`
	Builds      []Build                `json:"builds,omitempty"`
	Members     []Role                 `json:"members,omitempty"`
	CreatedAt   string                 `json:"created_at,omitempty"`
	UpdatedAt   string                 `json:"updated_at,omitempty"`
}

Env holds the environment response from service-store

func (*Env) Delete

func (e *Env) Delete() (err error)

Delete : will delete a env by its id

func (*Env) DeleteByName

func (e *Env) DeleteByName(name string) (err error)

DeleteByName : will delete a env by its name

func (*Env) Find

func (e *Env) Find(query map[string]interface{}, envs *[]Env) (err error)

Find : Searches for all envs with filters

func (*Env) FindAll

func (e *Env) FindAll(au User, envs *[]Env) (err error)

FindAll : Searches for all envs s on the store current user has access to

func (*Env) FindByID

func (e *Env) FindByID(id int) (err error)

FindByID : Gets a model by its id

func (*Env) FindByName

func (e *Env) FindByName(name string) (err error)

FindByName : Searches for all envs with a name equal to the specified

func (*Env) FindByProjectID

func (e *Env) FindByProjectID(id int, envs *[]Env) (err error)

FindByProjectID : find a envs for the given project id

func (*Env) FindByProjectName

func (e *Env) FindByProjectName(name string, envs *[]Env) (err error)

FindByProjectName : find a envs for the given project name

func (*Env) GetID

func (e *Env) GetID() string

GetID : ID getter

func (*Env) GetProject

func (e *Env) GetProject() string

GetProject : returns the environment's project

func (*Env) GetType

func (e *Env) GetType() string

GetType : Gets the resource type

func (*Env) Map

func (e *Env) Map(data []byte) error

Map : maps a env from a request's body and validates the input

func (*Env) Redact

func (e *Env) Redact() error

Redact : removes all sensitive fields from the return data before outputting to the user

func (*Env) RequestResolve

func (e *Env) RequestResolve(au User, resolution string) (string, error)

RequestResolve : calls environment.resolve with the given raw message

func (*Env) RequestReview

func (e *Env) RequestReview(au User, resolution string) (string, error)

RequestReview : calls build.review with the given raw message

func (*Env) RequestSync

func (e *Env) RequestSync(au User) (string, error)

RequestSync : calls environment.sync with the given raw message

func (*Env) Save

func (e *Env) Save() (err error)

Save : calls env.set with the marshalled

func (*Env) Validate

func (e *Env) Validate() error

Validate the env

type Error

type Error struct {
	Message    string                 `json:"message"`
	Validation *validation.Validation `json:"validation,omitempty"`
}

Error : the default error type for responses

func (Error) ToJSON

func (e Error) ToJSON() []byte

ToJSON : marshals error to json

type Group

type Group struct {
	ID       string   `json:"id"`
	Title    string   `json:"title"`
	Controls []string `json:"controls"`
}

type Logger

type Logger struct {
	Type        string `json:"type"`
	Logfile     string `json:"logfile"`
	Hostname    string `json:"hostname"`
	Port        int    `json:"port"`
	Timeout     int    `json:"timeout"`
	Token       string `json:"token"`
	Environment string `json:"environment"`
	UUID        string `json:"uuid"`
}

Logger holds the logger response from logger

func (*Logger) Delete

func (l *Logger) Delete(logger string) (err error)

Delete : will delete a logger by its type

func (*Logger) FindAll

func (l *Logger) FindAll(loggers *[]Logger) (err error)

FindAll : Searches for all loggers on the system

func (*Logger) Map

func (l *Logger) Map(data []byte) error

Map : maps a datacenter from a request's body and validates the input

func (*Logger) Save

func (l *Logger) Save() (err error)

Save : calls logger.set with the marshalled current logger

func (*Logger) Validate

func (l *Logger) Validate() error

Validate : validates the logger

type Mapping

type Mapping map[string]interface{}

Mapping : graph mapping

func (*Mapping) Apply

func (m *Mapping) Apply(d *definition.Definition, au User) error

Apply : apply a definition

func (*Mapping) ChangelogJSON

func (m *Mapping) ChangelogJSON() ([]byte, error)

Changelog : returns the mappings changelog if present

func (*Mapping) Delete

func (m *Mapping) Delete(env string, au User) error

Delete : get mapping for deleting an environment

func (*Mapping) Diff

func (m *Mapping) Diff(env, from, to string) error

Diff : diff two builds by id

func (*Mapping) Import

func (m *Mapping) Import(env string, filters []string, au User) error

Import : get mapping for importing an environment

func (*Mapping) Submission

func (m *Mapping) Submission(d *definition.Definition, au User) error

Submission : submit a definition

func (*Mapping) ToJSON

func (m *Mapping) ToJSON() ([]byte, error)

ToJSON : serializes the mapping to json

func (*Mapping) Validate

func (m *Mapping) Validate(env string) (*validation.Validation, error)

Validate : checks a map against any attached policies.

type ModelError

type ModelError struct {
	// contains filtered or unexported fields
}

ModelError : Specific model error

func NewError

func NewError(c, s string) *ModelError

NewError : Returns new model error

func (*ModelError) Code

func (e *ModelError) Code() string

Code : Returns the error code

func (*ModelError) Error

func (e *ModelError) Error() string

Error : Returns the error string, and implements go error interface

type Notification

type Notification struct {
	ID      int      `json:"id"`
	Name    string   `json:"name"`
	Type    string   `json:"type"`
	Config  string   `json:"config"`
	Sources []string `json:"sources"`
}

Notification holds the notification response from notification

func (*Notification) Delete

func (n *Notification) Delete() (err error)

Delete : will delete a notification by its type

func (*Notification) FindAll

func (n *Notification) FindAll(notifications *[]Notification) (err error)

FindAll : Searches for all notifications on the system

func (*Notification) FindByID

func (n *Notification) FindByID(id string, notification *Notification) (err error)

FindByID : Gets a notification by ID

func (*Notification) FindByName

func (n *Notification) FindByName(name string, notification *Notification) (err error)

FindByName : Searches for all notifications with a name equal to the specified

func (*Notification) Map

func (n *Notification) Map(data []byte) error

Map : maps a datacenter from a request's body and validates the input

func (*Notification) Save

func (n *Notification) Save() (err error)

Save : calls notification.set with the marshalled current notification

func (*Notification) Validate

func (n *Notification) Validate() error

Validate : validates the notification

type Policy

type Policy struct {
	ID           int      `json:"id"`
	Name         string   `json:"name"`
	Revisions    []int    `json:"revisions"`
	Environments []string `json:"environments"`
	Username     string   `json:"username"`
}

Policy holds the policy response from policy

func (*Policy) Delete

func (l *Policy) Delete() (err error)

Delete : will delete a policy by its type

func (*Policy) FindAll

func (l *Policy) FindAll(policys *[]Policy) (err error)

FindAll : Searches for all policys on the system

func (*Policy) FindByID

func (l *Policy) FindByID(id string, policy *Policy) (err error)

FindByID : Gets a policy by ID

func (*Policy) FindByNames

func (l *Policy) FindByNames(names []string, policies *[]Policy) (err error)

FindByNames : Gets a list by names array

func (*Policy) GetByName

func (l *Policy) GetByName(name string, policy *Policy) (err error)

GetByName : Searches for all policys with a name equal to the specified

func (*Policy) GetID

func (l *Policy) GetID() string

GetID : get the object id

func (*Policy) GetType

func (l *Policy) GetType() string

GetType : get the object type

func (*Policy) Map

func (l *Policy) Map(data []byte) error

Map : maps a datacenter from a request's body and validates the input

func (*Policy) Save

func (l *Policy) Save() (err error)

Save : calls policy.set with the marshalled current policy

func (*Policy) Validate

func (l *Policy) Validate() error

Validate the policy

type PolicyDocument

type PolicyDocument struct {
	ID         int    `json:"id"`
	PolicyID   int    `json:"policy_id"`
	Revision   int    `json:"revision"`
	Username   string `json:"username"`
	Definition string `json:"definition"`
	CreatedAt  string `json:"created_at"`
}

PolicyDocument holds the policy revision response from policy store

func (*PolicyDocument) FindAll

func (p *PolicyDocument) FindAll(documents *[]PolicyDocument) (err error)

FindAll : Searches for all policys on the system

func (*PolicyDocument) FindByID

func (p *PolicyDocument) FindByID(name, id string, documents *[]PolicyDocument) (err error)

FindByID : Gets a policy revision by policy name and id

func (*PolicyDocument) FindByPolicy

func (p *PolicyDocument) FindByPolicy(name string, documents *[]PolicyDocument) (err error)

FindByID : Gets a policy revision by policy name and id

func (*PolicyDocument) FindByPolicyID

func (p *PolicyDocument) FindByPolicyID(id int, documents *[]PolicyDocument) (err error)

FindByID : Gets a policy revision by policy name and id

func (*PolicyDocument) GetByRevision

func (p *PolicyDocument) GetByRevision(name, revision string, policy *PolicyDocument) (err error)

FindByID : Gets a policy revision by policy name and revision number

func (*PolicyDocument) Map

func (p *PolicyDocument) Map(data []byte) error

Map : maps a policy document revision from a request's body and validates the input

func (*PolicyDocument) Save

func (p *PolicyDocument) Save() (err error)

func (*PolicyDocument) Validate

func (p *PolicyDocument) Validate() error

Validate : validates the policy

type Profile

type Profile struct {
	Supports []string         `json:"supports"`
	Title    string           `json:"title"`
	Name     string           `json:"name"`
	Controls []ControlDetails `json:"controls"`
}

Profile describes the policy document and its test results

type Project

type Project struct {
	ID           int                    `json:"id"`
	Name         string                 `json:"name"`
	Type         string                 `json:"type"`
	Credentials  map[string]interface{} `json:"credentials,omitempty"`
	Environments []string               `json:"environments,omitempty"`
	Members      []Role                 `json:"members,omitempty"`
}

Project holds the project response from datacenter-store

func (*Project) Delete

func (d *Project) Delete() (err error)

Delete : will delete a project by its id

func (*Project) Encrypt

func (d *Project) Encrypt()

Encrypt : encrypts sensible data

func (*Project) Envs

func (d *Project) Envs() (envs []Env, err error)

Envs : Get the envs related with current project

func (*Project) FindAll

func (d *Project) FindAll(au User, projects *[]Project) (err error)

FindAll : Searches for all entities on the store current user has access to

func (*Project) FindByID

func (d *Project) FindByID(id int) (err error)

FindByID : Gets a model by its id

func (*Project) FindByIDs

func (d *Project) FindByIDs(ids []string, ds *[]Project) (err error)

FindByIDs : Gets a model by its id

func (*Project) FindByName

func (d *Project) FindByName(name string) (err error)

FindByName : Searches for all projects with a name equal to the specified

func (*Project) GetID

func (d *Project) GetID() string

GetID : ID getter

func (*Project) GetType

func (d *Project) GetType() string

GetType : Gets the resource type

func (*Project) HasOwner

func (d *Project) HasOwner() bool

HasOwner : returns true if there is at least one project owner

func (*Project) Improve

func (d *Project) Improve()

Improve : adds extra data to this entity

func (*Project) IsAzure

func (d *Project) IsAzure() bool

IsAzure : check if the current project is of type azure

func (*Project) Map

func (d *Project) Map(data []byte) error

Map : maps a project from a request's body and validates the input

func (*Project) Override

func (d *Project) Override(dt Project)

Override : override not empty parameters with the given project ones

func (*Project) Redact

func (d *Project) Redact() error

Redact : removes all sensitive fields from the return data before outputting to the user

func (*Project) Save

func (d *Project) Save() (err error)

Save : calls datacenter.set with the marshalled current entity

func (*Project) Validate

func (d *Project) Validate() error

Validate the project

type Role

type Role struct {
	ID           uint   `json:"id"`
	UserID       string `json:"user_id"`
	ResourceID   string `json:"resource_id"`
	ResourceType string `json:"resource_type"`
	Role         string `json:"role"`
}

Role holds the role response from role

func (*Role) Delete

func (l *Role) Delete() (err error)

Delete : will delete a role by its type

func (*Role) FindAll

func (l *Role) FindAll(roles *[]Role) (err error)

FindAll : Searches for all roles on the system

func (*Role) FindAllByResource

func (l *Role) FindAllByResource(id, r string, roles *[]Role) (err error)

FindAllByResource : Searches for all roles on the system by user and resource type

func (*Role) FindAllByUser

func (l *Role) FindAllByUser(u string, roles *[]Role) (err error)

FindAllByUser : Searches for all roles on the system by user

func (*Role) FindAllByUserAndResource

func (l *Role) FindAllByUserAndResource(u, r string, roles *[]Role) (err error)

FindAllByUserAndResource : Searches for all roles on the system by user and resource type

func (*Role) FindAllIDsByUserAndType

func (l *Role) FindAllIDsByUserAndType(u, r string) (ids []string, err error)

FindAllIDsByUserAndType : Searches for all resource_ids by user and resource type

func (*Role) FindByID

func (l *Role) FindByID(id string, role *Role) (err error)

FindByID : Gets a role by ID

func (*Role) Get

func (l *Role) Get(userID, resourceID, resourceType string) (role *Role, err error)

Get : will delete a role by its type

func (*Role) Map

func (l *Role) Map(data []byte) error

Map : maps a role from a request's body and validates the input

func (*Role) ResourceExists

func (l *Role) ResourceExists() bool

ResourceExists : check if related resource exists

func (*Role) Save

func (l *Role) Save() (err error)

Save : calls role.set with the marshalled current role

func (*Role) UserExists

func (l *Role) UserExists() bool

UserExists : check if related user exists

func (*Role) Validate

func (l *Role) Validate() error

Validate : validates the role

type Statistics

type Statistics struct {
	Duration float64 `json:"duration"`
}

Statistics describes stats for the build validate service.

type Usage

type Usage struct {
	ID      uint   `json:"id" gorm:"primary_key"`
	Service string `json:"service"`
	Name    string `json:"name"`
	Type    string `json:"type"`
	From    int64  `json:"from"`
	To      int64  `json:"to"`
}

Usage : Usage-store entity

func (*Usage) FindAll

func (l *Usage) FindAll(usages *[]Usage) (err error)

FindAll : Searches for all usaages on the system

func (*Usage) FindAllInRange

func (l *Usage) FindAllInRange(from, to int64, usages *[]Usage) (err error)

FindAllInRange : Searches for all usaages on a date range

func (*Usage) Map

func (l *Usage) Map(data []byte) error

Map : maps a datacenter from a request's body and validates the input

func (*Usage) Validate

func (l *Usage) Validate() error

Validate : validates the usage

type User

type User struct {
	ID                 int     `json:"id"`
	Username           string  `json:"username"`
	Password           *string `json:"password,omitempty"`
	OldPassword        *string `json:"oldpassword,omitempty"`
	Salt               string  `json:"salt,omitempty"`
	Admin              *bool   `json:"admin,omitempty"`
	MFA                *bool   `json:"mfa,omitempty"`
	MFASecret          string  `json:"mfa_secret,omitempty"`
	VerificationCode   string  `json:"verification_code,omitempty"`
	EnvMemberships     []Role  `json:"env_memberships,omitempty"`
	ProjectMemberships []Role  `json:"project_memberships,omitempty"`
	Type               string  `json:"type,omitempty"`
	Disabled           *bool   `json:"disabled,omitempty"`
}

User holds the user response from user-store

func (*User) Authenticate

func (u *User) Authenticate() (*AuthResponse, error)

Authenticate verifies user credentials

func (*User) CanBeChangedBy

func (u *User) CanBeChangedBy(user User) bool

CanBeChangedBy : Checks if an user has write permissions on another user

func (*User) Delete

func (u *User) Delete(id string) (err error)

Delete : will delete a user by its id

func (*User) EnvsBy

func (u *User) EnvsBy(filters map[string]interface{}) ([]Env, error)

EnvsBy : Get authorized envs by any filter

func (*User) FindAll

func (u *User) FindAll(users *[]User) (err error)

FindAll : Searches for all users on the store current user has access to

func (*User) FindAllKeyValue

func (u *User) FindAllKeyValue() (list map[int]string)

FindAllKeyValue : Finds all users on a id:name hash

func (*User) FindByID

func (u *User) FindByID(id string, user *User) (err error)

FindByID : Searches a user by ID on the store current user has access to

func (*User) FindByUserName

func (u *User) FindByUserName(name string, user *User) (err error)

FindByUserName : find a user for the given username, and maps it on the fiven User struct

func (*User) GetAdmin

func (u *User) GetAdmin() bool

GetAdmin : admin getter

func (*User) GetBuild

func (u *User) GetBuild(id string) (build Env, err error)

GetBuild : Gets a specific build if authorized

func (*User) GetID

func (u *User) GetID() string

GetID : ID getter

func (*User) GetPolicies

func (u *User) GetPolicies() (ds []Policy, err error)

GetPolicies : Gets the related user policies if any

func (*User) GetProjects

func (u *User) GetProjects() ([]Project, error)

GetProjects : Gets the related user projects if any

func (*User) Improve

func (u *User) Improve()

Improve : adds extra data

func (*User) IsAdmin

func (u *User) IsAdmin() bool

IsAdmin : Check if a user is admin or not

func (*User) IsMFA

func (u *User) IsMFA() (bool, error)

IsMFA checks if a user has Multi-Factor authentication enabled

func (*User) IsOwner

func (u *User) IsOwner(resourceType, resourceID string) bool

IsOwner : check if is the owner of a specific resource

func (*User) IsReader

func (u *User) IsReader(resourceType, resourceID string) bool

IsReader : check if has reader permissions on a specific resource

func (*User) Map

func (u *User) Map(data []byte) error

Map a user from a request's body and validates the input

func (*User) Owns

func (u *User) Owns(o resource) bool

Owns : Checks if the user owns a specific resource

func (*User) ProjectByName

func (u *User) ProjectByName(name string) (d Project, err error)

ProjectByName : Gets the related user projects if any

func (*User) Redact

func (u *User) Redact(au User)

Redact : removes all sensitive fields from the return data before outputting to the user

func (*User) Save

func (u *User) Save() (err error)

Save : calls user.set with the marshalled current user

func (*User) SetOwner

func (u *User) SetOwner(o resource) error

SetOwner : ...

func (*User) SetReader

func (u *User) SetReader(o resource) error

SetReader : ...

func (*User) ValidPassword

func (u *User) ValidPassword(pw string) bool

ValidPassword : checks if a submitted password matches the users password hash

func (*User) Validate

func (u *User) Validate() error

Validate checks user input details for missing values and invalid characters

Jump to

Keyboard shortcuts

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