Documentation ¶
Overview ¶
Copyright © 2020-2021 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-2021 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-2021 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-2021 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-2021 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-2021 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) 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 ¶
CheckIfDirectoryExists checks for the existence of a given path inside the docker environment
func GetDefaultObjectLabelsFilter ¶
GetDefaultObjectLabelsFilter returns docker type filters created from k3d labels
func GetDockerClient ¶
GetDockerClient returns a docker client
func GetGatewayIP ¶
GetGatewayIP returns the IP of the network gateway
func GetNetwork ¶
GetNetwork gets information about a network by its ID
func IsDockerDesktop ¶ added in v5.2.0
func IsLocalConnection ¶ added in v5.2.0
func TranslateContainerDetailsToNode ¶
func TranslateContainerDetailsToNode(containerDetails types.ContainerJSON) (*k3d.Node, error)
TranslateContainerDetailsToNode translates a docker containerJSON object into a k3d node representation
Types ¶
type Docker ¶
type Docker struct{}
func (Docker) ConnectNodeToNetwork ¶
ConnectNodeToNetwork connects a node to a network
func (Docker) CopyToNode ¶
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 ¶
CreateNode creates a new container
func (Docker) CreateVolume ¶
CreateVolume creates a new named volume
func (Docker) DeleteNetwork ¶
DeleteNetwork deletes a network
func (Docker) DeleteNode ¶
DeleteNode deletes a node
func (Docker) DeleteVolume ¶
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 ¶
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 (Docker) GetDockerMachineIP ¶
func (Docker) GetHostIP ¶
GetHostIP returns the IP of the docker host (routable from inside the containers)
func (Docker) GetImageStream ¶ added in v5.2.0
GetImageStream creates a tar stream for the given images, to be read (and closed) by the caller
func (Docker) GetKubeconfig ¶
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) 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 ¶
GetNodeStatus returns the status of a node (Running, Started, etc.)
func (Docker) GetNodesByLabel ¶
GetNodesByLabel returns a list of existing nodes
func (Docker) GetNodesInNetwork ¶
GetNodesInNetwork returns all the nodes connected to a given network
func (Docker) GetRuntimePath ¶
GetRuntimePath returns the path of the docker socket
func (Docker) Info ¶
func (d Docker) Info() (*runtimeTypes.RuntimeInfo, error)
func (Docker) NodeIsRunning ¶
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 ¶
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