pgdb

package
v0.0.0-...-837eb61 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodesTableAbbrev        = "n"
	TagsTableAbbrev         = "t"
	NodeManagersTableAbbrev = "nm"
)

Variables

This section is empty.

Functions

func Transact

func Transact(db *DB, txFunc func(*DBTrans) error) error

Transact wraps your calls in a transaction. If the call should fail with an error it will perform a rollback. Otherwise the transaction will be committed.

func Unique

func Unique(a []string) []string

Types

type DB

type DB struct {
	*gorp.DbMap
}

func InitDB

func InitDB(connectionString string) (*DB, error)

func New

func New(conf *config.Postgres) (*DB, error)

func (*DB) AddManagerGcpApi

func (db *DB) AddManagerGcpApi(managerId string, managerAcctId string, credential string) (*string, error)

Adds gcp-api node that corresponds to a gcp node manager

func (*DB) AddManagerNodeToDB

func (db *DB) AddManagerNodeToDB(managerId string, managerAcctId string, credential string, acctAlias string, region string) ([]string, error)

func (*DB) AddManagerNodesToDB

func (db *DB) AddManagerNodesToDB(nodesArr []*manager.ManagerNode, managerId string, managerAcctId string, instanceCredentials []*manager.CredentialsByTags, mgrType string) []string

func (*DB) AddManagerSubscriptionsToDB

func (db *DB) AddManagerSubscriptionsToDB(subs []*manager.ManagerNode, managerId string, tenantID string, credential string) []string

func (*DB) AddNode

func (db *DB) AddNode(inNode *nodes.Node) (string, error)

func (*DB) AddNodeManager

func (db *DB) AddNodeManager(inNodeManager *manager.NodeManager, acctID string) (string, error)

func (*DB) AssociateNodeIDsWithManagerID

func (db *DB) AssociateNodeIDsWithManagerID(nodeIDs []string, nodeManagerID string) error

func (*DB) BulkAddNodes

func (db *DB) BulkAddNodes(inNodes []*nodes.Node) (nodeIDs []string, err error)

func (*DB) CancelProjectUpdateTask

func (db *DB) CancelProjectUpdateTask(ctx context.Context, projectUpdateID string,
	id project_update_lib.SerializedProjectUpdateTaskID) error

func (*DB) ChangeNodeState

func (db *DB) ChangeNodeState(nodeState *manager.NodeState) error

func (*DB) DeleteNode

func (db *DB) DeleteNode(id string) (int64, error)

func (*DB) DeleteNodeManager

func (db *DB) DeleteNodeManager(id string) error

func (*DB) DeleteNodeManagerWithNodeStateUpdate

func (db *DB) DeleteNodeManagerWithNodeStateUpdate(id string, state string) error

func (*DB) DeleteNodeManagerWithNodes

func (db *DB) DeleteNodeManagerWithNodes(id string) ([]string, error)

func (*DB) DeleteNodesById

func (db *DB) DeleteNodesById(ctx context.Context, ids []string) ([]string, error)

func (*DB) DeleteNodesWithQuery

func (db *DB) DeleteNodesWithQuery(filters []*common.Filter) ([]string, error)

func (*DB) GetAllManagersByType

func (db *DB) GetAllManagersByType(mgrType string) ([]string, error)

func (*DB) GetCredentialFromNodeManager

func (db *DB) GetCredentialFromNodeManager(ctx context.Context, id string, secretsClient secrets.SecretsServiceClient) (*secrets.Secret, error)

func (*DB) GetManualNodesDue

func (db *DB) GetManualNodesDue(timeAgo time.Time) ([]string, error)

func (*DB) GetNode

func (db *DB) GetNode(ctx context.Context, id string) (*nodes.Node, error)

func (*DB) GetNodeManager

func (db *DB) GetNodeManager(id string) (*manager.NodeManager, error)

func (*DB) GetNodeManagers

func (db *DB) GetNodeManagers(sortField string, insortOrder manager.Query_OrderType,
	pageNr int32, perPage int32, filters []*common.Filter) ([]*manager.NodeManager, int64, error)

func (*DB) GetNodeSecretIds

func (db *DB) GetNodeSecretIds(ctx context.Context, id string) ([]string, error)

func (*DB) GetNodeState

func (db *DB) GetNodeState(id string) (string, error)

func (*DB) GetNodeSuggestions

func (db *DB) GetNodeSuggestions(ctx context.Context, field string, filters []*common.Filter) ([]string, error)

GetNodeSuggestions returns "suggestions" for filtering the nodes list, given a field and filters this is not used by any API/other function yet, but will be. it only supports suggestions for columns that are in the nodes table. it respects filters, it does not apply sorting to the returned list.

func (*DB) GetNodes

func (db *DB) GetNodes(sortField string, insortOrder nodes.Query_OrderType, pageNr int32,
	perPage int32, filters []*common.Filter) ([]*nodes.Node, *TotalCount, error)

func (*DB) JobCancel

func (db *DB) JobCancel(ctx context.Context, jobID string) error

JobCancel - cancel the a currently running project update

func (*DB) JobStatus

func (db *DB) JobStatus(ctx context.Context, jobID string) (project_update_lib.JobStatus, error)

JobStatus - get the job status of the project update

func (*DB) ListProjectUpdateTasks

func (db *DB) ListProjectUpdateTasks(ctx context.Context) ([]project_update_lib.SerializedProjectUpdateTask, error)

func (*DB) ProcessIncomingNode

func (db *DB) ProcessIncomingNode(node *manager.NodeMetadata) error

func (*DB) QueryManualNodesFields

func (db *DB) QueryManualNodesFields(ctx context.Context, filters []*common.Filter, field string) ([]string, error)

func (*DB) RemoveStaleNodeAssociations

func (db *DB) RemoveStaleNodeAssociations(managerId string, nodeIds []string) error

func (*DB) RunProjectUpdateTask

func (db *DB) RunProjectUpdateTask(ctx context.Context, projectUpdateID string,
	params map[string]string, projectTaggingRules map[string]*authz.ProjectRules) (
	project_update_lib.SerializedProjectUpdateTaskID,
	project_update_lib.SerializedProjectUpdateTaskStatus,
	error)

func (*DB) UpdateManagerStatus

func (db *DB) UpdateManagerStatus(mgrId string, status string) error

func (*DB) UpdateNode

func (db *DB) UpdateNode(inNode *nodes.Node) error

UpdateNode takes an inNode model struct and uses it to update a Node in the db.

func (*DB) UpdateNodeConnectionErr

func (db *DB) UpdateNodeConnectionErr(ctx context.Context, connErr *nodes.NodeError) (err error)

update node with the connection error

func (*DB) UpdateNodeDetectInfo

func (db *DB) UpdateNodeDetectInfo(ctx context.Context, nodeDetectInfo *nodes.NodeDetectJobInfo) (err error)

Update node with inspec detect job results. This includes platform name, platform release, last_contact, status and state

func (*DB) UpdateNodeManager

func (db *DB) UpdateNodeManager(inNodeManager *manager.NodeManager) (string, error)

func (*DB) UpdateOrInsertInstanceSourceStateInDb

func (db *DB) UpdateOrInsertInstanceSourceStateInDb(instance InstanceState, mgrID string, sourceAcctID string, mgrType string) (bool, error)

UpdateInstanceSourceStateInDb updates source_state of instance passed in, and updates the status as unreachable if the source_state is anything other than running if any rows are inserted or updated returns true, otherwise false

func (*DB) UpdateProjectTags

func (db *DB) UpdateProjectTags(ctx context.Context,
	projectRules map[string]*authz.ProjectRules) ([]string, error)

UpdateProjectTags - start a project update

type DBTrans

type DBTrans struct {
	*gorp.Transaction
}

type InstanceState

type InstanceState struct {
	ID     string
	Name   string
	State  string
	Region string
}

type NodeProjectData

type NodeProjectData struct {
	ID                   string `db:"id"`
	Data                 string `db:"projects_data"`
	ProjectDataKeyValues []*nodes.ProjectsData
}

type NodeSecret

type NodeSecret struct {
	NodeID   string `db:"node_id"`
	SecretID string `db:"secret_id"`
}

NodeSecret used only to (de)serialize database access

type NodeTag

type NodeTag struct {
	NodeID string `db:"node_id"`
	TagID  string `db:"tag_id"`
}

NodeTag used only to (de)serialize database access

type TotalCount

type TotalCount struct {
	Total, Unreachable, Reachable, Unknown int32
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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