securitygroup/securitygroup.go
func (m *DefaultManager) AssignDefaultSecurityGroups() error {
	sgs, err := m.ListSecurityGroups()
	if err != nil {
		return err
	}
	globalConfig, err := m.Cfg.GetGlobalConfig()
	if err != nil {
		return err
	}

	for _, runningGroup := range globalConfig.RunningSecurityGroups {
		if group, ok := sgs[runningGroup]; ok {
			if !group.Running {
				err = m.AssignRunningSecurityGroup(group)
				if err != nil {
					return err
				}
			}
		} else {
			return fmt.Errorf("Running security group [%s] does not exist", runningGroup)
		}
	}

	for _, stagingGroup := range globalConfig.StagingSecurityGroups {
		if group, ok := sgs[stagingGroup]; ok {
			if !group.Staging {
				err = m.AssignStagingSecurityGroup(group)
				if err != nil {
					return err
				}
			}
		} else {
			return fmt.Errorf("Staging security group [%s] does not exist", stagingGroup)
		}
	}

	if globalConfig.EnableUnassignSecurityGroups {
		for groupName, group := range sgs {
			if group.Running && !m.contains(globalConfig.RunningSecurityGroups, groupName) {
				err = m.UnassignRunningSecurityGroup(group)
				if err != nil {
					return err
				}
			}
			if group.Staging && !m.contains(globalConfig.StagingSecurityGroups, groupName) {
				err = m.UnassignStagingSecurityGroup(group)
				if err != nil {
					return err
				}
			}
		}
	}

	return nil
}
func (m *DefaultManager) AssignDefaultSecurityGroups() error {
	sgs, err := m.ListSecurityGroups()
	if err != nil {
		return err
	}
	globalConfig, err := m.Cfg.GetGlobalConfig()
	if err != nil {
		return err
	}

	for _, runningGroup := range globalConfig.RunningSecurityGroups {
		if group, ok := sgs[runningGroup]; ok {
			if !group.Running {
				err = m.AssignRunningSecurityGroup(group)
				if err != nil {
					return err
				}
			}
		} else {
			return fmt.Errorf("Running security group [%s] does not exist", runningGroup)
		}
	}

	for _, stagingGroup := range globalConfig.StagingSecurityGroups {
		if group, ok := sgs[stagingGroup]; ok {
			if !group.Staging {
				err = m.AssignStagingSecurityGroup(group)
				if err != nil {
					return err
				}
			}
		} else {
			return fmt.Errorf("Staging security group [%s] does not exist", stagingGroup)
		}
	}

	if globalConfig.EnableUnassignSecurityGroups {
		for groupName, group := range sgs {
			if group.Running && !m.contains(globalConfig.RunningSecurityGroups, groupName) {
				err = m.UnassignRunningSecurityGroup(group)
				if err != nil {
					return err
				}
			}
			if group.Staging && !m.contains(globalConfig.StagingSecurityGroups, groupName) {
				err = m.UnassignStagingSecurityGroup(group)
				if err != nil {
					return err
				}
			}
		}
	}

	return nil
}
func ( m * DefaultManager ) AssignDefaultSecurityGroups ( ) error { sgs , err := m . ListSecurityGroups ( ) if err != nil { return err } globalConfig , err := m . Cfg . GetGlobalConfig ( ) if err != nil { return err } for _ , runningGroup := range globalConfig . RunningSecurityGroups { if group , ok := sgs [ runningGroup ] ; ok { if ! group . Running { err = m . AssignRunningSecurityGroup ( group ) if err != nil { return err } } } else { return fmt . Errorf ( " " , runningGroup ) } } for _ , stagingGroup := range globalConfig . StagingSecurityGroups { if group , ok := sgs [ stagingGroup ] ; ok { if ! group . Staging { err = m . AssignStagingSecurityGroup ( group ) if err != nil { return err } } } else { return fmt . Errorf ( " " , stagingGroup ) } } if globalConfig . EnableUnassignSecurityGroups { for groupName , group := range sgs { if group . Running && ! m . contains ( globalConfig . RunningSecurityGroups , groupName ) { err = m . UnassignRunningSecurityGroup ( group ) if err != nil { return err } } if group . Staging && ! m . contains ( globalConfig . StagingSecurityGroups , groupName ) { err = m . UnassignStagingSecurityGroup ( group ) if err != nil { return err } } } } return nil }
//AssignDefaultSecurityGroups -
AssignDefaultSecurityGroups -