Documentation ¶
Index ¶
- Constants
- Variables
- func AuthFromJSON(data io.Reader) (*Auth, *AppError)
- func CategoryFromJSON(data io.Reader) (*Category, *AppError)
- func ComparePassword(hash string, password string) bool
- func HashPassword(password string) (string, error)
- func NewJSONToken(s string) []byte
- func RegistrationFromJSON(data io.Reader) (*Registration, *AppError)
- func SoftwareFromJSON(data io.Reader) (*Software, *AppError)
- func SoftwarePatchFromJSON(data io.Reader) (*SoftwarePatch, *AppError)
- func SubscriptionFromJSON(data io.Reader) (*Subscription, *AppError)
- func SubscriptionPatchFromJSON(data io.Reader) (*SubscriptionPatch, *AppError)
- func TagFromJSON(data io.Reader) (*Tag, *AppError)
- func TagPatchFromJSON(data io.Reader) (*TagPatch, *AppError)
- func ToJSON(o interface{}) []byte
- func UserFromJSON(data io.Reader) (*User, *AppError)
- func UserPatchFromJSON(data io.Reader) (*UserPatch, *AppError)
- type AppError
- func FromJSON(o interface{}, data io.Reader) *AppError
- func IsValidEmail(email string) *AppError
- func IsValidPassword(password string) *AppError
- func IsValidUsername(username string) *AppError
- func NewAppError(path string, in string, err error, message string, statusCode int) *AppError
- func NewInternalAppError(path string, in string, err error) *AppError
- type Auth
- type Categories
- type Category
- type Info
- type Model
- type Notification
- type Registration
- type Roles
- type Software
- type SoftwarePatch
- type Softwares
- type Subscription
- type SubscriptionPatch
- type Subscriptions
- type Tag
- type TagPatch
- type Tags
- type Token
- type User
- type UserNotifications
- type UserPatch
- type Users
- type Version
Constants ¶
const ( // MinUsernameLength constant MinUsernameLength = 4 // MaxUsernameLength constant MaxUsernameLength = 100 // MinPasswordLength constant MinPasswordLength = 8 // MaxPasswordLength constant MaxPasswordLength = 100 )
const (
// RepositoryTypeGithub constant
RepositoryTypeGithub = "github"
)
const (
// RoleAdmin role key
RoleAdmin = "admin"
)
Variables ¶
var AllowedRepositoryTypes = []string{RepositoryTypeGithub}
AllowedRepositoryTypes contains the list of allowed repository types
Functions ¶
func AuthFromJSON ¶
AuthFromJSON build a auth body from a JSON body
func CategoryFromJSON ¶
CategoryFromJSON build a user from a JSON body
func ComparePassword ¶
ComparePassword compares the hash to a plaintext password
func HashPassword ¶
HashPassword generates a hash using the bcrypt.GenerateFromPassword
func NewJSONToken ¶
NewJSONToken return a json body with the jwt token
func RegistrationFromJSON ¶
func RegistrationFromJSON(data io.Reader) (*Registration, *AppError)
RegistrationFromJSON build a registration from a JSON body
func SoftwareFromJSON ¶
SoftwareFromJSON build a user from a JSON body
func SoftwarePatchFromJSON ¶
func SoftwarePatchFromJSON(data io.Reader) (*SoftwarePatch, *AppError)
SoftwarePatchFromJSON build a user from a JSON body
func SubscriptionFromJSON ¶
func SubscriptionFromJSON(data io.Reader) (*Subscription, *AppError)
SubscriptionFromJSON build a user from a JSON body
func SubscriptionPatchFromJSON ¶
func SubscriptionPatchFromJSON(data io.Reader) (*SubscriptionPatch, *AppError)
SubscriptionPatchFromJSON build a user from a JSON body
func TagFromJSON ¶
TagFromJSON build a user from a JSON body
func TagPatchFromJSON ¶
TagPatchFromJSON build a user from a JSON body
func UserFromJSON ¶
UserFromJSON build a user from a JSON body
Types ¶
type AppError ¶
type AppError struct { Path string `json:"-"` // File path where the error occured In string `json:"-"` // Function name where the error occured InternalError error `json:"-"` // Admin error that will be logged on server side Message string `json:"message"` // End user message that describe the error StatusCode int `json:"status_code"` // HTTP status code that is supposed to be returned if error occurs }
AppError structure
func IsValidEmail ¶
IsValidEmail check wether the email is valid
func IsValidPassword ¶
IsValidPassword check wether the password is valid
func IsValidUsername ¶
IsValidUsername check wether the username is valid
func NewAppError ¶
NewAppError build a new app error
func NewInternalAppError ¶
NewInternalAppError build a new internal app error
type Auth ¶
type Auth struct { Username string `json:"username" binding:"required"` Password string `json:"password" binding:"required"` }
Auth structure
type Categories ¶
type Categories []Category
Categories structure
func (*Categories) ToJSON ¶
func (o *Categories) ToJSON() []byte
ToJSON build the JSON body from the struct
type Category ¶
type Category struct {
Name string `json:"name" binding:"required"`
}
Category structure
type Info ¶
type Info struct { ApplicationName string `json:"application_name"` ApplicationVersion string `json:"application_version"` ApplicationCommit string `json:"application_commit"` ApplicationBuildTime string `json:"application_build_time"` }
Info structure
type Model ¶
type Model struct { CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at"` }
Model structure
type Notification ¶
Notification is composed of a software, a new version and its severity
type Registration ¶
type Registration struct { Username string `json:"username" binding:"required"` Email string `json:"email" binding:"required"` EmailConfirmation string `json:"email_confirmation" binding:"required"` Password string `json:"password" binding:"required"` PasswordConfirmation string `json:"password_confirmation" binding:"required"` }
Registration structure
func (*Registration) IsValid ¶
func (o *Registration) IsValid() *AppError
IsValid return wether the registration data is valid
func (*Registration) NewUser ¶
func (o *Registration) NewUser() *User
NewUser return a new user based on registration data
type Roles ¶
type Roles string
Roles type
type Software ¶
type Software struct { Model ID uint64 `json:"id,omitempty" db:"id"` Name string `json:"name" db:"name"` Description string `json:"description" db:"description"` Repository string `json:"repository" db:"repository"` RepositoryType string `json:"repository_type" db:"repository_type"` Website string `json:"website" db:"website"` Version string `json:"version" db:"version"` VersionUpdatedAt *time.Time `json:"version_updated_at" db:"version_updated_at"` CreatedBy uint64 `json:"created_by" db:"created_by"` }
Software structure
func (*Software) FromPatch ¶
func (o *Software) FromPatch(patch *SoftwarePatch)
FromPatch merge patch user into current user
type SoftwarePatch ¶
type SoftwarePatch struct { Name *string `json:"name,omitempty"` Description *string `json:"description,omitempty"` Repository *string `json:"repository,omitempty"` RepositoryType *string `json:"repository_type,omitempty"` Website *string `json:"website,omitempty"` }
SoftwarePatch structure
func (*SoftwarePatch) NewSoftware ¶
func (o *SoftwarePatch) NewSoftware(userID uint64) *Software
NewSoftware return a new user based on patch data
type Subscription ¶
type Subscription struct { Model UserID uint64 `json:"-" db:"appuser_id"` SoftwareID uint64 `json:"-" db:"software_id"` Severity string `json:"severity" db:"severity"` *Software `json:",inline" db:"-"` Tags *Tags `json:"tags,omitempty" db:"-"` }
Subscription structure
func (*Subscription) FromPatch ¶
func (o *Subscription) FromPatch(patch *SubscriptionPatch)
FromPatch merge patch subscription into current subscription
func (*Subscription) IsValid ¶
func (o *Subscription) IsValid() *AppError
IsValid return wether the software data is valid
func (*Subscription) ToJSON ¶
func (o *Subscription) ToJSON() []byte
ToJSON build the JSON body from a struct
type SubscriptionPatch ¶
type SubscriptionPatch struct {
Severity *string `json:"severity"`
}
SubscriptionPatch structure
func (*SubscriptionPatch) NewSubscription ¶
func (o *SubscriptionPatch) NewSubscription(userID uint64, softwareID uint64) *Subscription
NewSubscription return a new subscription based on patch data
type Subscriptions ¶
type Subscriptions []Subscription
Subscriptions structure
func (*Subscriptions) ToJSON ¶
func (o *Subscriptions) ToJSON() []byte
ToJSON build the JSON body from the struct
type Tag ¶
type Tag struct { Model ID uint64 `json:"id" db:"id"` UserID uint64 `json:"user_id" db:"appuser_id"` Name string `json:"name" db:"name"` Color string `json:"color" db:"color"` TextLight bool `json:"text_light" db:"text_light"` }
Tag structure
type TagPatch ¶
type TagPatch struct { Name *string `json:"name,omitempty"` Color *string `json:"color,omitempty"` TextLight *bool `json:"text_light,omitempty"` }
TagPatch structure
type User ¶
type User struct { Model ID uint64 `json:"id,omitempty" db:"id"` Username string `json:"username" db:"username"` Email string `json:"email" db:"email"` EmailVerified bool `json:"email_verified" db:"email_verified"` Password string `json:"-,omitempty" db:"-"` PasswordHash string `json:"-" db:"password_hash"` Roles Roles `json:"roles" db:"roles"` }
User structure
type UserNotifications ¶
type UserNotifications struct { User *User Notifications []*Notification }
UserNotifications is composed of a user and a list of notifications
type UserPatch ¶
type UserPatch struct { Username *string `json:"name,omitempty"` Email *string `json:"email,omitempty"` Password *string `json:"password,omitempty"` }
UserPatch structure