in cobra/controller/init.go [78:134]
func initRun(cmd *cobra.Command, args []string) error {
logrus.Traceln("start: command init run")
cmd.SilenceUsage = true
if args[0] == "project" {
pName, err := cmd.Flags().GetString("project-name")
if err != nil {
logrus.Errorf("unable to access --project-name\n%v", err)
return fmt.Errorf("unable to access --project-name\n%v", err)
}
pType, err := cmd.Flags().GetString("project-type")
if err != nil {
logrus.Errorf("unable to access --project-type\n%v", err)
return fmt.Errorf("unable to access --project-type\n%v", err)
}
switch pType {
case "basic":
err = aid.CreateBasicProject(cmd, pName)
case "cloud":
err = aid.CreateCloudProject(cmd, pName)
case "cloudformation":
err = aid.CreateCloudFormationProject(cmd, pName)
case "terraform":
err = aid.CreateTerraformProject(cmd, pName)
default:
return errors.New("unknow project type")
}
if aid.ConfigurationsDirectoryExist() && aid.ConfigurationsFileExist() {
config, err := dao.GetConfigurations()
if err != nil {
logrus.Errorf("unable to get configuration during initialization\n%v", err)
return fmt.Errorf("unable to initialize project based on configurations\n%v", err)
}
created := aid.InitCustomized(profile, config)
if !created {
return fmt.Errorf("unable to initialize project based on configurations\n%s", err)
}
}
if err != nil {
return fmt.Errorf("unable to initialize project sucessfully \n%s", err)
}
cmd.Printf("%s was successfully initialized as a %s project\n", pName, pType)
}
logrus.Traceln("end: command init run")
return nil
}