Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Raposo <[email protected]>
  • Loading branch information
RRap0so committed Sep 2, 2024
1 parent 96c799c commit 2ea68d1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 1 addition & 2 deletions flytectl/cmd/get/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package get

import (
"context"

"github.com/flyteorg/flyte/flytectl/cmd/config"
workflowconfig "github.com/flyteorg/flyte/flytectl/cmd/config/subcommand/workflow"
cmdCore "github.com/flyteorg/flyte/flytectl/cmd/core"
Expand Down Expand Up @@ -183,7 +182,7 @@ func FetchWorkflowForName(ctx context.Context, fetcher ext.AdminFetcherExtInterf
domain string) (workflows []*admin.Workflow, isList bool, err error) {
var workflow *admin.Workflow
if workflowconfig.DefaultConfig.Latest {
if workflow, err = fetcher.FetchWorkflowLatestVersion(ctx, name, project, domain, workflowconfig.DefaultConfig.Filter); err != nil {
if workflow, err = fetcher.FetchWorkflowLatestVersion(ctx, name, project, domain); err != nil {
return nil, false, err
}
workflows = append(workflows, workflow)
Expand Down
2 changes: 1 addition & 1 deletion flytectl/pkg/ext/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type AdminFetcherExtInterface interface {
FetchAllVerOfWorkflow(ctx context.Context, name, project, domain string, filter filters.Filters) ([]*admin.Workflow, error)

// FetchWorkflowLatestVersion fetches latest version of workflow in a project, domain
FetchWorkflowLatestVersion(ctx context.Context, name, project, domain string, filter filters.Filters) (*admin.Workflow, error)
FetchWorkflowLatestVersion(ctx context.Context, name, project, domain string) (*admin.Workflow, error)

// FetchWorkflowVersion fetches particular version of workflow in a project, domain
FetchWorkflowVersion(ctx context.Context, name, version, project, domain string) (*admin.Workflow, error)
Expand Down
7 changes: 6 additions & 1 deletion flytectl/pkg/ext/workflow_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ func (a *AdminFetcherExtClient) FetchAllWorkflows(ctx context.Context, project,
}

// FetchWorkflowLatestVersion fetches latest version for given workflow name
func (a *AdminFetcherExtClient) FetchWorkflowLatestVersion(ctx context.Context, name, project, domain string, filter filters.Filters) (*admin.Workflow, error) {
func (a *AdminFetcherExtClient) FetchWorkflowLatestVersion(ctx context.Context, name, project, domain string) (*admin.Workflow, error) {
// Fetch the latest version of the workflow.
filter := filters.Filters{
SortBy: "created_at",
Limit: 1,
Asc: false,
}
wVersions, err := a.FetchAllVerOfWorkflow(ctx, name, project, domain, filter)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions flytectl/pkg/ext/workflow_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ func TestFetchWorkflowLatestVersion(t *testing.T) {
getWorkflowFetcherSetup()
adminClient.OnGetWorkflowMatch(mock.Anything, mock.Anything).Return(workflowResponse, nil)
adminClient.OnListWorkflowsMatch(mock.Anything, mock.Anything).Return(workflowListResponse, nil)
_, err := adminFetcherExt.FetchWorkflowLatestVersion(ctx, "workflowName", "project", "domain", workflowFilter)
_, err := adminFetcherExt.FetchWorkflowLatestVersion(ctx, "workflowName", "project", "domain")
assert.Nil(t, err)
}

func TestFetchWorkflowLatestVersionError(t *testing.T) {
workflowListResponse := &admin.WorkflowList{}
getWorkflowFetcherSetup()
adminClient.OnListWorkflowsMatch(mock.Anything, mock.Anything).Return(workflowListResponse, nil)
_, err := adminFetcherExt.FetchWorkflowLatestVersion(ctx, "workflowName", "project", "domain", workflowFilter)
_, err := adminFetcherExt.FetchWorkflowLatestVersion(ctx, "workflowName", "project", "domain")
assert.Equal(t, fmt.Errorf("no workflow retrieved for workflowName"), err)
}

0 comments on commit 2ea68d1

Please sign in to comment.