Documentation
¶
Index ¶
- Constants
- Variables
- func IsAlphaNumeric(s string) bool
- func NewJSONError(message string) []byte
- func NewJSONValidationError(message string, validation *validation.Validation) []byte
- type Action
- type AuthResponse
- type BaseModel
- func (b *BaseModel) CallStoreBy(verb string, query map[string]interface{}, o interface{}) (err error)
- func (b *BaseModel) CallStoreByRaw(verb string, query map[string]interface{}, res *[]byte) (err error)
- func (b *BaseModel) Delete(query map[string]interface{}) (err error)
- func (b *BaseModel) FindBy(query map[string]interface{}, o interface{}) (err error)
- func (b *BaseModel) GetBy(query map[string]interface{}, o interface{}) (err error)
- func (b *BaseModel) Query(subject, query string) ([]byte, error)
- func (b *BaseModel) Save(o interface{}) (err error)
- func (b *BaseModel) Set(query map[string]interface{}) (err error)
- type Build
- func (b *Build) Delete() (err error)
- func (b *Build) Find(query map[string]interface{}, builds *[]Build) (err error)
- func (b *Build) FindAll(au User, builds *[]Build) (err error)
- func (b *Build) FindByEnvironmentName(name string, builds *[]Build) (err error)
- func (b *Build) FindByID(id string) (err error)
- func (b *Build) FindByName(env string) (builds []Build, err error)
- func (b *Build) FindLastByName(env string) (err error)
- func (b *Build) GetDefinition() ([]byte, error)
- func (b *Build) GetID() string
- func (b *Build) GetMapping() (*graph.Graph, error)
- func (b *Build) GetRawMapping() (map[string]interface{}, error)
- func (b *Build) GetType() string
- func (b *Build) LoadMappingErrors() error
- func (b *Build) Map(data []byte) error
- func (b *Build) RequestCreation(mapping *Mapping) error
- func (b *Build) RequestDeletion(mapping *Mapping) error
- func (b *Build) RequestImport(mapping *Mapping) error
- func (b *Build) Reset() error
- func (b *Build) Save() (err error)
- func (b *Build) Validate() error
- type BuildDetails
- type BuildValidate
- type BuildValidateResponse
- type Config
- type Control
- type ControlDetails
- type Diff
- type Env
- func (e *Env) Delete() (err error)
- func (e *Env) DeleteByName(name string) (err error)
- func (e *Env) Find(query map[string]interface{}, envs *[]Env) (err error)
- func (e *Env) FindAll(au User, envs *[]Env) (err error)
- func (e *Env) FindByID(id int) (err error)
- func (e *Env) FindByName(name string) (err error)
- func (e *Env) FindByProjectID(id int, envs *[]Env) (err error)
- func (e *Env) FindByProjectName(name string, envs *[]Env) (err error)
- func (e *Env) GetID() string
- func (e *Env) GetProject() string
- func (e *Env) GetType() string
- func (e *Env) Map(data []byte) error
- func (e *Env) Redact() error
- func (e *Env) RequestResolve(au User, resolution string) (string, error)
- func (e *Env) RequestReview(au User, resolution string) (string, error)
- func (e *Env) RequestSync(au User) (string, error)
- func (e *Env) Save() (err error)
- func (e *Env) Validate() error
- type Error
- type Group
- type Logger
- type Mapping
- func (m *Mapping) Apply(d *definition.Definition, au User) error
- func (m *Mapping) ChangelogJSON() ([]byte, error)
- func (m *Mapping) Delete(env string, au User) error
- func (m *Mapping) Diff(env, from, to string) error
- func (m *Mapping) Import(env string, filters []string, au User) error
- func (m *Mapping) Submission(d *definition.Definition, au User) error
- func (m *Mapping) ToJSON() ([]byte, error)
- func (m *Mapping) Validate(env string) (*validation.Validation, error)
- type ModelError
- type Notification
- func (n *Notification) Delete() (err error)
- func (n *Notification) FindAll(notifications *[]Notification) (err error)
- func (n *Notification) FindByID(id string, notification *Notification) (err error)
- func (n *Notification) FindByName(name string, notification *Notification) (err error)
- func (n *Notification) Map(data []byte) error
- func (n *Notification) Save() (err error)
- func (n *Notification) Validate() error
- type Policy
- func (l *Policy) Delete() (err error)
- func (l *Policy) FindAll(policys *[]Policy) (err error)
- func (l *Policy) FindByID(id string, policy *Policy) (err error)
- func (l *Policy) FindByNames(names []string, policies *[]Policy) (err error)
- func (l *Policy) GetByName(name string, policy *Policy) (err error)
- func (l *Policy) GetID() string
- func (l *Policy) GetType() string
- func (l *Policy) Map(data []byte) error
- func (l *Policy) Save() (err error)
- func (l *Policy) Validate() error
- type PolicyDocument
- func (p *PolicyDocument) FindAll(documents *[]PolicyDocument) (err error)
- func (p *PolicyDocument) FindByID(name, id string, documents *[]PolicyDocument) (err error)
- func (p *PolicyDocument) FindByPolicy(name string, documents *[]PolicyDocument) (err error)
- func (p *PolicyDocument) FindByPolicyID(id int, documents *[]PolicyDocument) (err error)
- func (p *PolicyDocument) GetByRevision(name, revision string, policy *PolicyDocument) (err error)
- func (p *PolicyDocument) Map(data []byte) error
- func (p *PolicyDocument) Save() (err error)
- func (p *PolicyDocument) Validate() error
- type Profile
- type Project
- func (d *Project) Delete() (err error)
- func (d *Project) Encrypt()
- func (d *Project) Envs() (envs []Env, err error)
- func (d *Project) FindAll(au User, projects *[]Project) (err error)
- func (d *Project) FindByID(id int) (err error)
- func (d *Project) FindByIDs(ids []string, ds *[]Project) (err error)
- func (d *Project) FindByName(name string) (err error)
- func (d *Project) GetID() string
- func (d *Project) GetType() string
- func (d *Project) HasOwner() bool
- func (d *Project) Improve()
- func (d *Project) IsAzure() bool
- func (d *Project) Map(data []byte) error
- func (d *Project) Override(dt Project)
- func (d *Project) Redact() error
- func (d *Project) Save() (err error)
- func (d *Project) Validate() error
- type Role
- func (l *Role) Delete() (err error)
- func (l *Role) FindAll(roles *[]Role) (err error)
- func (l *Role) FindAllByResource(id, r string, roles *[]Role) (err error)
- func (l *Role) FindAllByUser(u string, roles *[]Role) (err error)
- func (l *Role) FindAllByUserAndResource(u, r string, roles *[]Role) (err error)
- func (l *Role) FindAllIDsByUserAndType(u, r string) (ids []string, err error)
- func (l *Role) FindByID(id string, role *Role) (err error)
- func (l *Role) Get(userID, resourceID, resourceType string) (role *Role, err error)
- func (l *Role) Map(data []byte) error
- func (l *Role) ResourceExists() bool
- func (l *Role) Save() (err error)
- func (l *Role) UserExists() bool
- func (l *Role) Validate() error
- type Statistics
- type Usage
- type User
- func (u *User) Authenticate() (*AuthResponse, error)
- func (u *User) CanBeChangedBy(user User) bool
- func (u *User) Delete(id string) (err error)
- func (u *User) EnvsBy(filters map[string]interface{}) ([]Env, error)
- func (u *User) FindAll(users *[]User) (err error)
- func (u *User) FindAllKeyValue() (list map[int]string)
- func (u *User) FindByID(id string, user *User) (err error)
- func (u *User) FindByUserName(name string, user *User) (err error)
- func (u *User) GetAdmin() bool
- func (u *User) GetBuild(id string) (build Env, err error)
- func (u *User) GetID() string
- func (u *User) GetPolicies() (ds []Policy, err error)
- func (u *User) GetProjects() ([]Project, error)
- func (u *User) Improve()
- func (u *User) IsAdmin() bool
- func (u *User) IsMFA() (bool, error)
- func (u *User) IsOwner(resourceType, resourceID string) bool
- func (u *User) IsReader(resourceType, resourceID string) bool
- func (u *User) Map(data []byte) error
- func (u *User) Owns(o resource) bool
- func (u *User) ProjectByName(name string) (d Project, err error)
- func (u *User) Redact(au User)
- func (u *User) Save() (err error)
- func (u *User) SetOwner(o resource) error
- func (u *User) SetReader(o resource) error
- func (u *User) ValidPassword(pw string) bool
- func (u *User) Validate() error
Constants ¶
const ( // SaltSize is the lenght of the salt string SaltSize = 32 // HashSize is the lenght of the hash string HashSize = 64 )
Variables ¶
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 )
var EnvNameSeparator = "/"
EnvNameSeparator : environment name separator
var N akira.Connector
N : Nats connection
Functions ¶
func IsAlphaNumeric ¶
func NewJSONError ¶
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 (*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 : ...
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) FindByEnvironmentName ¶
FindByEnvironmentName : find a builds for the given environment name
func (*Build) FindByName ¶
FindByName : Searches for all builds with by env name
func (*Build) FindLastByName ¶
FindLastByName : Searches for all environments with a name equal to the specified
func (*Build) GetDefinition ¶
GetDefinition : will get a builds mapping
func (*Build) GetMapping ¶
GetMapping : will get a builds mapping
func (*Build) GetRawMapping ¶
GetRawMapping : will get a builds mapping
func (*Build) LoadMappingErrors ¶
LoadMappingErrors : loads all errors from a build and maps them to the build model
func (*Build) RequestCreation ¶
RequestCreation : calls env.create with the given raw message
func (*Build) RequestDeletion ¶
RequestDeletion : calls build.delete with the given raw message
func (*Build) RequestImport ¶
RequestImport : calls build.import with the given raw message
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 ¶
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) GetJWTToken ¶
GetJWTToken : Gets the config value for the key jwt_token
func (*Config) GetServerPort ¶
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 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) DeleteByName ¶
DeleteByName : will delete a env by its name
func (*Env) FindByName ¶
FindByName : Searches for all envs with a name equal to the specified
func (*Env) FindByProjectID ¶
FindByProjectID : find a envs for the given project id
func (*Env) FindByProjectName ¶
FindByProjectName : find a envs for the given project name
func (*Env) GetProject ¶
GetProject : returns the environment's project
func (*Env) Redact ¶
Redact : removes all sensitive fields from the return data before outputting to the user
func (*Env) RequestResolve ¶
RequestResolve : calls environment.resolve with the given raw message
func (*Env) RequestReview ¶
RequestReview : calls build.review with the given raw message
func (*Env) RequestSync ¶
RequestSync : calls environment.sync with the given raw message
type Error ¶
type Error struct {
Message string `json:"message"`
Validation *validation.Validation `json:"validation,omitempty"`
}
Error : the default error type for responses
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
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 ¶
Changelog : returns the mappings changelog if present
func (*Mapping) Submission ¶
func (m *Mapping) Submission(d *definition.Definition, au User) error
Submission : submit a definition
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 (*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) FindByNames ¶
FindByNames : Gets a list by names array
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) FindAll ¶
FindAll : Searches for all entities on the store current user has access to
func (*Project) FindByName ¶
FindByName : Searches for all projects with a name equal to the specified
func (*Project) Redact ¶
Redact : removes all sensitive fields from the return data before outputting to the user
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) FindAllByResource ¶
FindAllByResource : Searches for all roles on the system by user and resource type
func (*Role) FindAllByUser ¶
FindAllByUser : Searches for all roles on the system by user
func (*Role) FindAllByUserAndResource ¶
FindAllByUserAndResource : Searches for all roles on the system by user and resource type
func (*Role) FindAllIDsByUserAndType ¶
FindAllIDsByUserAndType : Searches for all resource_ids by user and resource type
func (*Role) ResourceExists ¶
ResourceExists : check if related resource exists
func (*Role) UserExists ¶
UserExists : check if related user exists
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) FindAllInRange ¶
FindAllInRange : Searches for all usaages on a date range
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 ¶
CanBeChangedBy : Checks if an user has write permissions on another user
func (*User) FindAllKeyValue ¶
FindAllKeyValue : Finds all users on a id:name hash
func (*User) FindByUserName ¶
FindByUserName : find a user for the given username, and maps it on the fiven User struct
func (*User) GetPolicies ¶
GetPolicies : Gets the related user policies if any
func (*User) GetProjects ¶
GetProjects : Gets the related user projects if any
func (*User) ProjectByName ¶
ProjectByName : Gets the related user projects if any
func (*User) Redact ¶
Redact : removes all sensitive fields from the return data before outputting to the user
func (*User) ValidPassword ¶
ValidPassword : checks if a submitted password matches the users password hash