Skip to content

Commit

Permalink
Add public docstrings, cleanup formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
SoManyHs committed Jun 11, 2019
1 parent 52b4b0d commit d734cc9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ecs-cli/modules/cli/local/create_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/urfave/cli"
)

// Create reads in an ECS task definition, converts and writes it to a local
// Docker Compose file
func Create(c *cli.Context) {
project := localproject.New(c)

Expand Down
11 changes: 10 additions & 1 deletion ecs-cli/modules/cli/local/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
LocalInFileName = "./task-definition.json"
)

// Interface for a local project, holding data needed to convert an ECS Task Definition to a Docker Compose file
type LocalProject interface {
ReadTaskDefinition() error
Convert() error
Expand All @@ -52,19 +53,24 @@ type localProject struct {
localOutFileName string
}

// New instantiates a new Local Project
func New(context *cli.Context) LocalProject {
p := &localProject{context: context}
return p
}

// TaskDefinition returns the ECS task definition to be converted
func (p *localProject) TaskDefinition() *ecs.TaskDefinition {
return p.taskDefinition
}

// LocalOutFileName returns name of compose file output by local.Create
func (p *localProject) LocalOutFileName() string {
return p.localOutFileName
}

// ReadTaskDefinition reads an ECS Task Definition either from a local file
// or from retrieving one from ECS and stores it on the local project
func (p *localProject) ReadTaskDefinition() error {
arn := p.context.String(flags.TaskDefinitionArnFlag)
filename := p.context.String(flags.TaskDefinitionFileFlag)
Expand All @@ -87,7 +93,7 @@ func (p *localProject) ReadTaskDefinition() error {
return err
}
} else if _, err := os.Stat(LocalInFileName); err == nil {
// Try reading local task-definition.json file by default
// Try reading local task-definition.json file by default
taskDefinition, err = p.readTaskDefinitionFromFile(LocalInFileName)
if err != nil {
return err
Expand Down Expand Up @@ -138,6 +144,8 @@ func (p *localProject) readTaskDefinitionFromArn(arn string) (*ecs.TaskDefinitio
return ecsClient.DescribeTaskDefinition(arn)
}

// Convert translates an ECS Task Definition into a Compose V3 schema and
// stores the data on the project
func (p *localProject) Convert() error {
// FIXME get secrets here, pass to converter?
data, err := converter.ConvertToDockerCompose(p.taskDefinition)
Expand All @@ -151,6 +159,7 @@ func (p *localProject) Convert() error {
return nil
}

// Write writes the compose data to a local compose file. The output filename is stored on the project
func (p *localProject) Write() error {
// Will error if the file already exists, otherwise create

Expand Down
1 change: 0 additions & 1 deletion ecs-cli/modules/clients/aws/secretsmanager/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ func (c *secretsManagerClient) GetSecretValue(secretName string) (string, error)
output, err := c.client.GetSecretValue(input)

if err != nil {
// return nil, err
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case secretsmanager.ErrCodeDecryptionFailure:
Expand Down

0 comments on commit d734cc9

Please sign in to comment.