Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Initialize EnvDescriber in init command for svc and job #4253

Merged
merged 15 commits into from
Dec 6, 2022
Merged
23 changes: 23 additions & 0 deletions internal/pkg/cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

awscfn "github.com/aws/copilot-cli/internal/pkg/aws/cloudformation"
"github.com/aws/copilot-cli/internal/pkg/aws/iam"
"github.com/aws/copilot-cli/internal/pkg/describe"
"github.com/aws/copilot-cli/internal/pkg/docker/dockerfile"

"github.com/aws/copilot-cli/internal/pkg/deploy"
Expand Down Expand Up @@ -264,6 +265,17 @@ func newInitOpts(vars initVars) (*initOpts, error) {
initParser: func(s string) dockerfileParser {
return dockerfile.New(fs, s)
},
initEnvDescriber: func(appName string, envName string) (envDescriber, error) {
envDescriber, err := describe.NewEnvDescriber(describe.NewEnvDescriberConfig{
App: appName,
Env: envName,
ConfigStore: configStore,
})
if err != nil {
return nil, fmt.Errorf("initiate env describer: %w", err)
Copy link
Contributor

@huanjani huanjani Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (here and below):
"initialize" instead of "initiate"?

nvm "initiate" is all over our codebase

}
return envDescriber, nil
},
}
o.initWlCmd = &opts
o.schedule = &opts.schedule // Surfaced via pointer for logging
Expand Down Expand Up @@ -292,6 +304,17 @@ func newInitOpts(vars initVars) (*initOpts, error) {
opts.df = dockerfile.New(opts.fs, opts.dockerfilePath)
return opts.df
}
opts.initEnvDescriber = func(appName string, envName string) (envDescriber, error) {
envDescriber, err := describe.NewEnvDescriber(describe.NewEnvDescriberConfig{
App: appName,
Env: envName,
ConfigStore: opts.store,
})
if err != nil {
return nil, fmt.Errorf("initiate env describer: %w", err)
}
return envDescriber, nil
}
o.initWlCmd = &opts
o.port = &opts.port // Surfaced via pointer for logging.
o.initWkldVars = &opts.initWkldVars
Expand Down