utils

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLoggingFlags = log.LstdFlags | log.Lmicroseconds | log.Lmsgprefix
)

Variables

This section is empty.

Functions

func Convert

func Convert(i interface{}) interface{}

func CreateFileTemplate added in v0.29.0

func CreateFileTemplate(filename string) (*template.Template, error)

func CreatePrefix

func CreatePrefix(prefix, target string) (*gnmi.Path, error)

CreatePrefix //

func CreateTemplate

func CreateTemplate(name, text string) (*template.Template, error)

func FileExists added in v0.31.1

func FileExists(filename string) bool

FileExists returns true if a file referenced by filename exists & accessible.

func GetHost

func GetHost(hostport string) string

func GnmiPathToXPath

func GnmiPathToXPath(p *gnmi.Path, noKeys bool) string

func MergeMaps

func MergeMaps(dst, src map[string]interface{}) map[string]interface{}

func NewTLSConfig

func NewTLSConfig(ca, cert, key, clientAuth string, skipVerify, genSelfSigned bool) (*tls.Config, error)

NewTLSConfig generates a *tls.Config based on given CA, certificate, key files and skipVerify flag if certificate and key are missing a self signed key pair is generated. The certificates paths can be local or remote, http(s) and (s)ftp are supported for remote files.

func NewTemplateEngine added in v0.30.0

func NewTemplateEngine() templateEngine

func ParsePath

func ParsePath(p string) (*gnmi.Path, error)

ParsePath creates a gnmi.Path out of a p string, check if the first element is prefixed by an origin, removes it from the xpath and adds it to the returned gnmiPath

func PathElems

func PathElems(pf, p *gnmi.Path) []*gnmi.PathElem

func ReadFile

func ReadFile(ctx context.Context, path string) ([]byte, error)

ReadFile reads a local or remote file and returns the read bytes, the location of the file is determined based on its prefix, http(s), (s)ftp prefixes are supported. no prefix means the file is local. `-` means stdin.

func SelfSignedCerts

func SelfSignedCerts() (tls.Certificate, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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