github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/docker/clients.go (about)

     1  package docker
     2  
     3  import (
     4  	"context"
     5  )
     6  
     7  type LocalClient Client
     8  type ClusterClient Client
     9  
    10  // The LocalClient is the docker server from docker env variables.
    11  // The ClusterClient is the docker server from kubectl configs.
    12  //
    13  // We may need both or just one or neither, depending on what options the
    14  // Tiltfile has set to drive the build
    15  func ProvideClusterCli(ctx context.Context, lEnv LocalEnv, cEnv ClusterEnv, lClient LocalClient) (ClusterClient, error) {
    16  	// If the Cluster Env and the LocalEnv talk to the same daemon,
    17  	// we can re-use the cluster client as a local client.
    18  	var cClient ClusterClient
    19  	if Env(lEnv).DaemonHost() == Env(cEnv).DaemonHost() {
    20  		cClient = ClusterClient(lClient)
    21  	} else {
    22  		cClient = NewDockerClient(ctx, Env(cEnv))
    23  	}
    24  
    25  	return cClient, nil
    26  }
    27  
    28  func ProvideLocalCli(ctx context.Context, lEnv LocalEnv) LocalClient {
    29  	return LocalClient(NewDockerClient(ctx, Env(lEnv)))
    30  }