gorm

package
v0.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProjectRepository

func NewProjectRepository(db *gorm.DB) repository.ProjectRepository

NewProjectRepository returns a ProjectRepository which uses gorm.DB for querying the database

func NewRepoClientRepository

func NewRepoClientRepository(db *gorm.DB, key *[32]byte) repository.RepoClientRepository

NewRepoClientRepository returns a RepoClientRepository which uses gorm.DB for querying the database. It accepts an encryption key to encrypt sensitive data

func NewRepository

func NewRepository(db *gorm.DB, key *[32]byte) *repository.Repository

NewRepository returns a Repository which uses gorm.DB for querying the database

func NewServiceAccountRepository

func NewServiceAccountRepository(db *gorm.DB, key *[32]byte) repository.ServiceAccountRepository

NewServiceAccountRepository returns a ServiceAccountRepository which uses gorm.DB for querying the database. It accepts an encryption key to encrypt sensitive data

func NewSessionRepository

func NewSessionRepository(db *gorm.DB) repository.SessionRepository

NewSessionRepository returns pointer to repo along with the db

func NewUserRepository

func NewUserRepository(db *gorm.DB) repository.UserRepository

NewUserRepository returns a DefaultUserRepository which uses gorm.DB for querying the database

Types

type ProjectRepository

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

ProjectRepository uses gorm.DB for querying the database

func (*ProjectRepository) CreateProject

func (repo *ProjectRepository) CreateProject(project *models.Project) (*models.Project, error)

CreateProject creates a new project

func (*ProjectRepository) CreateProjectRole

func (repo *ProjectRepository) CreateProjectRole(project *models.Project, role *models.Role) (*models.Role, error)

CreateProjectRole appends a role to the existing array of roles

func (*ProjectRepository) DeleteProject

func (repo *ProjectRepository) DeleteProject(project *models.Project) (*models.Project, error)

DeleteProject deletes a project (marking deleted in the db)

func (*ProjectRepository) ListProjectsByUserID

func (repo *ProjectRepository) ListProjectsByUserID(userID uint) ([]*models.Project, error)

ListProjectsByUserID lists projects where a user has an associated role

func (*ProjectRepository) ReadProject

func (repo *ProjectRepository) ReadProject(id uint) (*models.Project, error)

ReadProject gets a projects specified by a unique id

type RepoClientRepository

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

RepoClientRepository uses gorm.DB for querying the database

func (*RepoClientRepository) CreateRepoClient

func (repo *RepoClientRepository) CreateRepoClient(rc *models.RepoClient) (*models.RepoClient, error)

CreateRepoClient creates a new repo client and appends it to the in-memory list

func (*RepoClientRepository) DecryptRepoClientData

func (repo *RepoClientRepository) DecryptRepoClientData(
	rc *models.RepoClient,
	key *[32]byte,
) error

DecryptRepoClientData will decrypt the repo client tokens before returning it from the DB

func (*RepoClientRepository) EncryptRepoClientData

func (repo *RepoClientRepository) EncryptRepoClientData(
	rc *models.RepoClient,
	key *[32]byte,
) error

EncryptRepoClientData will encrypt the repo client tokens before writing to the DB

func (*RepoClientRepository) ListRepoClientsByProjectID

func (repo *RepoClientRepository) ListRepoClientsByProjectID(projectID uint) ([]*models.RepoClient, error)

ListRepoClientsByProjectID returns a list of repo clients that match a project id

func (*RepoClientRepository) ReadRepoClient

func (repo *RepoClientRepository) ReadRepoClient(id uint) (*models.RepoClient, error)

ReadRepoClient returns a repo client by id

type ServiceAccountRepository

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

ServiceAccountRepository uses gorm.DB for querying the database

func (*ServiceAccountRepository) CreateServiceAccount

func (repo *ServiceAccountRepository) CreateServiceAccount(
	sa *models.ServiceAccount,
) (*models.ServiceAccount, error)

CreateServiceAccount creates a new servicea account

func (*ServiceAccountRepository) CreateServiceAccountCandidate

func (repo *ServiceAccountRepository) CreateServiceAccountCandidate(
	saCandidate *models.ServiceAccountCandidate,
) (*models.ServiceAccountCandidate, error)

CreateServiceAccountCandidate creates a new service account candidate

func (*ServiceAccountRepository) DecryptServiceAccountCandidateData

func (repo *ServiceAccountRepository) DecryptServiceAccountCandidateData(
	saCandidate *models.ServiceAccountCandidate,
	key *[32]byte,
) error

DecryptServiceAccountCandidateData will decrypt the service account candidate data before returning it from the DB

func (*ServiceAccountRepository) DecryptServiceAccountData

func (repo *ServiceAccountRepository) DecryptServiceAccountData(
	sa *models.ServiceAccount,
	key *[32]byte,
) error

DecryptServiceAccountData will decrypt the user's service account data before returning it from the DB

func (*ServiceAccountRepository) EncryptServiceAccountCandidateData

func (repo *ServiceAccountRepository) EncryptServiceAccountCandidateData(
	saCandidate *models.ServiceAccountCandidate,
	key *[32]byte,
) error

EncryptServiceAccountCandidateData will encrypt the service account candidate data before writing to the DB

func (*ServiceAccountRepository) EncryptServiceAccountData

func (repo *ServiceAccountRepository) EncryptServiceAccountData(
	sa *models.ServiceAccount,
	key *[32]byte,
) error

EncryptServiceAccountData will encrypt the user's service account data before writing to the DB

func (*ServiceAccountRepository) ListServiceAccountCandidatesByProjectID

func (repo *ServiceAccountRepository) ListServiceAccountCandidatesByProjectID(
	projectID uint,
) ([]*models.ServiceAccountCandidate, error)

ListServiceAccountCandidatesByProjectID finds all service account candidates for a given project id

func (*ServiceAccountRepository) ListServiceAccountsByProjectID

func (repo *ServiceAccountRepository) ListServiceAccountsByProjectID(
	projectID uint,
) ([]*models.ServiceAccount, error)

ListServiceAccountsByProjectID finds all service accounts for a given project id

func (*ServiceAccountRepository) ReadServiceAccount

func (repo *ServiceAccountRepository) ReadServiceAccount(
	id uint,
) (*models.ServiceAccount, error)

ReadServiceAccount finds a service account by id

func (*ServiceAccountRepository) ReadServiceAccountCandidate

func (repo *ServiceAccountRepository) ReadServiceAccountCandidate(
	id uint,
) (*models.ServiceAccountCandidate, error)

ReadServiceAccountCandidate finds a service account candidate by id

func (*ServiceAccountRepository) UpdateServiceAccountCandidateCreatedSAID

func (repo *ServiceAccountRepository) UpdateServiceAccountCandidateCreatedSAID(
	id uint,
	createdSAID uint,
) (*models.ServiceAccountCandidate, error)

UpdateServiceAccountCandidateCreatedSAID updates the CreatedServiceAccountID for a candidate, after the candidate has been resolved.

func (*ServiceAccountRepository) UpdateServiceAccountTokenCache

func (repo *ServiceAccountRepository) UpdateServiceAccountTokenCache(
	tokenCache *models.TokenCache,
) (*models.ServiceAccount, error)

UpdateServiceAccountTokenCache updates the token cache for a service account

type SessionRepository

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

SessionRepository uses gorm.DB for querying the database

func (*SessionRepository) CreateSession

func (s *SessionRepository) CreateSession(session *models.Session) (*models.Session, error)

CreateSession must take in Key, Data, and ExpiresAt as arguments.

func (*SessionRepository) DeleteSession

func (s *SessionRepository) DeleteSession(session *models.Session) (*models.Session, error)

DeleteSession deletes a session by Key

func (*SessionRepository) SelectSession

func (s *SessionRepository) SelectSession(session *models.Session) (*models.Session, error)

SelectSession returns a session with matching key

func (*SessionRepository) UpdateSession

func (s *SessionRepository) UpdateSession(session *models.Session) (*models.Session, error)

UpdateSession updates only the Data field using Key as selector.

type UserRepository

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

UserRepository uses gorm.DB for querying the database

func (*UserRepository) CheckPassword

func (repo *UserRepository) CheckPassword(id int, pwd string) (bool, error)

CheckPassword checks the input password is correct for the provided user id.

func (*UserRepository) CreateUser

func (repo *UserRepository) CreateUser(user *models.User) (*models.User, error)

CreateUser adds a new User row to the Users table in the database

func (*UserRepository) DeleteUser

func (repo *UserRepository) DeleteUser(user *models.User) (*models.User, error)

DeleteUser deletes a single user using their unique id

func (*UserRepository) ReadUser

func (repo *UserRepository) ReadUser(id uint) (*models.User, error)

ReadUser finds a single user based on their unique id

func (*UserRepository) ReadUserByEmail

func (repo *UserRepository) ReadUserByEmail(email string) (*models.User, error)

ReadUserByEmail finds a single user based on their unique email

func (*UserRepository) UpdateUser

func (repo *UserRepository) UpdateUser(user *models.User) (*models.User, error)

UpdateUser modifies an existing User in the database

Jump to

Keyboard shortcuts

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