Skip to content

Commit

Permalink
fix logs and run using prefix or suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
maruware committed Oct 21, 2020
1 parent 922fe69 commit 7620268
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
3 changes: 1 addition & 2 deletions deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,10 @@ func (a *App) updateService(ctx context.Context, opt DeployOption, nameToTdArn m
color.Green("~ service attributes: %s", fullname)
//TODO: diff

o, err := a.DescribeServices(ctx, []*string{&fullname})
curr, err := a.DescribeService(ctx, &fullname)
if err != nil {
return err
}
curr := o.Services[0]
d, err := diffService(*curr, srv.srv)
if err != nil {
return err
Expand Down
11 changes: 11 additions & 0 deletions ecs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ func (a *App) DescribeServices(ctx context.Context, names []*string) (*ecs.Descr
})
}

func (a *App) DescribeService(ctx context.Context, name *string) (*ecs.Service, error) {
o, err := a.DescribeServices(ctx, []*string{name})
if err != nil {
return nil, err
}
if len(o.Services) == 0 {
return nil, fmt.Errorf("not found service %s", *name)
}
return o.Services[0], nil
}

func (a *App) CreateService(ctx context.Context, cluster string, tdArn string, srv ecs.Service) error {
a.Log("Starting create service", *srv.ServiceName)

Expand Down
12 changes: 6 additions & 6 deletions logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"strconv"
"strings"
"time"

"github.com/aws/aws-sdk-go/aws"
)

type LogsOption struct {
Expand Down Expand Up @@ -67,17 +65,19 @@ func (a *App) Logs(ctx context.Context, name string, opt LogsOption) error {
return err
}

if _, ok := a.def.nameToSrv[name]; !ok {
_, ok := a.def.nameToSrv[name]

if !ok {
return fmt.Errorf("service %s is undefined", name)
}

descSrvs, err := a.DescribeServices(ctx, []*string{aws.String(name)})
fullname := a.resolveFullName(name)

srv, err := a.DescribeService(ctx, &fullname)
if err != nil {
return err
}

srv := descSrvs.Services[0]

tdArn := srv.TaskDefinition
td, err := a.DescribeTaskDefinition(ctx, *tdArn)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ func (a *App) Run(ctx context.Context, name string, opt RunOption) error {
return fmt.Errorf("service %s is undefined", name)
}

descSrvs, err := a.DescribeServices(ctx, []*string{aws.String(name)})
fullname := a.resolveFullName(name)

srv, err := a.DescribeService(ctx, &fullname)
if err != nil {
return err
}

srv := descSrvs.Services[0]

var tdArn *string
var container *ecs.ContainerDefinition

Expand Down

0 comments on commit 7620268

Please sign in to comment.