Documentation ¶
Index ¶
- Constants
- func AddAccessLog(accessLog models.AccessLog) error
- func AddProject(project models.Project) (int64, error)
- func AddProjectMember(projectID int64, userID int, role int) error
- func AddProjectMetadata(meta *models.ProjectMetadata) error
- func AddRepJob(job models.RepJob) (int64, error)
- func AddRepPolicy(policy models.RepPolicy) (int64, error)
- func AddRepTarget(target models.RepTarget) (int64, error)
- func AddRepository(repo models.RepoRecord) error
- func AddScanJob(job models.ScanJob) (int64, error)
- func AuthModeCanBeModified() (bool, error)
- func ChangeUserPassword(u models.User, oldPassword ...string) (err error)
- func ChangeUserProfile(user models.User, cols ...string) error
- func CheckUserPassword(query models.User) (*models.User, error)
- func CleanUser(id int64) error
- func ClearTable(table string) error
- func CountPull(repoName string) (int64, error)
- func DeleteProject(id int64) error
- func DeleteProjectMember(projectID int64, userID int) error
- func DeleteProjectMetadata(projectID int64, name ...string) error
- func DeleteRepJob(id int64) error
- func DeleteRepPolicy(id int64) error
- func DeleteRepTarget(id int64) error
- func DeleteRepository(name string) error
- func DeleteUser(userID int) error
- func FilterRepJobs(policyID int64, repository string, status []string, ...) ([]*models.RepJob, int64, error)
- func FilterRepPolicies(name string, projectID, page, pageSize int64) ([]*models.RepPolicy, error)
- func FilterRepTargets(name string) ([]*models.RepTarget, error)
- func GetAccessLogs(query *models.LogQueryParam) ([]models.AccessLog, error)
- func GetAllRepositories() ([]*models.RepoRecord, error)
- func GetConfigEntries() ([]*models.ConfigEntry, error)
- func GetImgScanOverview(digest string) (*models.ImgScanOverview, error)
- func GetOrmer() orm.Ormer
- func GetProjectByID(id int64) (*models.Project, error)
- func GetProjectByName(name string) (*models.Project, error)
- func GetProjectMetadata(projectID int64, name ...string) ([]*models.ProjectMetadata, error)
- func GetProjects(query *models.ProjectQueryParam) ([]*models.Project, error)
- func GetRepJob(id int64) (*models.RepJob, error)
- func GetRepJobByPolicy(policyID int64) ([]*models.RepJob, error)
- func GetRepJobByStatus(status ...string) ([]*models.RepJob, error)
- func GetRepJobToStop(policyID int64) ([]*models.RepJob, error)
- func GetRepPolicy(id int64) (*models.RepPolicy, error)
- func GetRepPolicyByName(name string) (*models.RepPolicy, error)
- func GetRepPolicyByProject(projectID int64) ([]*models.RepPolicy, error)
- func GetRepPolicyByProjectAndTarget(projectID, targetID int64) ([]*models.RepPolicy, error)
- func GetRepPolicyByTarget(targetID int64) ([]*models.RepPolicy, error)
- func GetRepTarget(id int64) (*models.RepTarget, error)
- func GetRepTargetByEndpoint(endpoint string) (*models.RepTarget, error)
- func GetRepTargetByName(name string) (*models.RepTarget, error)
- func GetRepositoriesByProject(projectID int64, name string, limit, offset int64) ([]*models.RepoRecord, error)
- func GetRepositoryByName(name string) (*models.RepoRecord, error)
- func GetRepositoryByProjectName(name string) ([]*models.RepoRecord, error)
- func GetRoleByID(id int) (*models.Role, error)
- func GetScanJob(id int64) (*models.ScanJob, error)
- func GetScanJobsByDigest(digest string, limit ...int) ([]*models.ScanJob, error)
- func GetScanJobsByImage(repository, tag string, limit ...int) ([]*models.ScanJob, error)
- func GetScanJobsByStatus(status ...string) ([]*models.ScanJob, error)
- func GetSchemaVersion() (*models.SchemaVersion, error)
- func GetTopRepos(projectIDs []int64, n int) ([]*models.RepoRecord, error)
- func GetTotalOfAccessLogs(query *models.LogQueryParam) (int64, error)
- func GetTotalOfProjects(query *models.ProjectQueryParam) (int64, error)
- func GetTotalOfRepPolicies(name string, projectID int64) (int64, error)
- func GetTotalOfRepositories(name string) (int64, error)
- func GetTotalOfRepositoriesByProject(projectIDs []int64, name string) (int64, error)
- func GetTotalOfUsers(query *models.UserQuery) (int64, error)
- func GetUser(query models.User) (*models.User, error)
- func GetUserByProject(projectID int64, queryUser models.User) ([]*models.Member, error)
- func GetUserProjectRoles(userID int, projectID int64) ([]models.Role, error)
- func IncreasePullCount(name string) (err error)
- func InitClairDB(clairDB *models.PostGreSQL) error
- func InitDatabase(database *models.Database) error
- func IsAdminRole(userIDOrUsername interface{}) (bool, error)
- func IsSuperUser(username string) bool
- func ListClairVulnTimestamps() ([]*models.ClairVulnTimestamp, error)
- func ListImgScanOverviews() ([]*models.ImgScanOverview, error)
- func ListProjectMetadata(name, value string) ([]*models.ProjectMetadata, error)
- func ListUsers(query *models.UserQuery) ([]models.User, error)
- func LoginByDb(auth models.AuthModel) (*models.User, error)
- func OnBoardUser(u *models.User) error
- func PrepareTestForMySQL()
- func PrepareTestForSQLite()
- func Register(user models.User) (int64, error)
- func RepositoryExists(name string) bool
- func ResetRunningJobs() error
- func ResetUserPassword(u models.User) error
- func SaveConfigEntries(entries []models.ConfigEntry) error
- func SetClairVulnTimestamp(namespace string, timestamp time.Time) error
- func SetScanJobForImg(digest string, jobID int64) error
- func ToggleUserAdminRole(userID, hasAdmin int) error
- func UpdateImgScanOverview(digest, detailsKey string, sev models.Severity, ...) error
- func UpdateProjectMember(projectID int64, userID int, role int) error
- func UpdateProjectMetadata(meta *models.ProjectMetadata) error
- func UpdateRepJobStatus(id int64, status string) error
- func UpdateRepPolicy(policy *models.RepPolicy) error
- func UpdateRepTarget(target models.RepTarget) error
- func UpdateRepository(repo models.RepoRecord) error
- func UpdateScanJobStatus(id int64, status string) error
- func UpdateUserResetUUID(u models.User) error
- func UserExists(user models.User, target string) (bool, error)
- type Database
- type DatabaseWatchItemDAO
- type WatchItemDAO
Constants ¶
const ( // NonExistUserID : if a user does not exist, the ID of the user will be 0. NonExistUserID = 0 // ClairDBAlias ... ClairDBAlias = "clair-db" )
const (
// SchemaVersion is the version of database schema
SchemaVersion = "1.4.0"
)
Variables ¶
This section is empty.
Functions ¶
func AddAccessLog ¶
AddAccessLog persists the access logs
func AddProject ¶
AddProject adds a project to the database along with project roles information and access log records.
func AddProjectMember ¶
AddProjectMember inserts a record to table project_member
func AddProjectMetadata ¶
func AddProjectMetadata(meta *models.ProjectMetadata) error
AddProjectMetadata adds metadata for a project
func AddRepository ¶
func AddRepository(repo models.RepoRecord) error
AddRepository adds a repo to the database.
func AuthModeCanBeModified ¶
AuthModeCanBeModified determines whether auth mode can be modified or not. Auth mode can modified when there is only admin user in database.
func ChangeUserPassword ¶
ChangeUserPassword ...
func ChangeUserProfile ¶
ChangeUserProfile - Update user in local db, cols to specify the columns need to update, Email, and RealName, Comment are updated by default.
func CheckUserPassword ¶
CheckUserPassword checks whether the password is correct.
func ClearTable ¶
ClearTable is the shortcut for test cases, it should be called only in test cases.
func DeleteProjectMember ¶
DeleteProjectMember delete the record from table project_member
func DeleteProjectMetadata ¶
DeleteProjectMetadata deleted metadata of a project. If name is absent all metadatas will be deleted, otherwise only the metadatas specified by name will be deleted
func FilterRepJobs ¶
func FilterRepJobs(policyID int64, repository string, status []string, startTime, endTime *time.Time, limit, offset int64) ([]*models.RepJob, int64, error)
FilterRepJobs ...
func FilterRepPolicies ¶
FilterRepPolicies filters policies by name and project ID
func FilterRepTargets ¶
FilterRepTargets filters targets by name
func GetAccessLogs ¶
func GetAccessLogs(query *models.LogQueryParam) ([]models.AccessLog, error)
GetAccessLogs gets access logs according to different conditions
func GetAllRepositories ¶
func GetAllRepositories() ([]*models.RepoRecord, error)
GetAllRepositories ...
func GetConfigEntries ¶
func GetConfigEntries() ([]*models.ConfigEntry, error)
GetConfigEntries Get configuration from database
func GetImgScanOverview ¶
func GetImgScanOverview(digest string) (*models.ImgScanOverview, error)
GetImgScanOverview returns the ImgScanOverview based on the digest.
func GetProjectByName ¶
GetProjectByName ...
func GetProjectMetadata ¶
func GetProjectMetadata(projectID int64, name ...string) ([]*models.ProjectMetadata, error)
GetProjectMetadata returns the metadata of a project. If name is absent all metadatas will be returned, otherwise only the metadatas specified by name will be returned
func GetProjects ¶
func GetProjects(query *models.ProjectQueryParam) ([]*models.Project, error)
GetProjects returns a project list according to the query conditions
func GetRepJobByPolicy ¶
GetRepJobByPolicy ...
func GetRepJobByStatus ¶
GetRepJobByStatus get jobs of certain statuses
func GetRepJobToStop ¶
GetRepJobToStop get jobs that are possibly being handled by workers of a certain policy.
func GetRepPolicyByName ¶
GetRepPolicyByName ...
func GetRepPolicyByProject ¶
GetRepPolicyByProject ...
func GetRepPolicyByProjectAndTarget ¶
GetRepPolicyByProjectAndTarget ...
func GetRepPolicyByTarget ¶
GetRepPolicyByTarget ...
func GetRepTargetByEndpoint ¶
GetRepTargetByEndpoint ...
func GetRepTargetByName ¶
GetRepTargetByName ...
func GetRepositoriesByProject ¶
func GetRepositoriesByProject(projectID int64, name string, limit, offset int64) ([]*models.RepoRecord, error)
GetRepositoriesByProject ...
func GetRepositoryByName ¶
func GetRepositoryByName(name string) (*models.RepoRecord, error)
GetRepositoryByName ...
func GetRepositoryByProjectName ¶
func GetRepositoryByProjectName(name string) ([]*models.RepoRecord, error)
GetRepositoryByProjectName ...
func GetScanJobsByDigest ¶
GetScanJobsByDigest returns a list of scan jobs with given digest
func GetScanJobsByImage ¶
GetScanJobsByImage returns a list of scan jobs with given repository and tag
func GetScanJobsByStatus ¶
GetScanJobsByStatus return a list of scan jobs with any of the given statuses in param
func GetSchemaVersion ¶
func GetSchemaVersion() (*models.SchemaVersion, error)
GetSchemaVersion return the version of database schema
func GetTopRepos ¶
func GetTopRepos(projectIDs []int64, n int) ([]*models.RepoRecord, error)
GetTopRepos returns the most popular repositories whose project ID is in projectIDs
func GetTotalOfAccessLogs ¶
func GetTotalOfAccessLogs(query *models.LogQueryParam) (int64, error)
GetTotalOfAccessLogs ...
func GetTotalOfProjects ¶
func GetTotalOfProjects(query *models.ProjectQueryParam) (int64, error)
GetTotalOfProjects returns the total count of projects according to the query conditions
func GetTotalOfRepPolicies ¶
GetTotalOfRepPolicies returns the total count of replication policies
func GetTotalOfRepositories ¶
GetTotalOfRepositories ...
func GetTotalOfRepositoriesByProject ¶
GetTotalOfRepositoriesByProject ...
func GetTotalOfUsers ¶
GetTotalOfUsers ...
func GetUserByProject ¶
GetUserByProject gets all members of the project.
func GetUserProjectRoles ¶
GetUserProjectRoles returns roles that the user has according to the project.
func InitDatabase ¶
InitDatabase initializes the database
func IsAdminRole ¶
IsAdminRole returns whether the user is admin.
func IsSuperUser ¶
IsSuperUser checks if the user is super user(conventionally id == 1) of Harbor
func ListClairVulnTimestamps ¶
func ListClairVulnTimestamps() ([]*models.ClairVulnTimestamp, error)
ListClairVulnTimestamps return a list of all records in vuln timestamp table.
func ListImgScanOverviews ¶
func ListImgScanOverviews() ([]*models.ImgScanOverview, error)
ListImgScanOverviews list all records in table img_scan_overview, it is called in notification handler when it needs to refresh the severity of all images.
func ListProjectMetadata ¶
func ListProjectMetadata(name, value string) ([]*models.ProjectMetadata, error)
ListProjectMetadata ...
func OnBoardUser ¶
OnBoardUser will check if a user exists in user table, if not insert the user and put the id in the pointer of user model, if it does exist, return the user's profile. This is used for ldap and uaa authentication, such the user can have an ID in Harbor.
func Register ¶
Register is used for user to register, the password is encrypted before the record is inserted into database.
func RepositoryExists ¶
RepositoryExists returns whether the repository exists according to its name.
func ResetRunningJobs ¶
func ResetRunningJobs() error
ResetRunningJobs update all running jobs status to pending, including replication jobs and scan jobs.
func SaveConfigEntries ¶
func SaveConfigEntries(entries []models.ConfigEntry) error
SaveConfigEntries Save configuration to database.
func SetClairVulnTimestamp ¶
SetClairVulnTimestamp update the last_update of a namespace. If there's no record for this namespace, one will be created.
func SetScanJobForImg ¶
SetScanJobForImg updates the scan_job_id based on the digest of image, if there's no data, it created one record.
func ToggleUserAdminRole ¶
ToggleUserAdminRole gives a user admin role.
func UpdateImgScanOverview ¶
func UpdateImgScanOverview(digest, detailsKey string, sev models.Severity, compOverview *models.ComponentsOverview) error
UpdateImgScanOverview updates the serverity and components status of a record in img_scan_overview
func UpdateProjectMember ¶
UpdateProjectMember updates the record in table project_member
func UpdateProjectMetadata ¶
func UpdateProjectMetadata(meta *models.ProjectMetadata) error
UpdateProjectMetadata updates metadata of a project
func UpdateRepJobStatus ¶
UpdateRepJobStatus ...
func UpdateScanJobStatus ¶
UpdateScanJobStatus updates the status of a scan job.
Types ¶
type Database ¶
type Database interface { // Name returns the name of database Name() string // String returns the details of database String() string // Register registers the database which will be used Register(alias ...string) error }
Database is an interface of different databases
type DatabaseWatchItemDAO ¶
type DatabaseWatchItemDAO struct{}
DatabaseWatchItemDAO implements interface WatchItemDAO for database
func (*DatabaseWatchItemDAO) Add ¶
func (d *DatabaseWatchItemDAO) Add(item *models.WatchItem) (int64, error)
Add a WatchItem
func (*DatabaseWatchItemDAO) DeleteByPolicyID ¶
func (d *DatabaseWatchItemDAO) DeleteByPolicyID(policyID int64) error
DeleteByPolicyID deletes the WatchItem specified by policy ID
type WatchItemDAO ¶
type WatchItemDAO interface { Add(*models.WatchItem) (int64, error) DeleteByPolicyID(int64) error Get(namespace, operation string) ([]models.WatchItem, error) }
WatchItemDAO defines operations about WatchItem
var DefaultDatabaseWatchItemDAO WatchItemDAO = &DatabaseWatchItemDAO{}
DefaultDatabaseWatchItemDAO is an instance of DatabaseWatchItemDAO