Skip to content

Commit 42771b9

Browse files
implement ListInstances
1 parent d6f3729 commit 42771b9

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

v1/providers/sfcompute/instance.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,22 @@ func (c *SFCClient) GetInstance(ctx context.Context, id v1.CloudProviderInstance
107107
}
108108

109109
func (c *SFCClient) ListInstances(ctx context.Context, args v1.ListInstancesArgs) ([]v1.Instance, error) {
110-
return nil, fmt.Errorf("not implemented")
110+
resp, err := c.client.Nodes.List(ctx, sfcnodes.NodeListParams{})
111+
if err != nil {
112+
return nil, err
113+
}
114+
115+
var instances []v1.Instance
116+
for _, node := range resp.Data {
117+
inst, err := c.GetInstance(ctx, v1.CloudProviderInstanceID(node.ID))
118+
if err != nil {
119+
return nil, err
120+
}
121+
if inst != nil {
122+
instances = append(instances, *inst)
123+
}
124+
}
125+
return instances, nil
111126
}
112127

113128
func (c *SFCClient) TerminateInstance(ctx context.Context, id v1.CloudProviderInstanceID) error {

0 commit comments

Comments
 (0)