readdb

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Stmts = []string{

	"create table revision (revision bigint, PRIMARY KEY(revision))",

	"create table committedwalsequence (seq varchar, PRIMARY KEY (seq))",

	"create table changegrouprevision (id varchar, revision varchar, PRIMARY KEY (id, revision))",

	"create table projectgroup (id uuid, name varchar, parentid varchar, parenttype varchar, data bytea, PRIMARY KEY (id))",
	"create index projectgroup_name on projectgroup(name)",

	"create table project (id uuid, name varchar, parentid varchar, parenttype varchar, data bytea, PRIMARY KEY (id))",
	"create index project_name on project(name)",

	"create table user (id uuid, name varchar, data bytea, PRIMARY KEY (id))",
	"create index user_name on user(name)",
	"create table user_token (tokenvalue varchar, userid uuid, PRIMARY KEY (tokenvalue, userid))",

	"create table org (id uuid, name varchar, data bytea, PRIMARY KEY (id))",
	"create index org_name on org(name)",

	"create table orgmember (id uuid, orgid uuid, userid uuid, role varchar, data bytea, PRIMARY KEY (id))",
	"create index orgmember_role on orgmember(role)",
	"create index orgmember_orgid_userid on orgmember(orgid, userid)",

	"create table remotesource (id uuid, name varchar, data bytea, PRIMARY KEY (id))",

	"create table linkedaccount_user (id uuid, remotesourceid uuid, userid uuid, remoteuserid uuid, PRIMARY KEY (id), FOREIGN KEY(userid) REFERENCES user(id))",

	"create table linkedaccount_project (id uuid, projectid uuid, PRIMARY KEY (id), FOREIGN KEY(projectid) REFERENCES user(id))",

	"create table secret (id uuid, name varchar, parentid varchar, parenttype varchar, data bytea, PRIMARY KEY (id))",
	"create index secret_name on secret(name)",

	"create table variable (id uuid, name varchar, parentid varchar, parenttype varchar, data bytea, PRIMARY KEY (id))",
	"create index variable_name on variable(name)",
}

Functions

This section is empty.

Types

type Element

type Element struct {
	ID         string
	Name       string
	Type       types.ConfigType
	ParentType types.ConfigType
	ParentID   string
}

type OrgUser

type OrgUser struct {
	User *types.User
	Role types.MemberRole
}

type ReadDB

type ReadDB struct {
	Initialized bool
	// contains filtered or unexported fields
}

func NewReadDB

func NewReadDB(ctx context.Context, logger *zap.Logger, dataDir string, e *etcd.Store, ost *objectstorage.ObjStorage, dm *datamanager.DataManager) (*ReadDB, error)

func (*ReadDB) Do

func (r *ReadDB) Do(ctx context.Context, f func(tx *db.Tx) error) error

func (*ReadDB) GetAllProjects

func (r *ReadDB) GetAllProjects(tx *db.Tx) ([]*types.Project, error)

func (*ReadDB) GetChangeGroupsUpdateTokens

func (r *ReadDB) GetChangeGroupsUpdateTokens(tx *db.Tx, groups []string) (*datamanager.ChangeGroupsUpdateToken, error)

func (*ReadDB) GetCommittedWalSequence

func (r *ReadDB) GetCommittedWalSequence(tx *db.Tx) (string, error)

func (*ReadDB) GetOrg

func (r *ReadDB) GetOrg(tx *db.Tx, orgRef string) (*types.Organization, error)

func (*ReadDB) GetOrgByID

func (r *ReadDB) GetOrgByID(tx *db.Tx, orgID string) (*types.Organization, error)

func (*ReadDB) GetOrgByName

func (r *ReadDB) GetOrgByName(tx *db.Tx, name string) (*types.Organization, error)

func (*ReadDB) GetOrgMemberByOrgUserID

func (r *ReadDB) GetOrgMemberByOrgUserID(tx *db.Tx, orgID, userID string) (*types.OrganizationMember, error)

func (*ReadDB) GetOrgUsers

func (r *ReadDB) GetOrgUsers(tx *db.Tx, orgID string) ([]*OrgUser, error)

TODO(sgotti) implement cursor fetching

func (*ReadDB) GetOrgs

func (r *ReadDB) GetOrgs(tx *db.Tx, startOrgName string, limit int, asc bool) ([]*types.Organization, error)

func (*ReadDB) GetPath

func (r *ReadDB) GetPath(tx *db.Tx, configType types.ConfigType, id string) (string, error)

func (*ReadDB) GetProject

func (r *ReadDB) GetProject(tx *db.Tx, projectRef string) (*types.Project, error)

func (*ReadDB) GetProjectByID

func (r *ReadDB) GetProjectByID(tx *db.Tx, projectID string) (*types.Project, error)

func (*ReadDB) GetProjectByName

func (r *ReadDB) GetProjectByName(tx *db.Tx, parentID, name string) (*types.Project, error)

func (*ReadDB) GetProjectByPath

func (r *ReadDB) GetProjectByPath(tx *db.Tx, projectPath string) (*types.Project, error)

func (*ReadDB) GetProjectGroup

func (r *ReadDB) GetProjectGroup(tx *db.Tx, projectGroupRef string) (*types.ProjectGroup, error)

func (*ReadDB) GetProjectGroupByID

func (r *ReadDB) GetProjectGroupByID(tx *db.Tx, projectGroupID string) (*types.ProjectGroup, error)

func (*ReadDB) GetProjectGroupByName

func (r *ReadDB) GetProjectGroupByName(tx *db.Tx, parentID, name string) (*types.ProjectGroup, error)

func (*ReadDB) GetProjectGroupByPath

func (r *ReadDB) GetProjectGroupByPath(tx *db.Tx, projectGroupPath string) (*types.ProjectGroup, error)

func (*ReadDB) GetProjectGroupHierarchy

func (r *ReadDB) GetProjectGroupHierarchy(tx *db.Tx, projectGroup *types.ProjectGroup) ([]*Element, error)

func (*ReadDB) GetProjectGroupOwnerID

func (r *ReadDB) GetProjectGroupOwnerID(tx *db.Tx, group *types.ProjectGroup) (types.ConfigType, string, error)

func (*ReadDB) GetProjectGroupPath

func (r *ReadDB) GetProjectGroupPath(tx *db.Tx, group *types.ProjectGroup) (string, error)

func (*ReadDB) GetProjectGroupProjects

func (r *ReadDB) GetProjectGroupProjects(tx *db.Tx, parentID string) ([]*types.Project, error)

func (*ReadDB) GetProjectGroupSubgroups

func (r *ReadDB) GetProjectGroupSubgroups(tx *db.Tx, parentID string) ([]*types.ProjectGroup, error)

func (*ReadDB) GetProjectOwnerID

func (r *ReadDB) GetProjectOwnerID(tx *db.Tx, project *types.Project) (types.ConfigType, string, error)

func (*ReadDB) GetProjectPath

func (r *ReadDB) GetProjectPath(tx *db.Tx, project *types.Project) (string, error)

func (*ReadDB) GetRemoteSource

func (r *ReadDB) GetRemoteSource(tx *db.Tx, rsRef string) (*types.RemoteSource, error)

func (*ReadDB) GetRemoteSourceByID

func (r *ReadDB) GetRemoteSourceByID(tx *db.Tx, remoteSourceID string) (*types.RemoteSource, error)

func (*ReadDB) GetRemoteSourceByName

func (r *ReadDB) GetRemoteSourceByName(tx *db.Tx, name string) (*types.RemoteSource, error)

func (*ReadDB) GetRemoteSources

func (r *ReadDB) GetRemoteSources(ctx context.Context, startRemoteSourceName string, limit int, asc bool) ([]*types.RemoteSource, error)

func (*ReadDB) GetRevision

func (r *ReadDB) GetRevision(ctx context.Context) (int64, error)

func (*ReadDB) GetSecretByID

func (r *ReadDB) GetSecretByID(tx *db.Tx, secretID string) (*types.Secret, error)

func (*ReadDB) GetSecretByName

func (r *ReadDB) GetSecretByName(tx *db.Tx, parentID, name string) (*types.Secret, error)

func (*ReadDB) GetSecretTree

func (r *ReadDB) GetSecretTree(tx *db.Tx, parentType types.ConfigType, parentID, name string) (*types.Secret, error)

func (*ReadDB) GetSecrets

func (r *ReadDB) GetSecrets(tx *db.Tx, parentID string) ([]*types.Secret, error)

func (*ReadDB) GetSecretsTree

func (r *ReadDB) GetSecretsTree(tx *db.Tx, parentType types.ConfigType, parentID string) ([]*types.Secret, error)

func (*ReadDB) GetUser

func (r *ReadDB) GetUser(tx *db.Tx, userRef string) (*types.User, error)

func (*ReadDB) GetUserByID

func (r *ReadDB) GetUserByID(tx *db.Tx, userID string) (*types.User, error)

func (*ReadDB) GetUserByLinkedAccount

func (r *ReadDB) GetUserByLinkedAccount(tx *db.Tx, linkedAccountID string) (*types.User, error)

func (*ReadDB) GetUserByLinkedAccountRemoteUserIDandSource

func (r *ReadDB) GetUserByLinkedAccountRemoteUserIDandSource(tx *db.Tx, remoteUserID, remoteSourceID string) (*types.User, error)

func (*ReadDB) GetUserByName

func (r *ReadDB) GetUserByName(tx *db.Tx, name string) (*types.User, error)

func (*ReadDB) GetUserByTokenValue

func (r *ReadDB) GetUserByTokenValue(tx *db.Tx, tokenValue string) (*types.User, error)

func (*ReadDB) GetUserOrgs

func (r *ReadDB) GetUserOrgs(tx *db.Tx, userID string) ([]*UserOrg, error)

TODO(sgotti) implement cursor fetching

func (*ReadDB) GetUsers

func (r *ReadDB) GetUsers(tx *db.Tx, startUserName string, limit int, asc bool) ([]*types.User, error)

func (*ReadDB) GetVariableByID

func (r *ReadDB) GetVariableByID(tx *db.Tx, variableID string) (*types.Variable, error)

func (*ReadDB) GetVariableByName

func (r *ReadDB) GetVariableByName(tx *db.Tx, parentID, name string) (*types.Variable, error)

func (*ReadDB) GetVariables

func (r *ReadDB) GetVariables(tx *db.Tx, parentID string) ([]*types.Variable, error)

func (*ReadDB) GetVariablesTree

func (r *ReadDB) GetVariablesTree(tx *db.Tx, parentType types.ConfigType, parentID string) ([]*types.Variable, error)

func (*ReadDB) Initialize

func (r *ReadDB) Initialize(ctx context.Context) error

Initialize populates the readdb with the current etcd data and save the revision to then feed it with the etcd events

func (*ReadDB) IsInitialized

func (r *ReadDB) IsInitialized() bool

func (*ReadDB) ResetDB

func (r *ReadDB) ResetDB(ctx context.Context) error

func (*ReadDB) ResolveConfigID

func (r *ReadDB) ResolveConfigID(tx *db.Tx, configType types.ConfigType, ref string) (string, error)

func (*ReadDB) Run

func (r *ReadDB) Run(ctx context.Context) error

func (*ReadDB) SetInitialized

func (r *ReadDB) SetInitialized(initialized bool)

func (*ReadDB) SyncFromDump

func (r *ReadDB) SyncFromDump(ctx context.Context) (string, error)

func (*ReadDB) SyncFromWals

func (r *ReadDB) SyncFromWals(ctx context.Context, startWalSeq, endWalSeq string) (string, error)

func (*ReadDB) SyncRDB

func (r *ReadDB) SyncRDB(ctx context.Context) error

type UserOrg

type UserOrg struct {
	Organization *types.Organization
	Role         types.MemberRole
}

Jump to

Keyboard shortcuts

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