github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/client/state/errdb.go (about) 1 package state 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/nomad/client/allocrunner/taskrunner/state" 7 dmstate "github.com/hashicorp/nomad/client/devicemanager/state" 8 driverstate "github.com/hashicorp/nomad/client/pluginmanager/drivermanager/state" 9 "github.com/hashicorp/nomad/nomad/structs" 10 ) 11 12 // ErrDB implements a StateDB that returns errors on restore methods, used for testing 13 type ErrDB struct { 14 // Allocs is a preset slice of allocations used in GetAllAllocations 15 Allocs []*structs.Allocation 16 } 17 18 func (m *ErrDB) Name() string { 19 return "errdb" 20 } 21 22 func (m *ErrDB) Upgrade() error { 23 return nil 24 } 25 26 func (m *ErrDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error) { 27 return m.Allocs, nil, nil 28 } 29 30 func (m *ErrDB) PutAllocation(alloc *structs.Allocation) error { 31 return fmt.Errorf("Error!") 32 } 33 34 func (m *ErrDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error) { 35 return nil, fmt.Errorf("Error!") 36 } 37 38 func (m *ErrDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error { 39 return fmt.Errorf("Error!") 40 } 41 42 func (m *ErrDB) GetTaskRunnerState(allocID string, taskName string) (*state.LocalState, *structs.TaskState, error) { 43 return nil, nil, fmt.Errorf("Error!") 44 } 45 46 func (m *ErrDB) PutTaskRunnerLocalState(allocID string, taskName string, val *state.LocalState) error { 47 return fmt.Errorf("Error!") 48 } 49 50 func (m *ErrDB) PutTaskState(allocID string, taskName string, state *structs.TaskState) error { 51 return fmt.Errorf("Error!") 52 } 53 54 func (m *ErrDB) DeleteTaskBucket(allocID, taskName string) error { 55 return fmt.Errorf("Error!") 56 } 57 58 func (m *ErrDB) DeleteAllocationBucket(allocID string) error { 59 return fmt.Errorf("Error!") 60 } 61 62 func (m *ErrDB) PutDevicePluginState(ps *dmstate.PluginState) error { 63 return fmt.Errorf("Error!") 64 } 65 66 // GetDevicePluginState stores the device manager's plugin state or returns an 67 // error. 68 func (m *ErrDB) GetDevicePluginState() (*dmstate.PluginState, error) { 69 return nil, fmt.Errorf("Error!") 70 } 71 72 func (m *ErrDB) GetDriverPluginState() (*driverstate.PluginState, error) { 73 return nil, fmt.Errorf("Error!") 74 } 75 76 func (m *ErrDB) PutDriverPluginState(ps *driverstate.PluginState) error { 77 return fmt.Errorf("Error!") 78 } 79 80 func (m *ErrDB) Close() error { 81 return fmt.Errorf("Error!") 82 }