-
Notifications
You must be signed in to change notification settings - Fork 427
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
feat: add profile flag to root init command #642
Changes from 2 commits
0717c4d
91f2d62
d9c5804
bbbc58c
16fe1b1
d1a1557
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ type initVars struct { | |
appType string | ||
appName string | ||
dockerfilePath string | ||
profile string | ||
} | ||
|
||
type initOpts struct { | ||
|
@@ -77,10 +78,15 @@ func newInitOpts(vars initVars) (*initOpts, error) { | |
if err != nil { | ||
return nil, err | ||
} | ||
profileSess, err := sessProvider.FromProfile(vars.profile) | ||
if err != nil { | ||
return nil, err | ||
} | ||
prompt := prompt.New() | ||
spin := termprogress.NewSpinner() | ||
id := identity.New(sess) | ||
deployer := cloudformation.New(sess) | ||
envDeployer := cloudformation.New(profileSess) | ||
cfg, err := profile.NewConfig() | ||
if err != nil { | ||
return nil, err | ||
|
@@ -115,13 +121,13 @@ func newInitOpts(vars initVars) (*initOpts, error) { | |
initEnvVars: initEnvVars{ | ||
GlobalOpts: NewGlobalOpts(), | ||
EnvName: defaultEnvironmentName, | ||
EnvProfile: "default", | ||
EnvProfile: vars.profile, | ||
IsProduction: false, | ||
}, | ||
envCreator: ssm, | ||
projectGetter: ssm, | ||
envDeployer: deployer, | ||
projDeployer: deployer, // TODO #317 | ||
envDeployer: envDeployer, | ||
projDeployer: deployer, | ||
profileConfig: cfg, | ||
prog: spin, | ||
identity: id, | ||
|
@@ -221,6 +227,9 @@ func (o *initOpts) deployEnv() error { | |
// User chose not to deploy the application, exit. | ||
return nil | ||
} | ||
if err := o.initEnv.Ask(); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if we need this. Also we always have value for |
||
return err | ||
} | ||
return o.initEnv.Execute() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While trying to understand how come this worked, I realized that we have a bug in Right now the value from We should change the code so that we initialize Here is a sample way of how to do it in |
||
} | ||
|
||
|
@@ -274,6 +283,7 @@ func BuildInitCmd() *cobra.Command { | |
return nil | ||
}), | ||
} | ||
cmd.Flags().StringVar(&vars.profile, profileFlag, "", profileFlagDescription) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be nice to give default value for the flag as "default" so that we can remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good idea, we can set that default in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But if we set the default value for the flag to be "default" then in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can make this change, but I'd like to make sure we document it somewhere. Is there a good spot that we can stick a line in the env init calls that will remind the user "hey, this will deploy to your default profile; if that's not cool, choose no and then run env deploy later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could simply modify the initShouldDeployPrompt to the following: |
||
cmd.Flags().StringVarP(&vars.projectName, projectFlag, projectFlagShort, "", projectFlagDescription) | ||
cmd.Flags().StringVarP(&vars.appName, appFlag, appFlagShort, "", appFlagDescription) | ||
cmd.Flags().StringVarP(&vars.appType, appTypeFlag, appTypeFlagShort, "", appTypeFlagDescription) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reason why this doesn't error when
vars.profile=""
is this:So right now it's creating a session with the default profile which is slightly misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intuition says that we should just not set this field until
o.initEnv.Ask()
is executed.