drone/types/principal.go
Johannes Batzill 335998505e [MISC] Introduce PathStore and Move PathLogic to Controller Layer (#226)
This change is a follow up on the effort to remove transactions and sync stores from the database layer, and move them in the application layer. It is addressing the repo + space store.
The following changes are included:
- Introduce PathStore storing resource paths (repo + space)
- Add foreign key from path.repo_id/space_id to repo.id/space.id
- Add foreign key from repo/space.parent_id to space.id
- Remove repo_sync and space_sync
- Move path creation logic to repo/space controller (for both creating primary paths for new repos/spaces, as well as creating alias spaces)
- Reimplement repo/space moving on controller layer
2023-01-18 11:34:12 -08:00

49 lines
1.7 KiB
Go

// Copyright 2022 Harness Inc. All rights reserved.
// Use of this source code is governed by the Polyform Free Trial License
// that can be found in the LICENSE.md file for this repository.
// Package types defines common data structures.
package types
import "github.com/harness/gitness/types/enum"
// Principal represents the identity of an acting entity (User, ServiceAccount, Service).
type Principal struct {
// TODO: int64 ID doesn't match DB
ID int64 `db:"principal_id" json:"-"`
UID string `db:"principal_uid" json:"uid"`
Email string `db:"principal_email" json:"email"`
Type enum.PrincipalType `db:"principal_type" json:"type"`
DisplayName string `db:"principal_display_name" json:"display_name"`
Admin bool `db:"principal_admin" json:"admin"`
// Should be part of principal or not?
Blocked bool `db:"principal_blocked" json:"blocked"`
Salt string `db:"principal_salt" json:"-"`
// Other info
Created int64 `db:"principal_created" json:"created"`
Updated int64 `db:"principal_updated" json:"updated"`
}
func (p *Principal) ToPrincipalInfo() *PrincipalInfo {
return &PrincipalInfo{
ID: p.ID,
UID: p.UID,
DisplayName: p.DisplayName,
Email: p.Email,
}
}
// PrincipalInfo is a compressed representation of a principal we return as part of non-principal APIs.
type PrincipalInfo struct {
ID int64 `json:"id"`
UID string `json:"uid"`
DisplayName string `json:"display_name"`
Email string `json:"email"`
}
func (p *PrincipalInfo) Identifier() int64 {
return p.ID
}