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.
Copyright 2018 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.
Index ¶
- Constants
- Variables
- func AddArray(t *tabby.Tabby, name string, strArr []string)
- func AddMap(t *tabby.Tabby, name string, strMap map[string]string)
- func CommaStringToStringMap(s string) (map[string]string, error)
- func Eprintf(format string, args ...interface{})
- func GetAclFromString(s string) (string, api.Ownership_AccessType, error)
- func GetAclMapFromString(s string) (map[string]api.Ownership_AccessType, error)
- func GetFormattedOutput(in FormatOutput) (string, error)
- func GetRandomName(prefix string) string
- func IsFileExists(fileName string) bool
- func ListContains(list []string, s string) bool
- func ListContainsSubString(list []string, s string) bool
- func ListHaveMatch(list, match []string) (string, bool)
- func NewTabby() *tabby.Tabby
- func PrintFormatted(in FormatOutput) error
- func PrintJson(obj interface{})
- func PrintPxErrorMessagef(err error, format string, args ...string)
- func PrintYaml(obj interface{})
- func Printf(format string, args ...interface{})
- func PxError(err error) error
- func PxErrorMessage(err error, msg string) error
- func PxErrorMessagef(err error, format string, args ...string) error
- func StringContainsAnyFromList(s string, list []string) bool
- func StringMapToCommaString(labels map[string]string) string
- func ToJson(obj interface{}) (string, error)
- func ToYaml(obj interface{}) (string, error)
- func ValidateEndpoint(endpoint string) (string, error)
- func WaitFor(timeout time.Duration, period time.Duration, f func() (bool, error)) error
- type BaseFormatOutput
- func (bfo *BaseFormatOutput) DefaultFormat() (string, error)
- func (bfo *BaseFormatOutput) GetFormat() string
- func (bfo *BaseFormatOutput) JsonFormat() (string, error)
- func (bfo *BaseFormatOutput) SetFormat(typeOfOutput string)
- func (bfo *BaseFormatOutput) WideFormat() (string, error)
- func (bfo *BaseFormatOutput) YamlFormat() (string, error)
- type DefaultFormatOutput
- type FormatOutput
Constants ¶
const ( FORMAT_WIDE = "wide" FORMAT_JSON = "json" FORMAT_YAML = "yaml" )
const ( DefaultPort = "9020" TimeFormat = "Jan 2 15:04:05 UTC 2006" )
Variables ¶
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 )
var (
ErrInvalidEndpoint = errors.New("Invalid Endpoint")
)
Functions ¶
func CommaStringToStringMap ¶
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 GetAclFromString ¶ added in v0.21.4
func GetAclFromString(s string) (string, api.Ownership_AccessType, error)
GetAclFromString takes values like group1:r or group2:w and breaks them returning the group name and the access type.
func GetAclMapFromString ¶ added in v0.21.4
func GetAclMapFromString(s string) (map[string]api.Ownership_AccessType, error)
GetAclMapFromString takes a comma separated string of acl names and their types, and returns a map of the names to their access types
func GetFormattedOutput ¶ added in v0.21.3
func GetFormattedOutput(in FormatOutput) (string, error)
GetFormattedOutput returns the formatted output
func GetRandomName ¶ added in v0.21.3
Generate random string with the given prefix, by appending random numbers.
func IsFileExists ¶ added in v0.21.3
IsFileExists returns true if the file exists else false
func ListContains ¶
ListContains returns true when string s is found in the list
func ListContainsSubString ¶ added in v0.21.3
ListContains returns true when string s is found in the list
func ListHaveMatch ¶
ListsHaveMatch returns the string and true if any one string is found in both lists
func NewTabby ¶
NewTabby is used to return a tabbing object set to the value of Stdout in the util package
func PrintFormatted ¶ added in v0.21.3
func PrintFormatted(in FormatOutput) error
Print the formatted output to stdout In case of any error, just return the error
func PrintPxErrorMessagef ¶
PrintPxErrorMessagef prints the Portworx error message to Stderr
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 PxErrorMessage ¶
PxErrorMessage returns an error composed of the gRPC error status message and the message provided.
func PxErrorMessagef ¶
PxErrorMessagef is like PxErrorMessage, but also adds formatted string support
func StringContainsAnyFromList ¶ added in v0.21.3
func StringMapToCommaString ¶
StringMapToCommaString returns a comma separated k=v as a single string
func ValidateEndpoint ¶ added in v0.21.3
ValidateEndpoint will valid whether given endpoint is a valid. Following validation will be done on the endpoint: 1. Check whether the host part (IP or hostname) is valid 2. Check whether port number is present in the endpoint, If not add Default_port.
Types ¶
type BaseFormatOutput ¶ added in v0.21.3
type BaseFormatOutput struct {
FormatType string
}
func (*BaseFormatOutput) DefaultFormat ¶ added in v0.21.3
func (bfo *BaseFormatOutput) DefaultFormat() (string, error)
DefaultFormat just returns the Desc
func (*BaseFormatOutput) GetFormat ¶ added in v0.21.3
func (bfo *BaseFormatOutput) GetFormat() string
GetFormat returns the format type set
func (*BaseFormatOutput) JsonFormat ¶ added in v0.21.3
func (bfo *BaseFormatOutput) JsonFormat() (string, error)
JsonFormat just returns the DefaultFormat
func (*BaseFormatOutput) SetFormat ¶ added in v0.21.3
func (bfo *BaseFormatOutput) SetFormat(typeOfOutput string)
SetFormat takes in as input the type of Formatting needed. Currently recoganized values are "wide", "json" and "yaml". Any other string including "" will end up with DefaultFormat.
func (*BaseFormatOutput) WideFormat ¶ added in v0.21.3
func (bfo *BaseFormatOutput) WideFormat() (string, error)
WideFormat just returns the DefaultFormat
func (*BaseFormatOutput) YamlFormat ¶ added in v0.21.3
func (bfo *BaseFormatOutput) YamlFormat() (string, error)
YamlFormat just returns the YamlFormat
type DefaultFormatOutput ¶ added in v0.21.3
type DefaultFormatOutput struct { BaseFormatOutput `json:"-" yaml:"-"` Cmd string `json:"cmd,omitempty" yaml:"cmd,omitempty"` Desc string `json:"desc,omitempty" yaml:"desc,omitempty"` Id []string `json:"id,omitempty" yaml:"id,omitempty"` }
func (*DefaultFormatOutput) DefaultFormat ¶ added in v0.21.3
func (dfo *DefaultFormatOutput) DefaultFormat() (string, error)
DefaultFormat returns the Desc
func (*DefaultFormatOutput) JsonFormat ¶ added in v0.21.3
func (dfo *DefaultFormatOutput) JsonFormat() (string, error)
JsonFormat returns the object in json format
func (*DefaultFormatOutput) WideFormat ¶ added in v0.21.3
func (dfo *DefaultFormatOutput) WideFormat() (string, error)
WideFormat returns the DefaultFormat
func (*DefaultFormatOutput) YamlFormat ¶ added in v0.21.3
func (dfo *DefaultFormatOutput) YamlFormat() (string, error)
YamlFormat returns the object in yaml format
type FormatOutput ¶ added in v0.21.3
type FormatOutput interface { // SetFormat takes in as input the type of Formatting needed. // Currently recoganized values are "wide", "json" and "yaml". // Any other string including "" will end up with DefaultFormat. SetFormat(typeOfFormatting string) // GetFormat returns the format type set GetFormat() string // DefaultFormat formats the output as a regular string // This is called when either "wide", "yaml" or "json" is not set DefaultFormat() (string, error) // WideFormat formats the object in the "wide" format WideFormat() (string, error) // YamlFormat formats the object in the "yaml" format YamlFormat() (string, error) // JsonFormat formats the object in the "json" format JsonFormat() (string, error) }
FormatOutput is the interface used to ensure proper formatting