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()) } }) }
// 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 }
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 }