80619137ab
* api/allocations: GetTaskGroup finds the taskgroup struct * command/node_status: display CSI volume names * nomad/state/state_store: new CSIVolumesByNodeID * nomad/state/iterator: new SliceIterator type implements memdb.ResultIterator * nomad/csi_endpoint: deal with a slice of volumes * nomad/state/state_store: CSIVolumesByNodeID return a SliceIterator * nomad/structs/csi: CSIVolumeListRequest takes a NodeID * nomad/csi_endpoint: use the return iterator * command/agent/csi_endpoint: parse query params for CSIVolumes.List * api/nodes: new CSIVolumes to list volumes by node * command/node_status: use the new list endpoint to print volumes * nomad/state/state_store: error messages consider the operator * command/node_status: include the Provider
31 lines
470 B
Go
31 lines
470 B
Go
package state
|
|
|
|
type SliceIterator struct {
|
|
data []interface{}
|
|
idx int
|
|
}
|
|
|
|
func NewSliceIterator() *SliceIterator {
|
|
return &SliceIterator{
|
|
data: []interface{}{},
|
|
idx: 0,
|
|
}
|
|
}
|
|
|
|
func (i *SliceIterator) Add(datum interface{}) {
|
|
i.data = append(i.data, datum)
|
|
}
|
|
|
|
func (i *SliceIterator) Next() interface{} {
|
|
if i.idx == len(i.data) {
|
|
return nil
|
|
}
|
|
idx := i.idx
|
|
i.idx += 1
|
|
return i.data[idx]
|
|
}
|
|
|
|
func (i *SliceIterator) WatchCh() <-chan struct{} {
|
|
return nil
|
|
}
|