-
Notifications
You must be signed in to change notification settings - Fork 0
/
get.go
48 lines (38 loc) · 941 Bytes
/
get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package gjobctl
import (
"context"
"encoding/json"
"fmt"
"time"
"github.com/aws/aws-sdk-go/service/glue"
)
const (
TimeoutForGet = 5 * time.Second
)
type GetOption struct {
JobName *string `arg:"" name:"jobname" help:"enter the name of the Glue Job to be getted"`
}
func (app *App) Get(ctx context.Context, opt *GetOption) error {
ctx, cancel := context.WithTimeout(ctx, TimeoutForGet)
defer cancel()
// AWSのセッションを作成
sess, err := app.createAWSSession()
if err != nil {
return err
}
// Glueのクライアントを作成
sv := glue.New(sess)
// Job名を指定
jobName := *opt.JobName
// Glue Jobの情報を取得
result, err := sv.GetJobWithContext(ctx, &glue.GetJobInput{
JobName: &jobName,
})
if err != nil {
return fmt.Errorf("failed to get job: %w", err)
}
// 取得したJob情報を表示
job, _ := json.MarshalIndent(result, "", " ")
fmt.Println(string(job))
return nil
}