func()

in plugins/ecs-bridge/engine/engine.go [184:213]


func (engine *engine) RunIPAMPluginAdd(plugin string, netConf []byte) (*current.Result, error) {
	ipamResult, err := engine.ipam.ExecAdd(plugin, netConf)
	if err != nil {
		return nil, errors.Wrapf(err,
			"bridge ipam ADD: failed to execute plugin: %s", plugin)
	}

	result, err := current.NewResultFromResult(ipamResult)
	if err != nil {
		return nil, errors.Wrapf(err,
			"bridge IPAM ADD: unable to parse result '%s'", ipamResult.String())
	}

	// This version of the bridge plugin only considers the first IP Address
	// returned by the ipam plugin as we only expect one ip address to be
	// allocated by the IPAM interface
	if len(result.IPs) != 1 {
		return nil, errors.New("bridge IPAM ADD: Missing IP config in result")
	}

	if result.IPs[0].Address.Mask == nil || result.IPs[0].Address.Mask.String() == zeroLengthIPString {
		return nil, errors.New("bridge IPAM ADD: IP address mask not set in result")
	}

	if result.IPs[0].Gateway == nil || result.IPs[0].Gateway.String() == zeroLengthIPString {
		return nil, errors.New("bridge IPAM ADD: Gateway not set in result")
	}

	return result, nil
}