-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cli] refactor cmd
tasks
and ports
supervisor related func
- Loading branch information
1 parent
0723994
commit 440259a
Showing
8 changed files
with
98 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
components/gitpod-cli/pkg/supervisor-helper/status-tasks.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2022 Gitpod GmbH. All rights reserved. | ||
// Licensed under the GNU Affero General Public License (AGPL). | ||
// See License-AGPL.txt in the project root for license information. | ||
|
||
package supervisor_helper | ||
|
||
import ( | ||
"context" | ||
|
||
supervisor "github.com/gitpod-io/gitpod/supervisor/api" | ||
"golang.org/x/xerrors" | ||
) | ||
|
||
func GetTasksList(ctx context.Context) ([]*supervisor.TaskStatus, error) { | ||
client := supervisor.NewStatusServiceClient(conn) | ||
respClient, err := client.TasksStatus(ctx, &supervisor.TasksStatusRequest{Observe: false}) | ||
if err != nil { | ||
return nil, xerrors.Errorf("failed get tasks status client: %w", err) | ||
} | ||
resp, err := respClient.Recv() | ||
if err != nil { | ||
return nil, xerrors.Errorf("failed receive data: %w", err) | ||
} | ||
return resp.GetTasks(), nil | ||
} | ||
|
||
func GetTasksListByState(ctx context.Context, filterState supervisor.TaskState) ([]*supervisor.TaskStatus, error) { | ||
tasks, err := GetTasksList(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var filteredTasks []*supervisor.TaskStatus | ||
for _, task := range tasks { | ||
if task.State == filterState { | ||
filteredTasks = append(filteredTasks, task) | ||
} | ||
} | ||
return filteredTasks, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.