[Fix] Reuse registry in multicluster (fixes #485,@kuritka) (#486, @kuritka)
This commit is contained in:
parent
78c22f7a0c
commit
76fc9ebed7
@ -131,6 +131,12 @@ func GetGatewayIP(ctx context.Context, network string) (net.IP, error) {
|
||||
|
||||
// ConnectNodeToNetwork connects a node to a network
|
||||
func (d Docker) ConnectNodeToNetwork(ctx context.Context, node *k3d.Node, networkName string) error {
|
||||
// check that node was not attached to network before
|
||||
if isAttachedToNetwork(node, networkName) {
|
||||
log.Infof("Container '%s' is already connected to '%s'", node.Name,networkName)
|
||||
return nil
|
||||
}
|
||||
|
||||
// get container
|
||||
container, err := getNodeContainer(ctx, node)
|
||||
if err != nil {
|
||||
|
@ -140,6 +140,7 @@ func (d Docker) WriteToNode(ctx context.Context, content []byte, dest string, no
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// GetDockerClient returns a docker client
|
||||
func GetDockerClient() (*client.Client, error) {
|
||||
var err error
|
||||
@ -168,3 +169,13 @@ func GetDockerClient() (*client.Client, error) {
|
||||
|
||||
return cli, err
|
||||
}
|
||||
|
||||
// isAttachedToNetwork return true if node is attached to network
|
||||
func isAttachedToNetwork(node *k3d.Node, network string) bool {
|
||||
for _, nw := range node.Networks {
|
||||
if nw == network {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user