database

package
v0.0.0-...-b58d5ac Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ErrDuplicateEntry = 1062
)

Variables

View Source
var (
	ErrRepoMissingRepoID = errors.New("repository id not set")
	ErrIDNotGenerated    = errors.New("id not generated")
	ErrValueNotFound     = errors.New("value not found")
)

Functions

func New

func New() *sqlx.DB

func RefreshVariableCounter

func RefreshVariableCounter()

Types

type Permission

type Permission struct {
	ID           uint32 `db:"id"`
	RepositoryID uint32 `db:"repository_id"`
	UserID       uint32 `db:"user_id"`
}

This table describes the type of access an user have for each repo. By default all users would have read-only access (that is if github api says so). This table only holds records for write access, including the repo owner, which the access entry should be written when they link up the repository

type Repository

type Repository struct {
	ID        uint32    `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"created_at,omitempty"`
	FullName  string    `db:"full_name" json:"full_name"` // ie: hn275/envhub
	UserID    uint32    `db:"user_id" json:"user_id"`
}

type User

type User struct {
	ID           uint32         `db:"id"`
	Login        string         `db:"login"`
	RefreshToken sql.NullString `db:"refresh_token"`
	Email        string         `db:"email"`
}

type Variable

type Variable struct {
	ID           string       `db:"id" json:"id"`
	CreatedAt    time.Time    `db:"created_at" json:"created_at"`
	UpdatedAt    sql.NullTime `db:"updated_at" json:"updated_at"`
	Key          string       `db:"variable_key" json:"key,required"`
	Value        string       `db:"variable_value" json:"value,required"`
	RepositoryID uint32       `db:"repository_id" json:"repository_id,omitempty"`
}

This table contains all the environment variables.

`Value`'s are never saved raw. always the base64 encoding of the ciphered text, and the `ad` is the base64 decoded value of it's ID

func (*Variable) DecryptValue

func (v *Variable) DecryptValue() error

func (*Variable) EncryptValue

func (v *Variable) EncryptValue() error

Cipher value, will panic if `Variable.ID` is an empty value

func (*Variable) GenID

func (v *Variable) GenID() error

Generates an ID for the variable. Panics if `RepositoryID` is not set

schema to generate id:

  • repoID: 8 bytes
  • time: 4 bytes
  • counter var: 2 bytes, reset to 0 every second
  • random var: 2 bytes

Jump to

Keyboard shortcuts

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