当前位置: 首页>>代码示例>>Golang>>正文


Golang JoinInfo.SetResolvConfPath方法代码示例

本文整理汇总了Golang中github.com/docker/libnetwork/driverapi.JoinInfo.SetResolvConfPath方法的典型用法代码示例。如果您正苦于以下问题:Golang JoinInfo.SetResolvConfPath方法的具体用法?Golang JoinInfo.SetResolvConfPath怎么用?Golang JoinInfo.SetResolvConfPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/docker/libnetwork/driverapi.JoinInfo的用法示例。


在下文中一共展示了JoinInfo.SetResolvConfPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Join

// Join method is invoked when a Sandbox is attached to an endpoint.
func (d *driver) Join(nid, eid types.UUID, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
	if err := jinfo.SetHostsPath("/etc/hosts"); err != nil {
		return err
	}

	return jinfo.SetResolvConfPath("/etc/resolv.conf")
}
开发者ID:AdamOssenford,项目名称:docker-pi,代码行数:8,代码来源:host.go

示例2: Join

// Join method is invoked when a Sandbox is attached to an endpoint.
func (d *driver) Join(nid, eid types.UUID, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
	join := &joinRequest{
		NetworkID:  string(nid),
		EndpointID: string(eid),
		SandboxKey: sboxKey,
		Options:    options,
	}
	var (
		res joinResponse
		err error
	)
	if err = d.call("Join", join, &res); err != nil {
		return err
	}

	// Expect each interface ID given by CreateEndpoint to have an
	// entry at that index in the names supplied here. In other words,
	// if you supply 0..n interfaces with IDs 0..n above, you should
	// supply the names in the same order.
	ifaceNames := res.InterfaceNames
	for _, iface := range jinfo.InterfaceNames() {
		i := iface.ID()
		if i >= len(ifaceNames) || i < 0 {
			return fmt.Errorf("no correlating interface %d in supplied interface names", i)
		}
		supplied := ifaceNames[i]
		if err := iface.SetNames(supplied.SrcName, supplied.DstName); err != nil {
			return errorWithRollback(fmt.Sprintf("failed to set interface name: %s", err), d.Leave(nid, eid))
		}
	}

	var addr net.IP
	if res.Gateway != "" {
		if addr = net.ParseIP(res.Gateway); addr == nil {
			return fmt.Errorf(`unable to parse Gateway "%s"`, res.Gateway)
		}
		if jinfo.SetGateway(addr) != nil {
			return errorWithRollback(fmt.Sprintf("failed to set gateway: %v", addr), d.Leave(nid, eid))
		}
	}
	if res.GatewayIPv6 != "" {
		if addr = net.ParseIP(res.GatewayIPv6); addr == nil {
			return fmt.Errorf(`unable to parse GatewayIPv6 "%s"`, res.GatewayIPv6)
		}
		if jinfo.SetGatewayIPv6(addr) != nil {
			return errorWithRollback(fmt.Sprintf("failed to set gateway IPv6: %v", addr), d.Leave(nid, eid))
		}
	}
	if jinfo.SetHostsPath(res.HostsPath) != nil {
		return errorWithRollback(fmt.Sprintf("failed to set hosts path: %s", res.HostsPath), d.Leave(nid, eid))
	}
	if jinfo.SetResolvConfPath(res.ResolvConfPath) != nil {
		return errorWithRollback(fmt.Sprintf("failed to set resolv.conf path: %s", res.ResolvConfPath), d.Leave(nid, eid))
	}
	return nil
}
开发者ID:fwalker,项目名称:dashboard,代码行数:57,代码来源:driver.go


注:本文中的github.com/docker/libnetwork/driverapi.JoinInfo.SetResolvConfPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。