func (c *AddASGToConfigurationCommand) Execute([]string) error {
	c.initConfig()

	errorString := ""

	if errorString != "" {
		return errors.New(errorString)
	}

	if !c.Override {
		if c.ASGType == "space" {
			asgConfigs, err := c.ConfigManager.GetASGConfigs()
			if err != nil {
				return err
			}
			for _, asgConfig := range asgConfigs {
				if c.ASGName == asgConfig.Name {
					return errors.New(fmt.Sprintf("asg [%s] already exists if wanting to update use --override flag", c.ASGName))
				}
			}
		} else {
			asgConfigs, err := c.ConfigManager.GetDefaultASGConfigs()
			if err != nil {
				return err
			}
			for _, asgConfig := range asgConfigs {
				if c.ASGName == asgConfig.Name {
					return errors.New(fmt.Sprintf("asg [%s] already exists if wanting to update use --override flag", c.ASGName))
				}
			}
		}
	}

	securityGroupsBytes := []byte("[]")
	if c.FilePath != "" {
		bytes, err := config.LoadFileBytes(c.FilePath)
		if err != nil {
			return err
		}
		securityGroupsBytes = bytes
	}
	if c.ASGType == "space" {
		if err := config.NewManager(c.ConfigDirectory).AddSecurityGroup(c.ASGName, securityGroupsBytes); err != nil {
			return err
		}
	} else {
		if err := config.NewManager(c.ConfigDirectory).AddDefaultSecurityGroup(c.ASGName, securityGroupsBytes); err != nil {
			return err
		}
	}
	fmt.Println(fmt.Sprintf("The asg [%s] has been updated", c.ASGName))
	return nil
}
func (c *AddASGToConfigurationCommand) Execute([]string) error {
	c.initConfig()

	errorString := ""

	if errorString != "" {
		return errors.New(errorString)
	}

	if !c.Override {
		if c.ASGType == "space" {
			asgConfigs, err := c.ConfigManager.GetASGConfigs()
			if err != nil {
				return err
			}
			for _, asgConfig := range asgConfigs {
				if c.ASGName == asgConfig.Name {
					return errors.New(fmt.Sprintf("asg [%s] already exists if wanting to update use --override flag", c.ASGName))
				}
			}
		} else {
			asgConfigs, err := c.ConfigManager.GetDefaultASGConfigs()
			if err != nil {
				return err
			}
			for _, asgConfig := range asgConfigs {
				if c.ASGName == asgConfig.Name {
					return errors.New(fmt.Sprintf("asg [%s] already exists if wanting to update use --override flag", c.ASGName))
				}
			}
		}
	}

	securityGroupsBytes := []byte("[]")
	if c.FilePath != "" {
		bytes, err := config.LoadFileBytes(c.FilePath)
		if err != nil {
			return err
		}
		securityGroupsBytes = bytes
	}
	if c.ASGType == "space" {
		if err := config.NewManager(c.ConfigDirectory).AddSecurityGroup(c.ASGName, securityGroupsBytes); err != nil {
			return err
		}
	} else {
		if err := config.NewManager(c.ConfigDirectory).AddDefaultSecurityGroup(c.ASGName, securityGroupsBytes); err != nil {
			return err
		}
	}
	fmt.Println(fmt.Sprintf("The asg [%s] has been updated", c.ASGName))
	return nil
}
func ( c * AddASGToConfigurationCommand ) Execute ( [ ] string ) error { c . initConfig ( ) errorString := " " if errorString != " " { return errors . New ( errorString ) } if ! c . Override { if c . ASGType == " " { asgConfigs , err := c . ConfigManager . GetASGConfigs ( ) if err != nil { return err } for _ , asgConfig := range asgConfigs { if c . ASGName == asgConfig . Name { return errors . New ( fmt . Sprintf ( " " , c . ASGName ) ) } } } else { asgConfigs , err := c . ConfigManager . GetDefaultASGConfigs ( ) if err != nil { return err } for _ , asgConfig := range asgConfigs { if c . ASGName == asgConfig . Name { return errors . New ( fmt . Sprintf ( " " , c . ASGName ) ) } } } } securityGroupsBytes := [ ] byte ( " " ) if c . FilePath != " " { bytes , err := config . LoadFileBytes ( c . FilePath ) if err != nil { return err } securityGroupsBytes = bytes } if c . ASGType == " " { if err := config . NewManager ( c . ConfigDirectory ) . AddSecurityGroup ( c . ASGName , securityGroupsBytes ) ; err != nil { return err } } else { if err := config . NewManager ( c . ConfigDirectory ) . AddDefaultSecurityGroup ( c . ASGName , securityGroupsBytes ) ; err != nil { return err } } fmt . Println ( fmt . Sprintf ( " " , c . ASGName ) ) return nil }
//Execute - adds a named asg to the configuration
Execute - adds a named asg to the configuration