Documentation
¶
Overview ¶
Copyright © 2020-2022 The k3d Author(s)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2020-2022 The k3d Author(s)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2020-2022 The k3d Author(s)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2020-2022 The k3d Author(s)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2020-2022 The k3d Author(s)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2020-2022 The k3d Author(s)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- Variables
- func CheckIfDirectoryExists(ctx context.Context, image string, dir string) (bool, error)
- func GetDefaultObjectLabelsFilter(clusterName string) filters.Args
- func GetDockerClient() (client.APIClient, error)
- func GetGatewayIP(ctx context.Context, network string) (net.IP, error)
- func GetNetwork(ctx context.Context, ID string) (types.NetworkResource, error)
- func IsDockerDesktop(os string) bool
- func IsLocalConnection(endpoint string) bool
- func TranslateContainerDetailsToNode(containerDetails types.ContainerJSON) (*k3d.Node, error)
- func TranslateContainerToNode(cont *types.Container) (*k3d.Node, error)
- type Docker
- func (d Docker) ConnectNodeToNetwork(ctx context.Context, node *k3d.Node, networkName string) error
- func (d Docker) CopyToNode(ctx context.Context, src string, dest string, node *k3d.Node) error
- func (d Docker) CreateNetworkIfNotPresent(ctx context.Context, inNet *k3d.ClusterNetwork) (*k3d.ClusterNetwork, bool, error)
- func (d Docker) CreateNode(ctx context.Context, node *k3d.Node) error
- func (d Docker) CreateVolume(ctx context.Context, name string, labels map[string]string) error
- func (d Docker) DeleteNetwork(ctx context.Context, ID string) error
- func (d Docker) DeleteNode(ctx context.Context, nodeSpec *k3d.Node) error
- func (d Docker) DeleteVolume(ctx context.Context, name string) error
- func (d Docker) DisconnectNodeFromNetwork(ctx context.Context, node *k3d.Node, networkName string) error
- func (d Docker) ExecInNode(ctx context.Context, node *k3d.Node, cmd []string) error
- func (d Docker) ExecInNodeGetLogs(ctx context.Context, node *k3d.Node, cmd []string) (*bufio.Reader, error)
- func (d Docker) ExecInNodeWithStdin(ctx context.Context, node *k3d.Node, cmd []string, stdin io.ReadCloser) error
- func (d Docker) GetDockerMachineIP() (string, error)
- func (d Docker) GetHost() string
- func (d Docker) GetHostIP(ctx context.Context, network string) (net.IP, error)
- func (d Docker) GetImageStream(ctx context.Context, image []string) (io.ReadCloser, error)
- func (d Docker) GetImages(ctx context.Context) ([]string, error)
- func (d Docker) GetKubeconfig(ctx context.Context, node *k3d.Node) (io.ReadCloser, error)
- func (d Docker) GetNetwork(ctx context.Context, searchNet *k3d.ClusterNetwork) (*k3d.ClusterNetwork, error)
- func (d Docker) GetNode(ctx context.Context, node *k3d.Node) (*k3d.Node, error)
- func (d Docker) GetNodeLogs(ctx context.Context, node *k3d.Node, since time.Time, ...) (io.ReadCloser, error)
- func (d Docker) GetNodeStatus(ctx context.Context, node *k3d.Node) (bool, string, error)
- func (d Docker) GetNodesByLabel(ctx context.Context, labels map[string]string) ([]*k3d.Node, error)
- func (d Docker) GetNodesInNetwork(ctx context.Context, network string) ([]*k3d.Node, error)
- func (d Docker) GetRuntimePath() string
- func (d Docker) GetVolume(name string) (string, error)
- func (d Docker) GetVolumesByLabel(ctx context.Context, labels map[string]string) ([]string, error)
- func (d Docker) ID() string
- func (d Docker) Info() (*runtimeTypes.RuntimeInfo, error)
- func (d Docker) NodeIsRunning(ctx context.Context, node *k3d.Node) (bool, error)
- func (d Docker) ReadFromNode(ctx context.Context, path string, node *k3d.Node) (io.ReadCloser, error)
- func (d Docker) RenameNode(ctx context.Context, node *k3d.Node, newName string) error
- func (d Docker) StartNode(ctx context.Context, node *k3d.Node) error
- func (d Docker) StopNode(ctx context.Context, node *k3d.Node) error
- func (d Docker) WriteToNode(ctx context.Context, content []byte, dest string, mode os.FileMode, ...) error
- type NodeInDocker
Constants ¶
const (
DefaultDockerSock = "/var/run/docker.sock"
)
Variables ¶
var LocalConnectionRegexp = regexp.MustCompile(`^(/|((tcp|ssh)://(localhost|127\.0\.0\.1))).*`)
* Simple Matching to detect local connection: * - file (socket): starts with / (absolute path) * - tcp://(localhost|127.0.0.1) * - ssh://(localhost|127.0.0.1)
Functions ¶
func CheckIfDirectoryExists ¶
func CheckIfDirectoryExists(ctx context.Context, image string, dir string) (bool, error)
CheckIfDirectoryExists checks for the existence of a given path inside the docker environment
func GetDefaultObjectLabelsFilter ¶
func GetDefaultObjectLabelsFilter(clusterName string) filters.Args
GetDefaultObjectLabelsFilter returns docker type filters created from k3d labels
func GetDockerClient ¶
func GetDockerClient() (client.APIClient, error)
GetDockerClient returns a docker client
func GetGatewayIP ¶
func GetGatewayIP(ctx context.Context, network string) (net.IP, error)
GetGatewayIP returns the IP of the network gateway
func GetNetwork ¶
func GetNetwork(ctx context.Context, ID string) (types.NetworkResource, error)
GetNetwork gets information about a network by its ID
func IsDockerDesktop ¶ added in v5.2.0
func IsDockerDesktop(os string) bool
func IsLocalConnection ¶ added in v5.2.0
func IsLocalConnection(endpoint string) bool
func TranslateContainerDetailsToNode ¶
func TranslateContainerDetailsToNode(containerDetails types.ContainerJSON) (*k3d.Node, error)
TranslateContainerDetailsToNode translates a docker containerJSON object into a k3d node representation
func TranslateContainerToNode ¶
func TranslateContainerToNode(cont *types.Container) (*k3d.Node, error)
TranslateContainerToNode translates a docker container object into a k3d node representation
Types ¶
type Docker ¶
type Docker struct{}
func (Docker) ConnectNodeToNetwork ¶
func (d Docker) ConnectNodeToNetwork(ctx context.Context, node *k3d.Node, networkName string) error
ConnectNodeToNetwork connects a node to a network
func (Docker) CopyToNode ¶
func (d Docker) CopyToNode(ctx context.Context, src string, dest string, node *k3d.Node) error
CopyToNode copies a file from the local FS to the selected node
func (Docker) CreateNetworkIfNotPresent ¶
func (d Docker) CreateNetworkIfNotPresent(ctx context.Context, inNet *k3d.ClusterNetwork) (*k3d.ClusterNetwork, bool, error)
CreateNetworkIfNotPresent creates a new docker network @return: network, exists, error
func (Docker) CreateNode ¶
func (d Docker) CreateNode(ctx context.Context, node *k3d.Node) error
CreateNode creates a new container
func (Docker) CreateVolume ¶
func (d Docker) CreateVolume(ctx context.Context, name string, labels map[string]string) error
CreateVolume creates a new named volume
func (Docker) DeleteNetwork ¶
func (d Docker) DeleteNetwork(ctx context.Context, ID string) error
DeleteNetwork deletes a network
func (Docker) DeleteNode ¶
func (d Docker) DeleteNode(ctx context.Context, nodeSpec *k3d.Node) error
DeleteNode deletes a node
func (Docker) DeleteVolume ¶
func (d Docker) DeleteVolume(ctx context.Context, name string) error
DeleteVolume creates a new named volume
func (Docker) DisconnectNodeFromNetwork ¶
func (d Docker) DisconnectNodeFromNetwork(ctx context.Context, node *k3d.Node, networkName string) error
DisconnectNodeFromNetwork disconnects a node from a network (u don't say :O)
func (Docker) ExecInNode ¶
func (d Docker) ExecInNode(ctx context.Context, node *k3d.Node, cmd []string) error
ExecInNode execs a command inside a node
func (Docker) ExecInNodeGetLogs ¶
func (d Docker) ExecInNodeGetLogs(ctx context.Context, node *k3d.Node, cmd []string) (*bufio.Reader, error)
ExecInNodeGetLogs executes a command inside a node and returns the logs to the caller, e.g. to parse them
func (Docker) ExecInNodeWithStdin ¶ added in v5.2.0
func (d Docker) ExecInNodeWithStdin(ctx context.Context, node *k3d.Node, cmd []string, stdin io.ReadCloser) error
func (Docker) GetDockerMachineIP ¶
func (d Docker) GetDockerMachineIP() (string, error)
func (Docker) GetHostIP ¶
func (d Docker) GetHostIP(ctx context.Context, network string) (net.IP, error)
GetHostIP returns the IP of the docker host (routable from inside the containers)
func (Docker) GetImageStream ¶ added in v5.2.0
func (d Docker) GetImageStream(ctx context.Context, image []string) (io.ReadCloser, error)
GetImageStream creates a tar stream for the given images, to be read (and closed) by the caller
func (Docker) GetImages ¶
func (d Docker) GetImages(ctx context.Context) ([]string, error)
GetImages returns a list of images present in the runtime
func (Docker) GetKubeconfig ¶
func (d Docker) GetKubeconfig(ctx context.Context, node *k3d.Node) (io.ReadCloser, error)
GetKubeconfig grabs the kubeconfig from inside a k3d node
func (Docker) GetNetwork ¶
func (d Docker) GetNetwork(ctx context.Context, searchNet *k3d.ClusterNetwork) (*k3d.ClusterNetwork, error)
GetNetwork returns a given network
func (Docker) GetNode ¶
func (d Docker) GetNode(ctx context.Context, node *k3d.Node) (*k3d.Node, error)
GetNode tries to get a node container by its name
func (Docker) GetNodeLogs ¶
func (d Docker) GetNodeLogs(ctx context.Context, node *k3d.Node, since time.Time, opts *runtimeTypes.NodeLogsOpts) (io.ReadCloser, error)
GetNodeLogs returns the logs from a given node
func (Docker) GetNodeStatus ¶
func (d Docker) GetNodeStatus(ctx context.Context, node *k3d.Node) (bool, string, error)
GetNodeStatus returns the status of a node (Running, Started, etc.)
func (Docker) GetNodesByLabel ¶
func (d Docker) GetNodesByLabel(ctx context.Context, labels map[string]string) ([]*k3d.Node, error)
GetNodesByLabel returns a list of existing nodes
func (Docker) GetNodesInNetwork ¶
func (d Docker) GetNodesInNetwork(ctx context.Context, network string) ([]*k3d.Node, error)
GetNodesInNetwork returns all the nodes connected to a given network
func (Docker) GetRuntimePath ¶
func (d Docker) GetRuntimePath() string
GetRuntimePath returns the path of the docker socket
func (Docker) GetVolume ¶
func (d Docker) GetVolume(name string) (string, error)
GetVolume tries to get a named volume
func (Docker) GetVolumesByLabel ¶ added in v5.3.0
func (d Docker) GetVolumesByLabel(ctx context.Context, labels map[string]string) ([]string, error)
func (Docker) NodeIsRunning ¶
func (d Docker) NodeIsRunning(ctx context.Context, node *k3d.Node) (bool, error)
NodeIsRunning tells the caller if a given node is in "running" state
func (Docker) ReadFromNode ¶
func (d Docker) ReadFromNode(ctx context.Context, path string, node *k3d.Node) (io.ReadCloser, error)
ReadFromNode reads from a given filepath inside the node container
func (Docker) RenameNode ¶
func (d Docker) RenameNode(ctx context.Context, node *k3d.Node, newName string) error
func (Docker) StartNode ¶
func (d Docker) StartNode(ctx context.Context, node *k3d.Node) error
StartNode starts an existing node
func (Docker) StopNode ¶
func (d Docker) StopNode(ctx context.Context, node *k3d.Node) error
StopNode stops an existing node
func (Docker) WriteToNode ¶
func (d Docker) WriteToNode(ctx context.Context, content []byte, dest string, mode os.FileMode, node *k3d.Node) error
WriteToNode writes a byte array to the selected node
type NodeInDocker ¶
type NodeInDocker struct {
ContainerConfig container.Config // TODO: do we need this as pointers?
HostConfig container.HostConfig
NetworkingConfig network.NetworkingConfig
}
NodeInDocker represents everything that we need to represent a k3d node in docker
func TranslateNodeToContainer ¶
func TranslateNodeToContainer(node *k3d.Node) (*NodeInDocker, error)
TranslateNodeToContainer translates a k3d node specification to a docker container representation