Skip to content

Commit 021bb19

Browse files
author
Pushkar Acharya
committed
Handle different flag responses
1 parent 083fb62 commit 021bb19

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

internal/crusoe/nfs_flag.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ var (
2424
errUnmarshalFlag = errors.New("failed to unmarshal flag response")
2525
)
2626

27-
type NfsFlagResponse struct {
28-
Status bool `json:"status"`
27+
type FlagResponse struct {
28+
Status bool `json:"status,omitempty"`
29+
Enabled bool `json:"enabled,omitempty"`
2930
}
3031

3132
// getFlag is a helper function to fetch a boolean flag from the API.
@@ -59,14 +60,14 @@ func getFlag(ctx context.Context, crusoeHTTPClient *http.Client, flagRoute strin
5960
return false, fmt.Errorf("%w: HTTP %d: %s", errGetFlag, resp.StatusCode, string(bodyBytes))
6061
}
6162

62-
var flagResponse NfsFlagResponse
63+
var flagResponse FlagResponse
6364

6465
unmarshalErr := json.Unmarshal(bodyBytes, &flagResponse)
6566
if unmarshalErr != nil {
6667
return false, fmt.Errorf("%w: %w (response body: %q)", errUnmarshalFlag, unmarshalErr, string(bodyBytes))
6768
}
6869

69-
return flagResponse.Status, nil
70+
return flagResponse.Status || flagResponse.Enabled, nil
7071
}
7172

7273
// GetNFSFlag returns true if the project has NFS enabled.

0 commit comments

Comments
 (0)