diff --git a/README.md b/README.md index 1ca1009c..80c0fd89 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ $ asdf plugin add ecspresso # or $ asdf plugin add ecspresso https://github.com/kayac/asdf-ecspresso.git -$ asdf install ecspresso 2.0.0 -$ asdf global ecspresso 2.0.0 +$ asdf install ecspresso 2.3.0 +$ asdf global ecspresso 2.3.0 ``` ### aqua (macOS and Linux) @@ -49,13 +49,13 @@ https://circleci.com/orbs/registry/orb/fujiwara/ecspresso ```yaml version: 2.1 orbs: - ecspresso: fujiwara/ecspresso@2.0.3 + ecspresso: fujiwara/ecspresso@2.3.0 jobs: install: steps: - checkout - ecspresso/install: - version: v2.0.0 # or latest + version: v2.3.0 # or latest # version-file: .ecspresso-version - run: command: | @@ -86,7 +86,7 @@ jobs: - uses: actions/checkout@v3 - uses: kayac/ecspresso@v2 with: - version: v2.0.0 # or latest + version: v2.3.0 # or latest # version-file: .ecspresso-version - run: | ecspresso deploy --config ecspresso.yml @@ -108,7 +108,7 @@ Pass the parameter "latest" to use the latest version of ecspresso. `version: latest` is not recommended because it may cause unexpected behavior when the new version of ecspresso is released. -GitHub Action `kayac/ecspresso@v2` supports `version-file: path/to/file` installs ecspresso that version written in the file. This version number does not have `v` prefix, For example `2.0.0`. +GitHub Action `kayac/ecspresso@v2` supports `version-file: path/to/file` installs ecspresso that version written in the file. This version number does not have `v` prefix, For example `2.3.0`. ## Usage @@ -117,13 +117,14 @@ Usage: ecspresso Flags: -h, --help Show context-sensitive help. - --envfile=ENVFILE,... environment files - --debug enable debug log - --ext-str=KEY=VALUE;... external string values for Jsonnet - --ext-code=KEY=VALUE;... external code values for Jsonnet - --config="ecspresso.yml" config file - --assume-role-arn="" the ARN of the role to assume - --option=OPTION + --envfile=ENVFILE,... environment files ($ECSPRESSO_ENVFILE) + --debug enable debug log ($ECSPRESSO_DEBUG) + --ext-str=KEY=VALUE;... external string values for Jsonnet ($ECSPRESSO_EXT_STR) + --ext-code=KEY=VALUE;... external code values for Jsonnet ($ECSPRESSO_EXT_CODE) + --config="ecspresso.yml" config file ($ECSPRESSO_CONFIG) + --assume-role-arn="" the ARN of the role to assume ($ECSPRESSO_ASSUME_ROLE_ARN) + --timeout=TIMEOUT timeout. Override in a configuration file ($ECSPRESSO_TIMEOUT). + --filter-command=STRING filter command ($ECSPRESSO_FILTER_COMMAND) Commands: appspec diff --git a/cli.go b/cli.go index 301c3b36..1e39bb36 100644 --- a/cli.go +++ b/cli.go @@ -4,10 +4,18 @@ import ( "context" "fmt" "os" + "time" ) type CLIOptions struct { - Option + Envfile []string `help:"environment files" env:"ECSPRESSO_ENVFILE"` + Debug bool `help:"enable debug log" env:"ECSPRESSO_DEBUG"` + ExtStr map[string]string `help:"external string values for Jsonnet" env:"ECSPRESSO_EXT_STR"` + ExtCode map[string]string `help:"external code values for Jsonnet" env:"ECSPRESSO_EXT_CODE"` + ConfigFilePath string `name:"config" help:"config file" default:"ecspresso.yml" env:"ECSPRESSO_CONFIG"` + AssumeRoleARN string `help:"the ARN of the role to assume" default:"" env:"ECSPRESSO_ASSUME_ROLE_ARN"` + Timeout *time.Duration `help:"timeout. Override in a configuration file." env:"ECSPRESSO_TIMEOUT"` + FilterCommand string `help:"filter command" env:"ECSPRESSO_FILTER_COMMAND"` Appspec *AppSpecOption `cmd:"" help:"output AppSpec YAML for CodeDeploy to STDOUT"` Delete *DeleteOption `cmd:"" help:"delete service"` @@ -30,6 +38,24 @@ type CLIOptions struct { Version struct{} `cmd:"" help:"show version"` } +func (opt *CLIOptions) resolveConfigFilePath() (path string) { + path = DefaultConfigFilePath + defer func() { + opt.ConfigFilePath = path + }() + if opt.ConfigFilePath != "" && opt.ConfigFilePath != DefaultConfigFilePath { + path = opt.ConfigFilePath + return + } + for _, ext := range []string{ymlExt, yamlExt, jsonExt, jsonnetExt} { + if _, err := os.Stat("ecspresso" + ext); err == nil { + path = "ecspresso" + ext + return + } + } + return +} + func (opts *CLIOptions) ForSubCommand(sub string) interface{} { switch sub { case "appspec": @@ -79,8 +105,15 @@ func dispatchCLI(ctx context.Context, sub string, usage func(), opts *CLIOptions fmt.Println("ecspresso", Version) return nil } - - app, err := New(ctx, &opts.Option) + var appOpts []AppOption + if sub == "init" { + config, err := opts.Init.NewConfig(ctx, opts.ConfigFilePath) + if err != nil { + return err + } + appOpts = append(appOpts, WithConfig(config)) + } + app, err := New(ctx, opts, appOpts...) if err != nil { return err } diff --git a/cli_test.go b/cli_test.go index aefcdc07..cd746fe4 100644 --- a/cli_test.go +++ b/cli_test.go @@ -12,7 +12,7 @@ import ( var cliTests = []struct { args []string sub string - option *ecspresso.Option + option *ecspresso.CLIOptions subOption any fn func(*testing.T, any) }{ @@ -28,13 +28,12 @@ var cliTests = []struct { "--assume-role-arn", "arn:aws:iam::123456789012:role/exampleRole", }, sub: "status", - option: &ecspresso.Option{ + option: &ecspresso.CLIOptions{ ConfigFilePath: "config.yml", Debug: true, Envfile: []string{"tests/envfile"}, ExtStr: map[string]string{"s1": "v1", "s2": "v2"}, ExtCode: map[string]string{"c1": "123", "c2": "1+2"}, - InitOption: nil, AssumeRoleARN: "arn:aws:iam::123456789012:role/exampleRole", }, subOption: &ecspresso.StatusOption{ @@ -54,12 +53,11 @@ var cliTests = []struct { "--events=100", }, sub: "status", - option: &ecspresso.Option{ + option: &ecspresso.CLIOptions{ ConfigFilePath: "config.yml", Debug: true, ExtStr: map[string]string{}, ExtCode: map[string]string{}, - InitOption: nil, AssumeRoleARN: "", }, subOption: &ecspresso.StatusOption{ @@ -587,7 +585,6 @@ var cliTests = []struct { subOption: &ecspresso.InitOption{ Region: os.Getenv("AWS_REGION"), Cluster: "default", - ConfigFilePath: "myconfig.yml", Service: "myservice", TaskDefinitionPath: "ecs-task-def.json", ServiceDefinitionPath: "ecs-service-def.json", @@ -598,17 +595,7 @@ var cliTests = []struct { { args: []string{"init", "--service", "myservice", "--config", "myconfig.yml"}, sub: "init", - option: &ecspresso.Option{ - InitOption: &ecspresso.InitOption{ - Region: os.Getenv("AWS_REGION"), - Cluster: "default", - ConfigFilePath: "myconfig.yml", - Service: "myservice", - TaskDefinitionPath: "ecs-task-def.json", - ServiceDefinitionPath: "ecs-service-def.json", - ForceOverwrite: false, - Jsonnet: false, - }, + option: &ecspresso.CLIOptions{ ConfigFilePath: "myconfig.yml", Debug: false, ExtStr: map[string]string{}, @@ -617,7 +604,6 @@ var cliTests = []struct { subOption: &ecspresso.InitOption{ Region: os.Getenv("AWS_REGION"), Cluster: "default", - ConfigFilePath: "myconfig.yml", Service: "myservice", TaskDefinitionPath: "ecs-task-def.json", ServiceDefinitionPath: "ecs-service-def.json", @@ -636,7 +622,6 @@ var cliTests = []struct { subOption: &ecspresso.InitOption{ Region: os.Getenv("AWS_REGION"), Cluster: "mycluster", - ConfigFilePath: "myconfig.jsonnet", Service: "myservice", TaskDefinitionPath: "taskdef.jsonnet", ServiceDefinitionPath: "servicedef.jsonnet", @@ -650,7 +635,6 @@ var cliTests = []struct { subOption: &ecspresso.InitOption{ Region: os.Getenv("AWS_REGION"), Cluster: "default", - ConfigFilePath: "myconfig.yml", Service: "", TaskDefinition: "app:123", TaskDefinitionPath: "ecs-task-def.json", @@ -798,7 +782,7 @@ func TestParseCLIv2(t *testing.T) { t.Errorf("unexpected subcommand: expected %s, got %s", tt.sub, sub) } if tt.option != nil { - if diff := cmp.Diff(*tt.option, opt.Option); diff != "" { + if diff := cmp.Diff(tt.option, CLIOptionsGlobalOnly(opt)); diff != "" { t.Errorf("unexpected option: diff %s", diff) } } @@ -813,3 +797,16 @@ func TestParseCLIv2(t *testing.T) { }) } } + +func CLIOptionsGlobalOnly(opts *ecspresso.CLIOptions) *ecspresso.CLIOptions { + return &ecspresso.CLIOptions{ + ConfigFilePath: opts.ConfigFilePath, + Debug: opts.Debug, + ExtStr: opts.ExtStr, + ExtCode: opts.ExtCode, + Envfile: opts.Envfile, + AssumeRoleARN: opts.AssumeRoleARN, + Timeout: opts.Timeout, + FilterCommand: opts.FilterCommand, + } +} diff --git a/cliv2.go b/cliv2.go index ae7ec13b..37903da4 100644 --- a/cliv2.go +++ b/cliv2.go @@ -30,16 +30,11 @@ func ParseCLIv2(args []string) (string, *CLIOptions, func(), error) { } } - if opts.Option.ExtStr == nil { - opts.Option.ExtStr = map[string]string{} + if opts.ExtStr == nil { + opts.ExtStr = map[string]string{} } - if opts.Option.ExtCode == nil { - opts.Option.ExtCode = map[string]string{} - } - switch sub { - case "init": - opts.Init.ConfigFilePath = opts.ConfigFilePath - opts.Option.InitOption = opts.Init + if opts.ExtCode == nil { + opts.ExtCode = map[string]string{} } return sub, &opts, func() { c.PrintUsage(true) }, nil } diff --git a/config.go b/config.go index 2dfbf445..f8e92c1e 100644 --- a/config.go +++ b/config.go @@ -112,7 +112,7 @@ func (l *configLoader) Load(ctx context.Context, path string, version string) (* return conf, nil } -func (c *Config) OverrideByOption(opt *Option) { +func (c *Config) OverrideByCLIOptions(opt *CLIOptions) { if opt.Timeout != nil { c.Timeout = &Duration{*opt.Timeout} } diff --git a/config_test.go b/config_test.go index 51d17c75..1c753afc 100644 --- a/config_test.go +++ b/config_test.go @@ -13,7 +13,7 @@ import ( func TestLoadServiceDefinition(t *testing.T) { ctx := context.Background() - app, err := ecspresso.New(ctx, &ecspresso.Option{ConfigFilePath: "tests/test.yaml"}) + app, err := ecspresso.New(ctx, &ecspresso.CLIOptions{ConfigFilePath: "tests/test.yaml"}) if err != nil { t.Error(err) } @@ -89,7 +89,7 @@ func testLoadConfigWithPlugin(t *testing.T, path string) { t.Setenv("JSON", `{"foo":"bar"}`) t.Setenv("AWS_REGION", "ap-northeast-1") ctx := context.Background() - app, err := ecspresso.New(ctx, &ecspresso.Option{ConfigFilePath: path}) + app, err := ecspresso.New(ctx, &ecspresso.CLIOptions{ConfigFilePath: path}) if err != nil { t.Error(err) } @@ -311,7 +311,7 @@ var FilterCommandTests = []struct { func TestFilterCommandDeprecated(t *testing.T) { ctx := context.Background() for _, ts := range FilterCommandTests { - app, err := ecspresso.New(ctx, &ecspresso.Option{ + app, err := ecspresso.New(ctx, &ecspresso.CLIOptions{ ConfigFilePath: "tests/filter_command.yml", FilterCommand: ts.Env, }) diff --git a/ecspresso.go b/ecspresso.go index 3c2a9abb..0a6d6586 100644 --- a/ecspresso.go +++ b/ecspresso.go @@ -109,33 +109,64 @@ type App struct { logger *log.Logger } -func New(ctx context.Context, opt *Option) (*App, error) { +type appOptions struct { + config *Config + loader *configLoader + logger *log.Logger +} + +type AppOption func(*appOptions) + +func WithConfig(c *Config) AppOption { + return func(o *appOptions) { + o.config = c + } +} + +func WithConfigLoader(extstr, extcode map[string]string) AppOption { + return func(o *appOptions) { + o.loader = newConfigLoader(extstr, extcode) + } +} + +func WithLogger(l *log.Logger) AppOption { + return func(o *appOptions) { + o.logger = l + } +} + +func New(ctx context.Context, opt *CLIOptions, newAppOptions ...AppOption) (*App, error) { opt.resolveConfigFilePath() - loader := newConfigLoader(opt.ExtStr, opt.ExtCode) - var ( - conf *Config - err error - ) - if opt.InitOption != nil { - conf, err = opt.InitOption.NewConfig(ctx) - if err != nil { - return nil, fmt.Errorf("failed to initialize config: %w", err) - } + + appOpts := appOptions{ + loader: newConfigLoader(opt.ExtStr, opt.ExtCode), + logger: newLogger(), + } + for _, fn := range newAppOptions { + fn(&appOpts) + } + + // set log level + if opt.Debug { + appOpts.logger.SetOutput(newLogFilter(os.Stderr, "DEBUG")) } else { - conf, err = loader.Load(ctx, opt.ConfigFilePath, Version) - if err != nil { + appOpts.logger.SetOutput(newLogFilter(os.Stderr, "INFO")) + } + Log("[INFO] ecspresso version: %s", Version) + + // load config file + if appOpts.config == nil { + if config, err := appOpts.loader.Load(ctx, opt.ConfigFilePath, Version); err != nil { return nil, fmt.Errorf("failed to load config file %s: %w", opt.ConfigFilePath, err) + } else { + appOpts.config = config } } - conf.OverrideByOption(opt) + conf := appOpts.config + conf.OverrideByCLIOptions(opt) conf.AssumeRole(opt.AssumeRoleARN) - logger := newLogger() - if opt.Debug { - logger.SetOutput(newLogFilter(os.Stderr, "DEBUG")) - } else { - logger.SetOutput(newLogFilter(os.Stderr, "INFO")) - } + // new app d := &App{ Service: conf.Service, Cluster: conf.Cluster, @@ -147,11 +178,11 @@ func New(ctx context.Context, opt *Option) (*App, error) { iam: iam.NewFromConfig(conf.awsv2Config), elbv2: elasticloadbalancingv2.NewFromConfig(conf.awsv2Config), sd: servicediscovery.NewFromConfig(conf.awsv2Config), - - config: conf, - loader: loader, - logger: logger, + loader: appOpts.loader, + config: appOpts.config, + logger: appOpts.logger, } + d.Log("[DEBUG] config file path: %s", opt.ConfigFilePath) d.Log("[DEBUG] timeout: %s", d.config.Timeout) return d, nil @@ -173,40 +204,6 @@ func (d *App) Start(ctx context.Context) (context.Context, context.CancelFunc) { } } -type Option struct { - InitOption *InitOption - - Envfile []string `help:"environment files" env:"ECSPRESSO_ENVFILE"` - Debug bool `help:"enable debug log" env:"ECSPRESSO_DEBUG"` - ExtStr map[string]string `help:"external string values for Jsonnet" env:"ECSPRESSO_EXT_STR"` - ExtCode map[string]string `help:"external code values for Jsonnet" env:"ECSPRESSO_EXT_CODE"` - ConfigFilePath string `name:"config" help:"config file" default:"ecspresso.yml" env:"ECSPRESSO_CONFIG"` - AssumeRoleARN string `help:"the ARN of the role to assume" default:"" env:"ECSPRESSO_ASSUME_ROLE_ARN"` - Timeout *time.Duration `help:"timeout. Override in a configuration file." env:"ECSPRESSO_TIMEOUT"` - FilterCommand string `help:"filter command" env:"ECSPRESSO_FILTER_COMMAND"` -} - -func (opt *Option) resolveConfigFilePath() (path string) { - path = DefaultConfigFilePath - defer func() { - opt.ConfigFilePath = path - if opt.InitOption != nil { - opt.InitOption.ConfigFilePath = path - } - }() - if opt.ConfigFilePath != "" && opt.ConfigFilePath != DefaultConfigFilePath { - path = opt.ConfigFilePath - return - } - for _, ext := range []string{ymlExt, yamlExt, jsonExt, jsonnetExt} { - if _, err := os.Stat("ecspresso" + ext); err == nil { - path = "ecspresso" + ext - return - } - } - return -} - func (d *App) DescribeServicesInput() *ecs.DescribeServicesInput { return &ecs.DescribeServicesInput{ Cluster: aws.String(d.Cluster), diff --git a/ecspresso_test.go b/ecspresso_test.go index 85b13866..e67c2d62 100644 --- a/ecspresso_test.go +++ b/ecspresso_test.go @@ -20,7 +20,7 @@ func TestLoadTaskDefinition(t *testing.T) { "tests/td-plain-in-tags.json", "tests/td.jsonnet", } { - app, err := ecspresso.New(ctx, &ecspresso.Option{ + app, err := ecspresso.New(ctx, &ecspresso.CLIOptions{ ConfigFilePath: "tests/td-config.yml", ExtStr: map[string]string{"WorkerID": "3"}, ExtCode: map[string]string{"EphemeralStorage": "24 + 1"}, // == 25 @@ -48,7 +48,7 @@ func TestLoadTaskDefinition(t *testing.T) { func TestLoadTaskDefinitionTags(t *testing.T) { ctx := context.Background() for _, path := range []string{"tests/td.json", "tests/td-plain.json", "tests/td.jsonnet"} { - app, err := ecspresso.New(ctx, &ecspresso.Option{ + app, err := ecspresso.New(ctx, &ecspresso.CLIOptions{ ConfigFilePath: "tests/td-config.yml", ExtStr: map[string]string{"WorkerID": "3"}, ExtCode: map[string]string{"EphemeralStorage": "24 + 1"}, // == 25 @@ -66,7 +66,7 @@ func TestLoadTaskDefinitionTags(t *testing.T) { } for _, path := range []string{"tests/td-in-tags.json", "tests/td-plain-in-tags.json"} { - app, err := ecspresso.New(ctx, &ecspresso.Option{ConfigFilePath: "tests/td-config.yml"}) + app, err := ecspresso.New(ctx, &ecspresso.CLIOptions{ConfigFilePath: "tests/td-config.yml"}) if err != nil { t.Error(err) } diff --git a/envfile.go b/envfile.go index b34a83a4..606bd4b1 100644 --- a/envfile.go +++ b/envfile.go @@ -11,6 +11,7 @@ func ExportEnvFile(file string) error { if file == "" { return nil } + Log("[DEBUG] loading envfile: %s", file) f, err := os.Open(file) if err != nil { diff --git a/init.go b/init.go index cba44b97..51e5b35a 100644 --- a/init.go +++ b/init.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/Songmu/prompter" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/ecs" "github.com/aws/aws-sdk-go-v2/service/ecs/types" "github.com/goccy/go-yaml" @@ -25,14 +26,13 @@ type InitOption struct { TaskDefinitionPath string `help:"path to output task definition file" default:"ecs-task-def.json"` ServiceDefinitionPath string `help:"path to output service definition file" default:"ecs-service-def.json"` Sort bool `help:"sort elements in task definition" default:"false" negatable:""` - ConfigFilePath string - ForceOverwrite bool `help:"overwrite existing files" default:"false"` - Jsonnet bool `help:"output files as jsonnet format" default:"false"` + ForceOverwrite bool `help:"overwrite existing files" default:"false"` + Jsonnet bool `help:"output files as jsonnet format" default:"false"` } -func (opt *InitOption) NewConfig(ctx context.Context) (*Config, error) { +func (opt *InitOption) NewConfig(ctx context.Context, configFilePath string) (*Config, error) { conf := NewDefaultConfig() - conf.path = opt.ConfigFilePath + conf.path = configFilePath conf.Region = opt.Region conf.Cluster = opt.Cluster conf.Service = opt.Service @@ -64,19 +64,16 @@ func (d *App) Init(ctx context.Context, opt InitOption) error { if ext := filepath.Ext(conf.TaskDefinitionPath); ext == jsonExt { conf.TaskDefinitionPath = strings.TrimSuffix(conf.TaskDefinitionPath, ext) + jsonnetExt } - if ext := filepath.Ext(opt.ConfigFilePath); ext == ymlExt || ext == yamlExt { - opt.ConfigFilePath = strings.TrimSuffix(opt.ConfigFilePath, ext) + jsonnetExt + if ext := filepath.Ext(conf.path); ext == ymlExt || ext == yamlExt { + conf.path = strings.TrimSuffix(conf.path, ext) + jsonnetExt } } - if err := conf.Restrict(ctx); err != nil { - return err - } - var err error var sv *Service var tdArn string if tdOnly { tdArn = opt.TaskDefinition } else { + var err error sv, tdArn, err = d.initServiceDefinition(ctx, opt) if err != nil { return err @@ -86,13 +83,13 @@ func (d *App) Init(ctx context.Context, opt InitOption) error { if err != nil { return err } - if err := d.initConfigurationFile(ctx, opt, sv, td); err != nil { + if err := d.initConfigurationFile(ctx, conf.path, opt, sv, td); err != nil { return err } return nil } -func (d *App) initConfigurationFile(ctx context.Context, opt InitOption, sv *Service, td *TaskDefinitionInput) error { +func (d *App) initConfigurationFile(ctx context.Context, configFilePath string, opt InitOption, sv *Service, td *TaskDefinitionInput) error { conf := d.config if sv == nil { // tdOnly @@ -118,7 +115,7 @@ func (d *App) initConfigurationFile(ctx context.Context, opt InitOption, sv *Ser if err != nil { return fmt.Errorf("unable to marshal config to JSON: %w", err) } - out, err := formatter.Format(opt.ConfigFilePath, string(b), formatter.DefaultOptions()) + out, err := formatter.Format(configFilePath, string(b), formatter.DefaultOptions()) if err != nil { return fmt.Errorf("unable to format config as Jsonnet: %w", err) } @@ -129,8 +126,8 @@ func (d *App) initConfigurationFile(ctx context.Context, opt InitOption, sv *Ser return fmt.Errorf("unable to marshal config to YAML: %w", err) } } - d.Log("save config to %s", opt.ConfigFilePath) - if err := d.saveFile(opt.ConfigFilePath, b, CreateFileMode, opt.ForceOverwrite); err != nil { + d.Log("save the config to %s", configFilePath) + if err := d.saveFile(configFilePath, b, CreateFileMode, opt.ForceOverwrite); err != nil { return err } } @@ -151,8 +148,8 @@ func (d *App) initServiceDefinition(ctx context.Context, opt InitOption) (*Servi if err != nil { return nil, "", fmt.Errorf("failed to describe service: %w", err) } - - if long, _ := isLongArnFormat(*sv.ServiceArn); long { + svArn := aws.ToString(sv.ServiceArn) + if long, _ := isLongArnFormat(svArn); long { // Long arn format must be used for tagging operations lt, err := d.ecs.ListTagsForResource(ctx, &ecs.ListTagsForResourceInput{ ResourceArn: sv.ServiceArn, @@ -175,7 +172,7 @@ func (d *App) initServiceDefinition(ctx context.Context, opt InitOption) (*Servi } b = []byte(out) } - d.Log("save service definition to %s", conf.ServiceDefinitionPath) + d.Log("save the service definition %s to %s", svArn, conf.ServiceDefinitionPath) if err := d.saveFile(conf.ServiceDefinitionPath, b, CreateFileMode, opt.ForceOverwrite); err != nil { return nil, "", err } @@ -202,7 +199,7 @@ func (d *App) initTaskDefinition(ctx context.Context, opt InitOption, tdArn stri } b = []byte(out) } - d.Log("save task definition to %s", conf.TaskDefinitionPath) + d.Log("save the task definition %s to %s", tdArn, conf.TaskDefinitionPath) if err := d.saveFile(conf.TaskDefinitionPath, b, CreateFileMode, opt.ForceOverwrite); err != nil { return nil, err } diff --git a/run_test.go b/run_test.go index b7a69c2f..d65dbb7e 100644 --- a/run_test.go +++ b/run_test.go @@ -99,7 +99,7 @@ func TestTaskDefinitionArnForRun(t *testing.T) { }) defer ecspresso.ResetAWSV2ConfigLoadOptionsFunc() for config, suites := range testTaskDefinitionArnForRunSuite { - app, err := ecspresso.New(ctx, &ecspresso.Option{ConfigFilePath: config}) + app, err := ecspresso.New(ctx, &ecspresso.CLIOptions{ConfigFilePath: config}) if err != nil { t.Error(err) continue diff --git a/tests/ci/ecs-task-def.json b/tests/ci/ecs-task-def.json index 6df1a5a0..d316eb3a 100644 --- a/tests/ci/ecs-task-def.json +++ b/tests/ci/ecs-task-def.json @@ -4,7 +4,7 @@ "cpu": 0, "environment": [ { - "name": "FOO", + "name": "FOO_ENV", "value": "{{ ssm `/ecspresso-test/foo` }}" }, { @@ -34,7 +34,7 @@ ], "secrets": [ { - "name": "FOO", + "name": "FOO_SECRETS", "valueFrom": "/ecspresso-test/foo" }, {