Skip to content

Commit

Permalink
Fix --clusterPool argument override (#360)
Browse files Browse the repository at this point in the history
* fix clusterPool override
* increase coverage

Signed-off-by: Iaroslav Ciupin <iaroslav@union.ai>
  • Loading branch information
iaroslav-ciupin committed Oct 7, 2022
1 parent b484b2f commit 92104a8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions flytectl/cmd/create/execution_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ func resolveOverrides(toBeOverridden *ExecutionConfig, project string, domain st
if executionConfig.Version != "" {
toBeOverridden.Version = executionConfig.Version
}
if executionConfig.ClusterPool != "" {
toBeOverridden.ClusterPool = executionConfig.ClusterPool
}
// Use the root project and domain to launch the task/workflow if target is unspecified
if executionConfig.TargetProject == "" {
toBeOverridden.TargetProject = project
Expand Down
22 changes: 21 additions & 1 deletion flytectl/cmd/create/execution_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"fmt"
"testing"

"github.com/flyteorg/flytectl/cmd/config"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"

"github.com/flyteorg/flytectl/cmd/config"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
Expand Down Expand Up @@ -192,3 +193,22 @@ func TestCreateExecutionRequestForTask(t *testing.T) {
executionConfig.KubeServiceAcct = ""
})
}

func Test_resolveOverrides(t *testing.T) {
executionConfig.KubeServiceAcct = "k8s-acct"
executionConfig.IamRoleARN = "iam-role"
executionConfig.TargetProject = "t-proj"
executionConfig.TargetDomain = "t-domain"
executionConfig.Version = "v1"
executionConfig.ClusterPool = "gpu"
cfg := &ExecutionConfig{}

resolveOverrides(cfg, "p1", "d1")

assert.Equal(t, "k8s-acct", cfg.KubeServiceAcct)
assert.Equal(t, "iam-role", cfg.IamRoleARN)
assert.Equal(t, "t-proj", cfg.TargetProject)
assert.Equal(t, "t-domain", cfg.TargetDomain)
assert.Equal(t, "v1", cfg.Version)
assert.Equal(t, "gpu", cfg.ClusterPool)
}

0 comments on commit 92104a8

Please sign in to comment.