pgdb

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindKeyValue

func FindKeyValue(tags []*common.Kv, key string) *common.Kv

FindKeyValue finds a Tag object in the array based on key match

func KeyValueToRawMap

func KeyValueToRawMap(arr []*common.Kv) (json.RawMessage, error)

KeyValueToRawMap helps convert an array of KeyValues in a Map and convert it to json

func RawMapToKeyValue

func RawMapToKeyValue(rawJSON json.RawMessage) ([]*common.Kv, error)

RawMapToKeyValue helps convert an array of KeyValues in a Map and convert it to json

func RemoveKeyValue

func RemoveKeyValue(tags []*common.Kv, key string) []*common.Kv

RemoveKeyValue removes an item from the array base on key match

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.

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) AddManagerNodesToDB

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

func (*DB) AddManagerRegionsToDB

func (db *DB) AddManagerRegionsToDB(regions []string, managerId string, managerAcctId string, credential string, acctAlias 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) 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) GetNodes

func (db *DB) GetNodes(sortField string, insortOrder nodes.Query_OrderType, pageNr int32, perPage int32, filters []*common.Filter) ([]*nodes.Node, *TotalCount, 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) 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

type DBTrans

type DBTrans struct {
	*gorp.Transaction
}

type InstanceState

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

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