types

package
v0.0.0-...-f07dfbc Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDatabaseNotInitialized occurs when the database is not initialized and no request can be executed
	ErrDatabaseNotInitialized = errors.New("Database is not initialized")
	// ErrInvalidUserID occurs when the user id is not a valid objectID Hex
	ErrInvalidUserID = errors.New("Invalid User ID")
	// ErrInvalidEntityID occurs when the entity id is not a valid objectID Hex
	ErrInvalidEntityID = errors.New("Invalid Entity ID")
)
View Source
var Deployed = map[int]string{
	-1: "no",
	0:  "yes",
}

Deployed maps the progress codes to their string representation

View Source
var Priority = map[int]string{
	-1: "N/A",
	0:  "P0",
	1:  "P1",
	2:  "P2",
}

Priority maps the progress codes to their string representation

View Source
var Progress = map[int]string{
	-1: "N/A",
	0:  "0%",
	1:  "20%",
	2:  "40%",
	3:  "60%",
	4:  "80%",
	5:  "100%",
}

Progress maps the progress codes to their string representation

Functions

func BasicDelete

func BasicDelete(collection IsCollection, id bson.ObjectId) (bson.ObjectId, error)

BasicDelete is a basic delete of a collection document

func GetEntitiesIds

func GetEntitiesIds(entities []Entity) []bson.ObjectId

GetEntitiesIds get ids of a slice of entities

func UniqIDs

func UniqIDs(ids []bson.ObjectId) []bson.ObjectId

UniqIDs returns the slice of Object id, where an id can appear only once

Types

type BulkImportUsageIndicatorsResults

type BulkImportUsageIndicatorsResults struct {
	All      int                `json:"all"`      // Number of usage indicators to import
	Imported int                `json:"imported"` // Number of usage indicators actually imported (inserted or updated)
	InError  int                `json:"inError"`  // Number of usage indicators not imported because an error happened
	Errors   []IndicatorInError `json:"errors"`   // Occurred errors and its details
}

BulkImportUsageIndicatorsResults is the result of a bulk import of usage indicators

type DocktorURL

type DocktorURL struct {
	DocktorGroupName string `bson:"docktorGroupName" json:"docktorGroupName"`
	DocktorGroupURL  string `bson:"docktorGroupURL" json:"docktorGroupURL"`
}

DocktorURL represents the url of the Docktor project linked to the DAD project

type Entity

type Entity struct {
	ID   bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	Name string        `bson:"name" json:"name"`
	Type EntityType    `bson:"type" json:"type"`
}

Entity represents an Sopra Steria entity

func (Entity) GetID

func (e Entity) GetID() bson.ObjectId

GetID gets the ID of the entity

type EntityRepo

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

EntityRepo wraps all requests to database for accessing entities

func NewEntityRepo

func NewEntityRepo(database *mgo.Database) EntityRepo

NewEntityRepo creates a new entites repo from database This EntityRepo is wrapping all requests with database

func (*EntityRepo) Delete

func (r *EntityRepo) Delete(id bson.ObjectId) (bson.ObjectId, error)

Delete the entity

func (*EntityRepo) Exists

func (r *EntityRepo) Exists(name string) (bool, error)

Exists checks if an entity (name) already exists

func (*EntityRepo) FindAll

func (r *EntityRepo) FindAll() ([]Entity, error)

FindAll get all entities from the database

func (*EntityRepo) FindAllByIDBson

func (r *EntityRepo) FindAllByIDBson(ids []bson.ObjectId) ([]Entity, error)

FindAllByIDBson gets all the entities existing with ids

func (*EntityRepo) FindByID

func (r *EntityRepo) FindByID(id string) (Entity, error)

FindByID get the entity by its id (string version)

func (*EntityRepo) FindByIDBson

func (r *EntityRepo) FindByIDBson(id bson.ObjectId) (Entity, error)

FindByIDBson get the entity by its id (as a bson object)

func (*EntityRepo) Save

func (r *EntityRepo) Save(entity Entity) (Entity, error)

Save updates or create the entity in database

type EntityType

type EntityType string

EntityType identifies the type of the entity

const (
	// BusinessUnitType is the type of entity for business units
	BusinessUnitType EntityType = "businessUnit"
	// ServiceCenterType is the type of entity for services centers
	ServiceCenterType EntityType = "serviceCenter"
)

type ErrorMsg

type ErrorMsg struct {
	Message string `json:"message"`
}

ErrorMsg is a json formated error

func NewErr

func NewErr(message string) ErrorMsg

NewErr is a function used to format errors into json

type FunctionalService

type FunctionalService struct {
	ID                    bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	Name                  string        `bson:"name" json:"name"`
	Translations          Translations  `bson:"translations" json:"translations"`
	Package               string        `bson:"package" json:"package"`
	Position              int           `bson:"position" json:"position"`
	Services              []string      `bson:"services" json:"services"`
	DeclarativeDeployment bool          `bson:"declarativeDeployement" json:"declarativeDeployement"`
}

FunctionalService represents the service

type FunctionalServiceRepo

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

FunctionalServiceRepo wraps all requests to database for accessing functional services

func NewFunctionalServiceRepo

func NewFunctionalServiceRepo(database *mgo.Database) FunctionalServiceRepo

NewFunctionalServiceRepo creates a new entites repo from database This FunctionalServiceRepo is wrapping all requests with database

func (*FunctionalServiceRepo) Delete

Delete the functional service

func (*FunctionalServiceRepo) Exists

func (r *FunctionalServiceRepo) Exists(name, pkg string) (bool, error)

Exists checks if a functional service (name and package) already exists

func (*FunctionalServiceRepo) FindAll

func (r *FunctionalServiceRepo) FindAll() ([]FunctionalService, error)

FindAll get all functional services from the database

func (*FunctionalServiceRepo) FindByID

FindByID get the functional service by its id (string version)

func (*FunctionalServiceRepo) FindByIDBson

FindByIDBson get the functional service by its id (as a bson object)

func (*FunctionalServiceRepo) FindFunctionalServicesDeployByServices

func (r *FunctionalServiceRepo) FindFunctionalServicesDeployByServices(services []string) ([]FunctionalService, error)

FindFunctionalServicesDeployByServices find all functional services associated to

func (*FunctionalServiceRepo) Save

func (r *FunctionalServiceRepo) Save(functionalService FunctionalService) (FunctionalService, error)

Save updates or create the functional service in database

type IndicatorInError

type IndicatorInError struct {
	Indicator UsageIndicator `json:"indicator"`
	Message   string         `json:"message"`
	Index     int            `json:"index"` // Index of usage indicator in error, in original slice
}

IndicatorInError represents an indicator that could not be imported because an error occurred

type IsCollection

type IsCollection interface {
	// contains filtered or unexported methods
}

IsCollection is an interface representing a collection accessing mongod documents

type IsCollectionWithIndexes

type IsCollectionWithIndexes interface {
	IsCollection
	CreateIndexes() error
}

IsCollectionWithIndexes is an interface representing a collection which needs indexes to be created

type IsDocument

type IsDocument interface {
	GetID() bson.ObjectId
}

IsDocument is an interface representing a data being in a collection in Mongo

type Language

type Language struct {
	ID           bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	LanguageCode string        `bson:"languagecode" json:"languagecode"`
}

Language object which contain the language code (as id)

type LanguageRepo

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

LanguageRepo wraps all requests to database for accessing languages

func NewLanguageRepo

func NewLanguageRepo(database *mgo.Database) LanguageRepo

NewLanguageRepo creates a new languages repo from database This LanguageRepo is wrapping languages with database

func (*LanguageRepo) Exists

func (r *LanguageRepo) Exists(languagecode string) (bool, error)

Exists checks if a language (languagecode) already exists

func (*LanguageRepo) FindAll

func (r *LanguageRepo) FindAll() (Languages, error)

FindAll get all languages from the database

func (*LanguageRepo) Save

func (r *LanguageRepo) Save(language Language) (Language, error)

Save updates or creates the language in database

type Languages

type Languages []Language

Languages slice of Language

type Matrix

type Matrix []MatrixLine

Matrix represent a slice of matrix lines

type MatrixLine

type MatrixLine struct {
	Service  bson.ObjectId `bson:"service" json:"service"`
	Deployed string        `bson:"deployed,omitempty" json:"deployed,omitempty"`
	Progress int           `bson:"progress" json:"progress"`
	Goal     int           `bson:"goal" json:"goal"`
	Priority string        `bson:"priority,omitempty" json:"priority,omitempty"`
	DueDate  *time.Time    `bson:"dueDate,omitempty" json:"dueDate,omitempty"`
	Comment  string        `bson:"comment" json:"comment"`
}

MatrixLine represents information of a depending on the functional service

type Project

type Project struct {
	ID             bson.ObjectId                  `bson:"_id,omitempty" json:"id,omitempty"`
	Name           string                         `bson:"name" json:"name"`
	Description    string                         `bson:"description" json:"description"`
	Domain         []string                       `bson:"domain" json:"domain"`
	Client         string                         `bson:"client" json:"client"`
	ProjectManager string                         `bson:"projectManager" json:"projectManager"`
	Deputies       []string                       `bson:"deputies" json:"deputies"`
	BusinessUnit   string                         `bson:"businessUnit" json:"businessUnit"`
	ServiceCenter  []string                       `bson:"serviceCenter" json:"serviceCenter"`
	DocktorURL     `bson:"docktorURL" json:""`    // json is an empty string because we want to flatten the object to avoid client-side null-checks
	TechnicalData  `bson:"technicalData" json:""` // json is an empty string because we want to flatten the object to avoid client-side null-checks
	Matrix         Matrix                         `bson:"matrix" json:"matrix"`
	Created        time.Time                      `bson:"created" json:"created"`
	Updated        time.Time                      `bson:"updated" json:"updated"`
}

Project represents a Sopra Steria project

type ProjectRepo

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

ProjectRepo wraps all requests to database for accessing entities

func NewProjectRepo

func NewProjectRepo(database *mgo.Database) ProjectRepo

NewProjectRepo creates a new projects repo from database This ProjectRepo is wrapping all requests with database

func (*ProjectRepo) Delete

func (r *ProjectRepo) Delete(id bson.ObjectId) (bson.ObjectId, error)

Delete the project

func (*ProjectRepo) FindAll

func (r *ProjectRepo) FindAll() ([]Project, error)

FindAll get all projects from the database

func (*ProjectRepo) FindByEntities

func (r *ProjectRepo) FindByEntities(ids []bson.ObjectId) ([]Project, error)

FindByEntities get all projects with a matching businessUnit or serviceCenter

func (*ProjectRepo) FindByID

func (r *ProjectRepo) FindByID(id string) (Project, error)

FindByID get the project by its id (string version)

func (*ProjectRepo) FindByIDBson

func (r *ProjectRepo) FindByIDBson(id bson.ObjectId) (Project, error)

FindByIDBson get the project by its id (as a bson object)

func (*ProjectRepo) FindByName

func (r *ProjectRepo) FindByName(name string) (Project, error)

FindByName find a project by its name (case insensitive)

func (*ProjectRepo) FindByProjectManagerOrDeputy

func (r *ProjectRepo) FindByProjectManagerOrDeputy(id bson.ObjectId) ([]Project, error)

FindByProjectManagerOrDeputy get all projects with a specific project manager or deputy

func (*ProjectRepo) FindForUser

func (r *ProjectRepo) FindForUser(user User) (Projects, error)

FindForUser returns the projects associated to a user, handling their rights

func (*ProjectRepo) FindModifiableForUser

func (r *ProjectRepo) FindModifiableForUser(user User) (Projects, error)

FindModifiableForUser returns the projects associated to a user, but only projects which are modifiable by him

func (*ProjectRepo) FindWithDocktorGroupURL

func (r *ProjectRepo) FindWithDocktorGroupURL() ([]Project, error)

FindWithDocktorGroupURL returns the projects with a no empty docktor group url

func (*ProjectRepo) RemoveEntity

func (r *ProjectRepo) RemoveEntity(id string) error

RemoveEntity removes an entity (businessUnit or serviceCenter) from a project This is used for cascade deletions

func (*ProjectRepo) Save

func (r *ProjectRepo) Save(project Project) (Project, error)

Save updates or create the functional service in database

func (*ProjectRepo) UpdateDocktorGroupURL

func (r *ProjectRepo) UpdateDocktorGroupURL(id bson.ObjectId, docktorGroupURL, docktorGroupName string) error

UpdateDocktorGroupURL updates Docktor Group URL to project in database

type Projects

type Projects []Project

Projects represents a slice of Project

func (Projects) ContainsBsonID

func (projects Projects) ContainsBsonID(id bson.ObjectId) bool

ContainsBsonID checks that a list of projects contains a certain ObjectID

type Role

type Role string

Role identifies global rights of connected user

const (
	// AdminRole is an administrator role who can do anything
	AdminRole Role = "admin"
	// RIRole is a role who can see projects by entities
	RIRole Role = "ri"
	// PMRole is a role who can see projects
	PMRole Role = "pm"
	// DeputyRole is a substitute role of the PMRole with the same rights
	DeputyRole Role = "deputy"
)

func DefaultRole

func DefaultRole() Role

DefaultRole return the default role of user when he registers

func (Role) IsValid

func (r Role) IsValid() bool

IsValid checks if a role is valid

type TechnicalData

type TechnicalData struct {
	Technologies                   []string `bson:"technologies" json:"technologies"`
	Mode                           string   `bson:"mode" json:"mode"`
	DeliverablesInVersionControl   bool     `bson:"deliverables" json:"deliverables"`
	SpecificationsInVersionControl bool     `bson:"specifications" json:"specifications"`
	SourceCodeInVersionControl     bool     `bson:"sourceCode" json:"sourceCode"`
	VersionControlSystem           string   `bson:"versionControlSystem" json:"versionControlSystem"`
	IsCDKApplicable                bool     `bson:"isCDKApplicable" json:"isCDKApplicable"`
	Explanation                    string   `bson:"explanation" json:"explanation"`
}

TechnicalData contains the technical data of a project

type Technology

type Technology struct {
	ID   bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	Name string        `bson:"name" json:"name"`
}

Technology represents a technology (ie. programming language, software suite, etc.)

type TechnologyRepo

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

TechnologyRepo wraps all requests to database for accessing technologies

func NewTechnologyRepo

func NewTechnologyRepo(database *mgo.Database) TechnologyRepo

NewTechnologyRepo creates a new technologies repo from database This TechnologyRepo is wrapping all requests with database

func (*TechnologyRepo) Exists

func (r *TechnologyRepo) Exists(name string) (bool, error)

Exists checks if a technology (name) already exists

func (*TechnologyRepo) FindAll

func (r *TechnologyRepo) FindAll() ([]Technology, error)

FindAll get all technologies from the database

func (*TechnologyRepo) Save

func (r *TechnologyRepo) Save(technology Technology) (Technology, error)

Save updates or creates the technology in database

type Translation

type Translation struct {
	LanguageCode string `bson:"languagecode" json:"languagecode"`
	Translation  string `bson:"translation" json:"translation"`
}

Translation object contain the language code (as id) and the translation

type Translations

type Translations []Translation

Translations slice of Translation

type UsageIndicator

type UsageIndicator struct {
	ID bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	// Name of the Docktor Group, owner of the service instance which generated this indicator
	DocktorGroup string `bson:"docktorGroup" json:"docktorGroup,omitempty"`
	// Name of the service generating the indicator. e.g. jenkins
	Service string `bson:"service,omitempty" json:"service,omitempty"`
	// Name of the instance of service generating the indicator. e.g. GROUP1-jenkins
	ServiceInstanceName string `bson:"serviceInstance" json:"serviceInstance,omitempty"`
	// Indicator status of the service instance. e.g. active, inactive, undetermined...
	Status string `bson:"status,omitempty" json:"status,omitempty"`
	// Date when the indicator was last updated
	Updated time.Time `bson:"updated,omitempty" json:"updated,omitempty"`
}

UsageIndicator represents a Sopra Steria entity

type UsageIndicatorRepo

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

UsageIndicatorRepo wraps all requests to database for accessing usage indicators

func NewUsageIndicatorRepo

func NewUsageIndicatorRepo(database *mgo.Database) UsageIndicatorRepo

NewUsageIndicatorRepo creates a new usage indicators repo from database This UsageIndicatorRepo is wrapping all requests with database

func (*UsageIndicatorRepo) BulkImport

func (r *UsageIndicatorRepo) BulkImport(usageIndicators []UsageIndicator) (BulkImportUsageIndicatorsResults, error)

BulkImport imports a list of indicators usages It updates existing indicators (with given service and Docktor group name), or create new ones.

func (*UsageIndicatorRepo) CreateIndexes

func (r *UsageIndicatorRepo) CreateIndexes() error

CreateIndexes creates Index

func (*UsageIndicatorRepo) FindAll

func (r *UsageIndicatorRepo) FindAll() ([]UsageIndicator, error)

FindAll get all usage indicators from the database

func (*UsageIndicatorRepo) FindAllFromGroup

func (r *UsageIndicatorRepo) FindAllFromGroup(docktorGroup string) ([]UsageIndicator, error)

FindAllFromGroup get all usage indicators with a given Docktor group

type User

type User struct {
	ID          bson.ObjectId   `bson:"_id,omitempty" json:"id,omitempty"`
	FirstName   string          `bson:"firstName" json:"firstName"`
	LastName    string          `bson:"lastName" json:"lastName"`
	DisplayName string          `bson:"displayName" json:"displayName"`
	Username    string          `bson:"username" json:"username"`
	Email       string          `bson:"email" json:"email"`
	Role        Role            `bson:"role" json:"role"`
	Created     time.Time       `bson:"created" json:"created"`
	Updated     time.Time       `bson:"updated" json:"updated"`
	Entities    []bson.ObjectId `bson:"entities" json:"entities"`
}

User model

func (User) GetID

func (u User) GetID() bson.ObjectId

GetID gets the ID of the user

func (User) HasValidRole

func (u User) HasValidRole() bool

HasValidRole checks the user has a known role

func (User) IsAdmin

func (u User) IsAdmin() bool

IsAdmin checks that the user is an admin, meaning he can do anything on the application.

func (User) IsPMOrDeputy

func (u User) IsPMOrDeputy() bool

IsPMOrDeputy checks that the user is a PM or a Deputy

func (User) IsRI

func (u User) IsRI() bool

IsRI checks that the user is a RI

type UserRepo

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

UserRepo wraps all requests to database for accessing users

func NewUserRepo

func NewUserRepo(database *mgo.Database) UserRepo

NewUserRepo creates a new user repo from database This UserRepo is wrapping all requests with database

func (*UserRepo) Delete

func (s *UserRepo) Delete(id bson.ObjectId) (bson.ObjectId, error)

Delete the user

func (*UserRepo) FindAll

func (s *UserRepo) FindAll() ([]User, error)

FindAll get all users from Dad

func (*UserRepo) FindByID

func (s *UserRepo) FindByID(id string) (User, error)

FindByID get the user by its id (string version)

func (*UserRepo) FindByIDBson

func (s *UserRepo) FindByIDBson(id *bson.ObjectId) (User, error)

FindByIDBson get the user by its id (as a bson object)

func (*UserRepo) FindByUsername

func (s *UserRepo) FindByUsername(username string) (User, error)

FindByUsername finds the user with given username

func (*UserRepo) FindRIWithEntity

func (s *UserRepo) FindRIWithEntity(entitiesIDs []bson.ObjectId) ([]User, error)

FindRIWithEntity finds RI whose matching with serviceCenter and/or businessUnit IDs

func (*UserRepo) RemoveEntity

func (s *UserRepo) RemoveEntity(id bson.ObjectId) error

RemoveEntity removes an entity from a user This is used for cascade deletions

func (*UserRepo) Save

func (s *UserRepo) Save(user User) (User, error)

Save updates or create the user in database

Jump to

Keyboard shortcuts

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