-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
65 lines (51 loc) · 1.24 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"errors"
"fmt"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ecs"
"github.com/kylelemons/godebug/diff"
)
func validateArgs(args []string) error {
argLength := len(args)
if argLength != 3 {
return errors.New("Two arguments must be specified")
}
return nil
}
func describeTaskDefinition(name string, svc *ecs.ECS) (*ecs.DescribeTaskDefinitionOutput, error) {
input := &ecs.DescribeTaskDefinitionInput{
TaskDefinition: aws.String(name),
}
result, err := svc.DescribeTaskDefinition(input)
if err != nil {
return nil, err
}
return result, nil
}
func main() {
if err := validateArgs(os.Args); err != nil {
fmt.Println(err)
os.Exit(1)
}
srcTaskDef := os.Args[1]
destTaskDef := os.Args[2]
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
}))
svc := ecs.New(sess)
srcResult, err := describeTaskDefinition(srcTaskDef, svc)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
destResult, err := describeTaskDefinition(destTaskDef, svc)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
diff := diff.Diff(srcResult.GoString(), destResult.GoString())
fmt.Println(diff)
}