-
-
Notifications
You must be signed in to change notification settings - Fork 90
/
register.go
47 lines (40 loc) · 918 Bytes
/
register.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
package ecspresso
import (
"context"
"os"
)
type RegisterOption struct {
DryRun bool `help:"dry run" default:"false"`
Output bool `help:"output the registered task definition as JSON" default:"false"`
}
func (opt RegisterOption) DryRunString() string {
if opt.DryRun {
return dryRunStr
}
return ""
}
func (d *App) Register(ctx context.Context, opt RegisterOption) error {
ctx, cancel := d.Start(ctx)
defer cancel()
d.Log("Starting register task definition %s", opt.DryRunString())
td, err := d.LoadTaskDefinition(d.config.TaskDefinitionPath)
if err != nil {
return err
}
if opt.DryRun {
d.Log("task definition:")
if err := d.OutputJSONForAPI(os.Stdout, td); err != nil {
return err
}
d.Log("DRY RUN OK")
return nil
}
newTd, err := d.RegisterTaskDefinition(ctx, td)
if err != nil {
return err
}
if opt.Output {
return d.OutputJSONForAPI(os.Stdout, newTd)
}
return nil
}