Skip to content

Commit 48fa3a8

Browse files
committed
logging
1 parent 1cb81e7 commit 48fa3a8

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

internal/ankacloud/api.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const (
55
)
66

77
type response struct {
8-
Status string `json:"status"`
9-
Message string `json:"message"`
10-
Body interface{} `json:"body,omitempty"`
8+
Status string `json:"status"`
9+
Message string `json:"message"`
10+
Body any `json:"body,omitempty"`
1111
}
1212

1313
type StartupScriptCondition int

internal/ankacloud/controller.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ func (c *controller) GetAllInstances(ctx context.Context) ([]Instance, error) {
185185
return nil, fmt.Errorf("failed to parse response body %q: %w", string(body), err)
186186
}
187187

188+
log.ConditionalColorf("got %d instances back from controller\n", len(response.Instances))
189+
body, err = json.Marshal(response)
190+
if err != nil {
191+
return nil, fmt.Errorf("failed to marshal response body %q: %w", string(body), err)
192+
}
193+
log.ConditionalColorf("instances response: %s\n", string(body))
194+
188195
var instances []Instance
189196
for _, instanceWrapper := range response.Instances {
190197
instances = append(instances, *instanceWrapper.Instance)
@@ -195,9 +202,11 @@ func (c *controller) GetAllInstances(ctx context.Context) ([]Instance, error) {
195202

196203
func (c *controller) GetInstanceByExternalId(ctx context.Context, externalId string) (*Instance, error) {
197204
instances, err := c.GetAllInstances(ctx)
205+
198206
if len(instances) == 0 {
199-
return nil, fmt.Errorf("no instances returned from controller")
207+
return nil, fmt.Errorf("no instances returned from controller: %w", err)
200208
}
209+
201210
if err != nil {
202211
return nil, fmt.Errorf("failed to get instance by external id %s: %w", externalId, err)
203212
}

0 commit comments

Comments
 (0)