utils

package
v1.30.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 15 Imported by: 1,287

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CIDRSubnet added in v1.21.3

func CIDRSubnet(prefix string, newSize int, netNum int64) (string, error)

CIDRSubnet calculates a subnet address within given IP network address prefix. Inspired by the Terraform implementation of the "cidrsubnet" function https://www.terraform.io/docs/language/functions/cidrsubnet.html

func ExpandPath

func ExpandPath(p string) string

ExpandPath replaces common path aliases: ~ -> $HOME

func HashString added in v1.15.1

func HashString(s string) (string, error)

HashString Takes String and returns a sha256 hash represented as a string

func IsIPv4CIDR added in v1.21.3

func IsIPv4CIDR(s string) bool

IsIPv4CIDR checks if a string is a valid IPv4 CIDR.

func IsIPv4IP added in v1.21.3

func IsIPv4IP(s string) bool

IsIPv4IP checks if a string is a valid IPv4 IP.

func IsIPv6CIDR added in v1.21.3

func IsIPv6CIDR(s string) bool

IsIPv6CIDR checks if a string is a valid IPv6 CIDR.

func IsIPv6IP added in v1.21.3

func IsIPv6IP(s string) bool

IsIPv6IP checks if a string is a valid IPv6 IP.

func ParseCIDRNotation added in v1.21.3

func ParseCIDRNotation(subnet string) (int, int64, error)

ParseCIDRNotation parses a string in the format "/<newSize>#<netNum>" and returns the values of <newSize> and <netNum>.

func SanitizeString

func SanitizeString(s string) string

SanitizeString iterated a strings, removes any characters not in the allow list and returns at most 200 characters

func StringSlicesEqual

func StringSlicesEqual(l, r []string) bool

func StringSlicesEqualIgnoreOrder

func StringSlicesEqualIgnoreOrder(l, r []string) bool

func UngzipFile added in v1.18.0

func UngzipFile(gzipPath string, destPath string) error

UngzipFile extracts a .gzip file

func YAMLToJSON added in v1.10.0

func YAMLToJSON(yamlBytes []byte) ([]byte, error)

YAMLToJSON converts yaml to json

func YamlMarshal

func YamlMarshal(o interface{}) ([]byte, error)

YamlMarshal tries to marshal the input struct into yaml content

func YamlUnmarshal

func YamlUnmarshal(yamlBytes []byte, dest interface{}) error

YamlUnmarshal unmarshals the yaml content to an interface Note: if you are loading a kops.k8s.io API object, normally you want something like kopscodecs.Decode, so that we can convert between apiVersions.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL