db

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(err error) *pq.Error

Error returns the underlying cause for error

Types

type Database

type Database interface {
	// contains filtered or unexported methods
}

Database interface for tinkerbell database operations

type TinkDB

type TinkDB struct {
	// contains filtered or unexported fields
}

TinkDB implements the Database interface

func Connect

func Connect(lg log.Logger) *TinkDB

Connect returns a connection to postgres database

func (TinkDB) CreateTemplate

func (d TinkDB) CreateTemplate(ctx context.Context, name string, data string, id uuid.UUID) error

CreateTemplate creates a new workflow template

func (TinkDB) CreateWorkflow

func (d TinkDB) CreateWorkflow(ctx context.Context, wf Workflow, data string, id uuid.UUID) error

CreateWorkflow creates a new workflow

func (TinkDB) DeleteFromDB

func (d TinkDB) DeleteFromDB(ctx context.Context, id string) error

DeleteFromDB : delete data from hardware table

func (TinkDB) DeleteTemplate

func (d TinkDB) DeleteTemplate(ctx context.Context, name string) error

DeleteTemplate deletes a workflow template

func (TinkDB) DeleteWorkflow

func (d TinkDB) DeleteWorkflow(ctx context.Context, id string, state int32) error

DeleteWorkflow deletes a workflow

func (TinkDB) GetAll

func (d TinkDB) GetAll(fn func([]byte) error) error

GetAll : get data for all machine

func (TinkDB) GetByID

func (d TinkDB) GetByID(ctx context.Context, id string) (string, error)

GetByID : get data by machine id

func (TinkDB) GetByIP

func (d TinkDB) GetByIP(ctx context.Context, ip string) (string, error)

GetByIP : get data by machine ip

func (TinkDB) GetByMAC

func (d TinkDB) GetByMAC(ctx context.Context, mac string) (string, error)

GetByMAC : get data by machine mac

func (TinkDB) GetTemplate

func (d TinkDB) GetTemplate(ctx context.Context, id string) (string, string, error)

GetTemplate returns a workflow template

func (TinkDB) GetWorkflow

func (d TinkDB) GetWorkflow(ctx context.Context, id string) (Workflow, error)

GetWorkflow returns a workflow

func (TinkDB) GetWorkflowActions

func (d TinkDB) GetWorkflowActions(ctx context.Context, wfID string) (*pb.WorkflowActionList, error)

GetWorkflowActions : gives you the action list of workflow

func (TinkDB) GetWorkflowContexts

func (d TinkDB) GetWorkflowContexts(ctx context.Context, wfID string) (*pb.WorkflowContext, error)

GetWorkflowContexts : gives you the current workflow context

func (TinkDB) GetWorkflowDataVersion

func (d TinkDB) GetWorkflowDataVersion(ctx context.Context, workflowID string) (int32, error)

GetWorkflowDataVersion returns the latest version of data for a workflow

func (TinkDB) GetWorkflowMetadata

func (d TinkDB) GetWorkflowMetadata(ctx context.Context, req *pb.GetWorkflowDataRequest) ([]byte, error)

GetWorkflowMetadata returns metadata wrt to the ephemeral data of a workflow

func (TinkDB) GetWorkflowsForWorker

func (d TinkDB) GetWorkflowsForWorker(id string) ([]string, error)

GetWorkflowsForWorker : returns the list of workflows for a particular worker

func (TinkDB) GetfromWfDataTable

func (d TinkDB) GetfromWfDataTable(ctx context.Context, req *pb.GetWorkflowDataRequest) ([]byte, error)

GetfromWfDataTable : Give you the ephemeral data from workflow_data table

func (TinkDB) InsertIntoDB

func (d TinkDB) InsertIntoDB(ctx context.Context, data string) error

InsertIntoDB : insert data into hardware table

func (TinkDB) InsertIntoWfDataTable

func (d TinkDB) InsertIntoWfDataTable(ctx context.Context, req *pb.UpdateWorkflowDataRequest) error

InsertIntoWfDataTable : Insert ephemeral data in workflow_data table

func (TinkDB) InsertIntoWorkflowEventTable

func (d TinkDB) InsertIntoWorkflowEventTable(ctx context.Context, wfEvent *pb.WorkflowActionStatus, time time.Time) error

InsertIntoWorkflowEventTable : insert workflow event table

func (TinkDB) ListTemplates

func (d TinkDB) ListTemplates(fn func(id, n string, in, del *timestamp.Timestamp) error) error

ListTemplates returns all saved templates

func (TinkDB) ListWorkflows

func (d TinkDB) ListWorkflows(fn func(wf Workflow) error) error

ListWorkflows returns all workflows

func (TinkDB) ShowWorkflowEvents

func (d TinkDB) ShowWorkflowEvents(wfID string, fn func(wfs *pb.WorkflowActionStatus) error) error

ShowWorkflowEvents returns all workflows

func (TinkDB) UpdateTemplate

func (d TinkDB) UpdateTemplate(ctx context.Context, name string, data string, id uuid.UUID) error

UpdateTemplate update a given template

func (TinkDB) UpdateWorkflow

func (d TinkDB) UpdateWorkflow(ctx context.Context, wf Workflow, state int32) error

UpdateWorkflow updates a given workflow

func (TinkDB) UpdateWorkflowState

func (d TinkDB) UpdateWorkflowState(ctx context.Context, wfContext *pb.WorkflowContext) error

UpdateWorkflowState : update the current workflow state

type Workflow

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

Workflow represents a workflow instance in database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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