db

package
v0.0.0-...-98d7d05 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(lg log.Logger) *sql.DB

ConnectDB returns a connection to postgres database

func CreateTemplate

func CreateTemplate(ctx context.Context, db *sql.DB, name string, data []byte, id uuid.UUID) error

CreateTemplate creates a new workflow template

func CreateWorkflow

func CreateWorkflow(ctx context.Context, db *sql.DB, wf Workflow, data string, id uuid.UUID) error

CreateWorkflow creates a new workflow

func DeleteFromDB

func DeleteFromDB(ctx context.Context, db *sql.DB, id string) error

DeleteFromDB : delete data from hardware table

func DeleteFromTargetDB

func DeleteFromTargetDB(ctx context.Context, db *sql.DB, id string) error

DeleteFromTargetDB : Delete the targets which belong to the input id

func DeleteTemplate

func DeleteTemplate(ctx context.Context, db *sql.DB, name string) error

DeleteTemplate deletes a workflow template

func DeleteWorkflow

func DeleteWorkflow(ctx context.Context, db *sql.DB, id string, state int32) error

DeleteWorkflow deletes a workflow

func Error

func Error(err error) *pq.Error

Error returns the underlying cause for error

func GetAll

func GetAll(db *sql.DB, fn func(string) error) error

GetAll : get data for all machine

func GetByID

func GetByID(ctx context.Context, db *sql.DB, id string) (string, error)

GetByID : get data by machine id

func GetByIP

func GetByIP(ctx context.Context, db *sql.DB, ip string) (string, error)

GetByIP : get data by machine ip

func GetByMAC

func GetByMAC(ctx context.Context, db *sql.DB, mac string) (string, error)

GetByMAC : get data by machine mac

func GetTemplate

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

GetTemplate returns a workflow template

func GetWorkflowActions

func GetWorkflowActions(ctx context.Context, db *sql.DB, wfID string) (*pb.WorkflowActionList, error)

GetWorkflowActions : gives you the action list of workflow

func GetWorkflowContexts

func GetWorkflowContexts(ctx context.Context, db *sql.DB, wfID string) (*pb.WorkflowContext, error)

GetWorkflowContexts : gives you the current workflow context

func GetWorkflowDataVersion

func GetWorkflowDataVersion(ctx context.Context, db *sql.DB, workflowID string) (int32, error)

GetWorkflowDataVersion returns the latest version of data for a workflow

func GetWorkflowMetadata

func GetWorkflowMetadata(ctx context.Context, db *sql.DB, req *pb.GetWorkflowDataRequest) ([]byte, error)

GetWorkflowMetadata returns metadata wrt to the ephemeral data of a workflow

func GetfromWfDataTable

func GetfromWfDataTable(ctx context.Context, db *sql.DB, req *pb.GetWorkflowDataRequest) ([]byte, error)

GetfromWfDataTable : Give you the ephemeral data from workflow_data table

func GetfromWfWorkflowTable

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

GetfromWfWorkflowTable : gives you the current workflow

func InsertIntoDB

func InsertIntoDB(ctx context.Context, db *sql.DB, data string) error

InsertIntoDB : insert data into hardware table

func InsertIntoTargetDB

func InsertIntoTargetDB(ctx context.Context, db *sql.DB, data string, uuid string) error

InsertIntoTargetDB : Push targets data in target table

func InsertIntoWfDataTable

func InsertIntoWfDataTable(ctx context.Context, db *sql.DB, req *pb.UpdateWorkflowDataRequest) error

InsertIntoWfDataTable : Insert ephemeral data in workflow_data table

func InsertIntoWorkflowEventTable

func InsertIntoWorkflowEventTable(ctx context.Context, db *sql.DB, wfEvent *pb.WorkflowActionStatus, time time.Time) error

InsertIntoWorkflowEventTable : insert workflow event table

func ListTargets

func ListTargets(db *sql.DB, fn func(id, n string) error) error

ListTargets returns all saved targets which are not deleted

func ListTemplates

func ListTemplates(db *sql.DB, fn func(id, n string, in, del *timestamp.Timestamp) error) error

ListTemplates returns all saved templates

func ListWorkflows

func ListWorkflows(db *sql.DB, fn func(wf Workflow) error) error

ListWorkflows returns all workflows

func ShowWorkflowEvents

func ShowWorkflowEvents(db *sql.DB, wfID string, fn func(wfs pb.WorkflowActionStatus) error) error

ShowWorkflowEvents returns all workflows

func TargetsByID

func TargetsByID(ctx context.Context, db *sql.DB, id string) (string, error)

TargetsByID : Get the targets data which belongs to the input id

func UpdateTemplate

func UpdateTemplate(ctx context.Context, db *sql.DB, name string, data []byte, id uuid.UUID) error

UpdateTemplate update a given template

func UpdateWorkflow

func UpdateWorkflow(ctx context.Context, db *sql.DB, wf Workflow, state int32) error

UpdateWorkflow updates a given workflow

func UpdateWorkflowState

func UpdateWorkflowState(ctx context.Context, db *sql.DB, wfContext *pb.WorkflowContext) error

UpdateWorkflowState : update the current workflow state

Types

type Workflow

type Workflow struct {
	State                int32
	ID, Target, Template string
	CreatedAt, UpdatedAt *timestamp.Timestamp
}

Workflow represents a workflow instance in database

func GetWorkflow

func GetWorkflow(ctx context.Context, db *sql.DB, id string) (Workflow, error)

GetWorkflow returns a workflow

Jump to

Keyboard shortcuts

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