Example #1
0
func waitFor(once *sync.Once, client dockerclient.APIClient, endpoint string) {
	once.Do(func() {
		err := ClientOK(endpoint, func() bool {
			_, err := client.Info(context.Background())
			return err == nil
		})
		if err != nil {
			panic(err.Error())
		}
	})
}
Example #2
0
// Reference returns the reference of a node. The special value "self" for a node
// reference is mapped to the current node, hence the node ID is retrieved using
// the `/info` endpoint.
func Reference(client apiclient.APIClient, ctx context.Context, ref string) (string, error) {
	if ref == "self" {
		info, err := client.Info(ctx)
		if err != nil {
			return "", err
		}
		return info.Swarm.NodeID, nil
	}
	return ref, nil
}
Example #3
0
func nodeReference(client apiclient.APIClient, ctx context.Context, ref string) (string, error) {
	// The special value "self" for a node reference is mapped to the current
	// node, hence the node ID is retrieved using the `/info` endpoint.
	if ref == "self" {
		info, err := client.Info(ctx)
		if err != nil {
			return "", err
		}
		return info.Swarm.NodeID, nil
	}
	return ref, nil
}