utils

package
v0.0.0-...-d654738 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 36

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRequestBody

func BuildRequestBody(opts interface{}, parent string) (map[string]interface{}, error)

BuildRequestBody builds a map[string]interface from the given `struct`. If parent is not an empty string, the final map[string]interface returned will encapsulate the built one. For example:

disk := 1
createOpts := flavors.CreateOpts{
  ID:         "1",
  Name:       "m1.tiny",
  Disk:       &disk,
  RAM:        512,
  VCPUs:      1,
  RxTxFactor: 1.0,
}

body, err := BuildRequestBody(createOpts, "flavor")

The above example can be run as-is, however it is recommended to look at how BuildRequestBody is used within Gophercloud to more fully understand how it fits within the request process as a whole rather than use it directly as shown above.

func IsValidEmail

func IsValidEmail(email string) bool

func JsonMarshal

func JsonMarshal(t interface{}) ([]byte, error)

func LoadFromYaml

func LoadFromYaml(path string, cfg interface{}) error

func RunCmd

func RunCmd(args ...string) ([]byte, error, int)

Types

type HttpClient

type HttpClient struct {
	Client     *http.Client
	MaxRetries int
}

func NewHttpClient

func NewHttpClient(n int) HttpClient

func (*HttpClient) Download

func (hc *HttpClient) Download(req *http.Request) (r []byte, statusCode int, err error)

func (*HttpClient) ForwardTo

func (hc *HttpClient) ForwardTo(req *http.Request, jsonResp interface{}) (statusCode int, err error)

type MultiError

type MultiError struct {
	// contains filtered or unexported fields
}

func NewMultiErrors

func NewMultiErrors() *MultiError

func (*MultiError) Add

func (e *MultiError) Add(s string)

func (*MultiError) AddError

func (e *MultiError) AddError(err error)

func (*MultiError) Err

func (e *MultiError) Err() error

type Timer

type Timer interface {
	Start(f func(), interval, delay time.Duration)
	Stop()
}

func NewTimer

func NewTimer() Timer

Jump to

Keyboard shortcuts

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