Skip to content

Commit

Permalink
adding consoleUrl parameterization based on partition (#4375)
Browse files Browse the repository at this point in the history
* adding consoleUrl parameterization based on partition

Signed-off-by: Laura Lin <[email protected]>

* Update plugin.go

Signed-off-by: Laura Lin <[email protected]>

* Update plugin_test.go

Signed-off-by: Laura Lin <[email protected]>

* lint

Signed-off-by: Laura Lin <[email protected]>

---------

Signed-off-by: Laura Lin <[email protected]>
Co-authored-by: Kevin Su <[email protected]>
  • Loading branch information
lauralindy and pingsutw authored Nov 11, 2023
1 parent 21b92f4 commit 31748fe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion flyteplugins/go/tasks/plugins/webapi/athena/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package athena
import (
"context"
"fmt"
"strings"
"time"

awsSdk "github.com/aws/aws-sdk-go-v2/aws"
Expand Down Expand Up @@ -177,12 +178,19 @@ func (p Plugin) Status(ctx context.Context, tCtx webapi.StatusContext) (phase co

func createTaskInfo(queryID string, cfg awsSdk.Config) *core.TaskInfo {
timeNow := time.Now()
var consoleURL string
if strings.Contains(cfg.Region, "gov") {
consoleURL = "console.amazonaws-us-gov.com"
} else {
consoleURL = "console.aws.amazon.com"
}
return &core.TaskInfo{
OccurredAt: &timeNow,
Logs: []*idlCore.TaskLog{
{
Uri: fmt.Sprintf("https://%v.console.aws.amazon.com/athena/home?force&region=%v#query/history/%v",
Uri: fmt.Sprintf("https://%v.%v/athena/home?force&region=%v#query/history/%v",
cfg.Region,
consoleURL,
cfg.Region,
queryID),
Name: "Athena Query Console",
Expand Down
15 changes: 15 additions & 0 deletions flyteplugins/go/tasks/plugins/webapi/athena/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ func TestCreateTaskInfo(t *testing.T) {
assert.Len(t, taskInfo.ExternalResources, 1)
assert.Equal(t, taskInfo.ExternalResources[0].ExternalID, "query_id")
}


func TestCreateTaskInfoGovAWS(t *testing.T) {
taskInfo := createTaskInfo("query_id", awsSdk.Config{
Region: "us-gov-east-1",
})
assert.EqualValues(t, []*idlCore.TaskLog{
{
Uri: "https://us-gov-east-1.console.amazonaws-us-gov.com/athena/home?force&region=us-gov-east-1#query/history/query_id",
Name: "Athena Query Console",
},
}, taskInfo.Logs)
assert.Len(t, taskInfo.ExternalResources, 1)
assert.Equal(t, taskInfo.ExternalResources[0].ExternalID, "query_id")
}

0 comments on commit 31748fe

Please sign in to comment.