util

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Copyright 2021 k0s authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllAddresses

func AllAddresses() ([]string, error)

AllAddresses returns a list of all network addresses on a node

func CheckIfUserExists added in v0.9.0

func CheckIfUserExists(name string) (bool, error)

func CheckPathPermissions

func CheckPathPermissions(path string, perm os.FileMode) error

CheckPathPermissions checks the correct permissions are for a path (file or directory)

func FileExists

func FileExists(fileName string) bool

FileExists checks if a file exists and is not a directory before we try using it to prevent further errors.

func FirstPublicAddress

func FirstPublicAddress() (string, error)

FirstPublicAddress return the first found non-local address that's not part of pod network

func GetAllDirs

func GetAllDirs(base string) ([]string, error)

GetAllDirs return a list of dirs in given base path

func GetExecPath added in v0.9.0

func GetExecPath(fileName string) (*string, error)

Find the path for a given file (similar to `which`)

func GetGID

func GetGID(name string) (int, error)

GetGID returns gid of given groupname and logs a warning if its missing

func GetUID

func GetUID(name string) (int, error)

GetUID returns uid of given username and logs a warning if its missing

func HomeDir

func HomeDir() (string, error)

HomeDir fetches the running user's home directory, regardless of Sudo

func InitDirectory

func InitDirectory(path string, perm os.FileMode) error

InitDirectory creates a path if it does not exist, and verifies its permissions, if it does

func IsDirectory

func IsDirectory(name string) bool

IsDirectory check the given path exists and is a directory

func IsStringArrayEqual

func IsStringArrayEqual(a1 []string, a2 []string) bool

IsStringArrayEqual returns true if an array of strings is equal, regardless of order

func MachineID

func MachineID() (string, error)

MachineID returns protected id for the current machine

func MachineIDFromHostname

func MachineIDFromHostname() (string, error)

MachineIDFromHostname generates a machine id hash from hostname

func MapMerge added in v0.13.0

func MapMerge(intpuMap map[string]string, existingMap map[string]string) map[string]string

MapMerge merges the input from one map with an existing map, so that we can override entries entry in the existing map

func RandomString

func RandomString(length int) string

RandomString generates a random string with given length

func StringSliceContains

func StringSliceContains(strSlice []string, str string) bool

StringSliceContains check whether the given string slice contains the other string

func Unique added in v0.9.0

func Unique(input []string) []string

Unique returns only the unique items from given input slice

Types

type MappedArgs added in v0.10.0

type MappedArgs map[string]string

MappedArgs defines map like arguments that can be "evaluated" into args=value pairs

func SplitFlags added in v0.11.0

func SplitFlags(input string) MappedArgs

SplitFlags splits arbitrary set of flags into MappedArgs struct

func (MappedArgs) Merge added in v0.11.0

func (m MappedArgs) Merge(other MappedArgs)

Merge merges two maps together

func (MappedArgs) ToArgs added in v0.10.0

func (m MappedArgs) ToArgs() []string

ToArgs maps the data into cmd arguments like foo=bar baz=baf

type TemplateWriter

type TemplateWriter struct {
	Name     string
	Template string
	Data     interface{}
	Path     string
}

TemplateWriter is a helper to write templated kube manifests

func (*TemplateWriter) Write

func (p *TemplateWriter) Write() error

Write writes executes the template and writes the results on disk

func (*TemplateWriter) WriteToBuffer

func (p *TemplateWriter) WriteToBuffer(w io.Writer) error

WriteToBuffer writes executed template tot he given writer

Jump to

Keyboard shortcuts

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