util

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright © 2019 Portworx

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

View Source
var (
	// Stdout points to the output buffer to send screen output
	Stdout io.Writer = os.Stdout
	// Stderr points to the output buffer to send errors to the screen
	Stderr io.Writer = os.Stderr
)

Functions

func CommaStringToStringMap

func CommaStringToStringMap(s string) (map[string]string, error)

CommaStringToStringMap returns a string map composed of the k=v comma separated values in the string

func Eprintf

func Eprintf(format string, args ...interface{})

Eprintf prints the errors to the output buffer Stderr. It is equal to fmt.Fprintf(util.Stderr, format, args)

func ListContains

func ListContains(list []string, s string) bool

ListContains returns true when string s is found in the list

func ListHaveMatch

func ListHaveMatch(list, match []string) bool

ListsHaveMatch returns true when any one string is found in both lists

func NewTabby

func NewTabby() *tabby.Tabby

NewTabby is used to return a tabbing object set to the value of Stdout in the util package

func PrintJson

func PrintJson(obj interface{})

PrintJson prints the object to json to Stdout

func PrintPxErrorMessagef

func PrintPxErrorMessagef(err error, format string, args ...string)

PrintPxErrorMessagef prints the Portworx error message to Stderr

func PrintYaml

func PrintYaml(obj interface{})

PrintYaml prints the object to yaml to Stdout

func Printf

func Printf(format string, args ...interface{})

Printf is just like fmt.Printf except that it send the output to Stdout. It is equal to fmt.Fprintf(util.Stdout, format, args)

func PxError

func PxError(err error) error

PxError extracts and returns the message found in the gRPC error status

func PxErrorMessage

func PxErrorMessage(err error, msg string) error

PxErrorMessage returns an error composed of the gRPC error status message and the message provided.

func PxErrorMessagef

func PxErrorMessagef(err error, format string, args ...string) error

PxErrorMessagef is like PxErrorMessage, but also adds formatted string support

func StringMapToCommaString

func StringMapToCommaString(labels map[string]string) string

StringMapToCommaString returns a comma separated k=v as a single string

func WaitFor

func WaitFor(timeout time.Duration, period time.Duration, f func() (bool, error)) error

WaitFor() waits until f() returns false or err != nil f() returns <wait as bool, or err>.

Types

This section is empty.

Jump to

Keyboard shortcuts

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