func (c *interfaceClient) NewInterface(secGrps []string, requiredTags map[string]string) (*Interface, error) {
	subnets, err := c.subnet.GetSubnetsForInstance()
	if err != nil {
		return nil, err
	}

	existingInterfaces, err := c.aws.GetInterfaces()
	if err != nil {
		return nil, err
	}

	limits := c.aws.ENILimits()
	if len(existingInterfaces) >= limits.Adapters {
		return nil, fmt.Errorf("too many adapters on this instance already")
	}

	var availableSubnets []Subnet

OUTER:
	for _, newSubnet := range subnets {
		// Match incoming tags
		for tagKey, tagValue := range requiredTags {
			value, ok := newSubnet.Tags[tagKey]
			// Skip untagged subnets and ones not matching
			// the required tag
			if !ok || (ok && value != tagValue) {
				continue OUTER
			}
		}
		availableSubnets = append(availableSubnets, newSubnet)
	}

	// assign new interfaces to subnets with most available addresses
	sort.Sort(SubnetsByAvailableAddressCount(availableSubnets))

	if len(availableSubnets) <= 0 {
		return nil, fmt.Errorf("No subnets are available which haven't already been used")
	}

	return c.NewInterfaceOnSubnetAtIndex(len(existingInterfaces), secGrps, availableSubnets[0])
}
// NewInterface creates an Interface based on specified parameters
NewInterface creates an Interface based on specified parameters
// NewInterface creates an Interface based on specified parameters
func (c *interfaceClient) NewInterface(secGrps []string, requiredTags map[string]string) (*Interface, error) {
	subnets, err := c.subnet.GetSubnetsForInstance()
	if err != nil {
		return nil, err
	}
	existingInterfaces, err := c.aws.GetInterfaces()
	if err != nil {
		return nil, err
	}
	limits := c.aws.ENILimits()
	if len(existingInterfaces) >= limits.Adapters {
		return nil, fmt.Errorf("too many adapters on this instance already")
	}
	var availableSubnets []Subnet
OUTER:
	for _, newSubnet := range subnets {
		for tagKey, tagValue := range requiredTags {
			value, ok := newSubnet.Tags[tagKey]
			if !ok || (ok && value != tagValue) {
				continue OUTER
			}
		}
		availableSubnets = append(availableSubnets, newSubnet)
	}
	sort.Sort(SubnetsByAvailableAddressCount(availableSubnets))
	if len(availableSubnets) <= 0 {
		return nil, fmt.Errorf("No subnets are available which haven't already been used")
	}
	return c.NewInterfaceOnSubnetAtIndex(len(existingInterfaces), secGrps, availableSubnets[0])
}
func ( c * interfaceClient ) NewInterface ( secGrps [ ] string , requiredTags map [ string ] string ) ( * Interface , error ) { subnets , err := c . subnet . GetSubnetsForInstance ( ) if err != nil { return nil , err } existingInterfaces , err := c . aws . GetInterfaces ( ) if err != nil { return nil , err } limits := c . aws . ENILimits ( ) if len ( existingInterfaces ) >= limits . Adapters { return nil , fmt . Errorf ( " " ) } var availableSubnets [ ] Subnet OUTER : for _ , newSubnet := range subnets { for tagKey , tagValue := range requiredTags { value , ok := newSubnet . Tags [ tagKey ] if ! ok || ( ok && value != tagValue ) { continue OUTER } } availableSubnets = append ( availableSubnets , newSubnet ) } sort . Sort ( SubnetsByAvailableAddressCount ( availableSubnets ) ) if len ( availableSubnets ) <= 0 { return nil , fmt . Errorf ( " " ) } return c . NewInterfaceOnSubnetAtIndex ( len ( existingInterfaces ) , secGrps , availableSubnets [ 0 ] ) }
NewInterface creates an Interface based on specified parameters
NewInterface creates an Interface based on specified parameters
// Match incoming tags // Skip untagged subnets and ones not matching // the required tag // assign new interfaces to subnets with most available addresses