util

package
v0.8.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright 2020 Mirantis, Inc.

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.

Copyright 2020 Mirantis, Inc.

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.

Copyright 2020 Mirantis, Inc.

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.

Copyright 2020 Mirantis, Inc.

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.

Copyright 2020 Mirantis, Inc.

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.

Copyright 2020 Mirantis, Inc.

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.

Copyright 2020 Mirantis, Inc.

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 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

func GetAllDirs

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

GetAllDirs return a list of dirs in given base path

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 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

Types

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