Documentation ¶
Overview ¶
Copyright © 2020-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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 FilterNodes(nodes []*k3d.Node, filters []string) ([]*k3d.Node, error)
- func FilterNodesByRole(nodes []*k3d.Node, role k3d.Role) []*k3d.Node
- func FilterNodesWithSuffix(nodes []*k3d.Node, nodefilters []string, allowedSuffices ...string) (map[string][]*k3d.Node, error)
- func GenerateRandomString(n int) string
- func GetConfigDirOrCreate() (string, error)
- func GetFakeMeminfoPathForName(nodeName string) (string, error)
- func GetFreePort() (int, error)
- func GetNodeFakerDirOrCreate(name string) (string, error)
- func IsPortBindingEqual(a, b nat.PortBinding) bool
- func MakeFakeEdac(nodeName string) (string, error)
- func MakeFakeMeminfo(memoryBytes int64, nodeName string) (string, error)
- func MapSubexpNames(names, matches []string) map[string]string
- func ParseRegistryRef(registryRef string) (*k3d.Registry, error)
- func ReadFileSource(configFile, source string) ([]byte, error)
- func RemoveElementFromStringSlice(slice []string, index int) []string
- func ReplaceInAllElements(replacer *strings.Replacer, arr []string) []string
- func ResolveFileDestination(destPath string) (string, error)
- func SplitLabelKeyValue(label string) (string, string)
- func SplitYAML(resources []byte) ([][]byte, error)
- type YAMLEncoder
Constants ¶
const ( NodeFilterSuffixNone = "nosuffix" NodeFilterMapKeyAll = "all" )
const ( EdacFolderPath = "/sys/devices/system/edac" MemInfoPath = "/proc/meminfo" )
Variables ¶
var DoNotCopyVolumeSuffices = []string{ fmt.Sprintf("%s:ro", EdacFolderPath), fmt.Sprintf("%s:ro", MemInfoPath), }
DoNotCopyVolumeSuffices defines a set of volume mounts that should not be copied to a new node (e.g. to avoid duplicate mountpoints)
var NodeFilterRegexp = regexp.MustCompile(`^(?P<group>server|servers|agent|agents|loadbalancer|all)(?P<subsetSpec>:(?P<subset>(?P<subsetList>(\d+,?)+)|(?P<subsetRange>\d*-\d*)|(?P<subsetWildcard>\*)))?(?P<suffixSpec>:(?P<suffix>[[:alpha:]]+))?$`)
Regexp pattern to match node filters
Functions ¶
func FilterNodes ¶
FilterNodes takes a string filter to return a filtered list of nodes
func FilterNodesByRole ¶
FilterNodesByRole returns a stripped list of nodes which do match the given role
func FilterNodesWithSuffix ¶
func FilterNodesWithSuffix(nodes []*k3d.Node, nodefilters []string, allowedSuffices ...string) (map[string][]*k3d.Node, error)
FilterNodesBySuffix properly interprets NodeFilters with suffix
func GenerateRandomString ¶
GenerateRandomString thanks to https://stackoverflow.com/a/31832326/6450189 GenerateRandomString is used to generate a random string that is used as a cluster token
func GetConfigDirOrCreate ¶
GetConfigDirOrCreate will return the base path of the k3d config directory or create it if it doesn't exist yet k3d's config directory will be $XDG_CONFIG_HOME (Unix)
func GetFakeMeminfoPathForName ¶
GetFakeMeminfoPathForName returns a path to (existent or not) fake meminfo file for a given node/container name
func GetFreePort ¶
GetFreePort tries to fetch an open port from the OS-Kernel
func GetNodeFakerDirOrCreate ¶
GetNodeFakerDirOrCreate creates or gets a hidden folder in k3d home dir to keep container(node)-specific fake files in it
func IsPortBindingEqual ¶
func IsPortBindingEqual(a, b nat.PortBinding) bool
func MakeFakeEdac ¶
MakeFakeEdac creates an empty edac folder to force cadvisor to use meminfo even for ECC memory
func MakeFakeMeminfo ¶
MakeFakeMeminfo creates a fake meminfo file to be mounted and provide a specific RAM capacity. This file is created on a per specific container/node basis, uniqueName must ensure that. Returns a path to the file
func MapSubexpNames ¶
MapSubexpNames maps regex capturing group names to corresponding matches
func ParseRegistryRef ¶
ParseRegistryRef returns a registry struct parsed from a simplified definition string
func ReadFileSource ¶ added in v5.7.0
ReadFileSource reads the file source which is either embedded in the k3d config file or relative to it.
func ReplaceInAllElements ¶
func ResolveFileDestination ¶ added in v5.7.0
ResolveFileDestination determines the file destination and resolves it if it has a magic shortcut.
func SplitLabelKeyValue ¶
SplitLabelKeyValue separates the label key from the label value (if any)
Types ¶
type YAMLEncoder ¶ added in v5.4.4
type YAMLEncoder struct {
// contains filtered or unexported fields
}
func NewYAMLEncoder ¶ added in v5.4.4
func NewYAMLEncoder(w io.Writer) *YAMLEncoder
func (*YAMLEncoder) Close ¶ added in v5.4.4
func (e *YAMLEncoder) Close() (err error)
func (*YAMLEncoder) Encode ¶ added in v5.4.4
func (e *YAMLEncoder) Encode(v interface{}) (err error)