Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/clis/nvcf-cli/internal/client/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,16 +360,17 @@ func (c *Client) ListBasicTaskDetails(ctx context.Context, taskIDs []string) (*L
return decodeNVCT[ListBasicTaskDetailsResponse](resp)
}

// GetTask returns full details for a single task. When includeSecrets is true,
// secret values are included in the response (subject to API authorization).
// GetTask returns full details for a single task. includeSecrets controls
// whether secret names are included in the response.
func (c *Client) GetTask(ctx context.Context, taskID string, includeSecrets bool) (*TaskResponse, error) {
if taskID == "" {
return nil, fmt.Errorf("taskId is required")
}
endpoint := fmt.Sprintf("/v1/nvct/tasks/%s", url.PathEscape(taskID))
if includeSecrets {
endpoint += "?includeSecrets=true"
}
endpoint := fmt.Sprintf(
"/v1/nvct/tasks/%s?includeSecrets=%t",
url.PathEscape(taskID),
includeSecrets,
)

resp, err := c.makeNVCTRequest(ctx, "GET", endpoint, nil)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/clis/nvcf-cli/internal/client/tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func TestGetTaskWithSecrets(t *testing.T) {
wantPath string
wantQS string
}{
{"without flag", false, "/v1/nvct/tasks/task-id", ""},
{"without flag", false, "/v1/nvct/tasks/task-id", "includeSecrets=false"},
{"with flag", true, "/v1/nvct/tasks/task-id", "includeSecrets=true"},
}
for _, tt := range tests {
Expand Down
Loading