util

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: GPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStringFromInterface

func GetStringFromInterface(queryParam any) (string, error)

func Html2Json added in v1.13.0

func Html2Json(rawHtml []byte) ([]byte, error)

Html2Json parses the raw html data and converts it into a json string

func IsPathSpec

func IsPathSpec(s string) bool

IsPathSpec is a wrapper around ParsePathSpec that discards the parsed PathSpec. It's useful for chaining within boolean expressions.

func LocalPath added in v0.99.0

func LocalPath(path, rootDir string) string

func Max

func Max(x, y int) int

func OpenFileOrUrl

func OpenFileOrUrl(path, rootDir string) (io.ReadCloser, error)

OpenFileOrUrl opens either a local file or gives the resp.Body from a remote file

func RemoveFromJsonArray

func RemoveFromJsonArray(input []any, removeIndex int) (output []any)

func Unmarshal added in v1.2.7

func Unmarshal(input []byte, output any) error

func Xhtml2Json added in v1.12.0

func Xhtml2Json(rawXhtml []byte) ([]byte, error)

Xhtml2Json parses the raw xhtml data and converts it into a json string

func Xml2Json added in v1.9.0

func Xml2Json(rawXml []byte, format string) ([]byte, error)

Xml2Json parses the raw xml data and converts it into a json string there are 2 formats for the result json: - "xml": use mxj.NewMapXmlSeq (more complex format including #seq) - "xml2": use mxj.NewMapXmlSeq (simpler format)

Types

type JsonArray

type JsonArray = []any

type JsonBool

type JsonBool = bool

type JsonNumber

type JsonNumber = float64

type JsonObject

type JsonObject = map[string]any

type JsonString

type JsonString = string

type OAuthClientConfig added in v1.0.3

type OAuthClientConfig struct {
	Client      string              `json:"client"`
	Endpoint    OAuthEndpointConfig `mapstructure:"endpoint" json:"endpoint"`
	Secret      string              `mapstructure:"secret" json:"secret"`
	RedirectURL string              `mapstructure:"redirect_url" json:"redirect_url"`
	Scopes      []string            `mapstructure:"scopes" json:"scopes"`
}

OAuthClientConfig is our config for a single oAuth client

func (OAuthClientConfig) GetAuthToken added in v1.0.3

func (c OAuthClientConfig) GetAuthToken(params ...string) (*oauth2.Token, error)

GetCodeAuthToken sends request to oAuth auth endpoint to get a token, optionally bypassing login form username, password have to be provided in the params list if needed

func (OAuthClientConfig) GetClientCredentialsAuthToken added in v1.1.0

func (c OAuthClientConfig) GetClientCredentialsAuthToken() (*oauth2.Token, error)

GetClientCredentialsAuthToken sends request to oAuth token endpoint to get a token on behalf of a user

func (OAuthClientConfig) GetCodeAuthToken added in v1.1.0

func (c OAuthClientConfig) GetCodeAuthToken(params ...string) (*oauth2.Token, error)

GetCodeAuthToken sends request to oAuth auth endpoint to get a token, optionally bypassing login form username, password have to be provided in the params list if needed

func (OAuthClientConfig) GetPasswordCredentialsAuthToken added in v1.1.0

func (c OAuthClientConfig) GetPasswordCredentialsAuthToken(username string, password string) (tok *oauth2.Token, err error)

GetPasswordCredentialsAuthToken sends request to oAuth token endpoint to get a token on behalf of a user

type OAuthClientsConfig added in v1.0.3

type OAuthClientsConfig map[string]OAuthClientConfig

OAuthClientsConfig is our config for multiple oAuth clients

type OAuthEndpointConfig added in v1.0.3

type OAuthEndpointConfig struct {
	TokenURL string `mapstructure:"token_url" json:"token_url"`
	AuthURL  string `mapstructure:"auth_url" json:"auth_url"`
}

OAuthEndpointConfig is our config for an oAuth endpoint

type PathSpec added in v1.21.0

type PathSpec struct {
	// ParallelRuns matches the number of parallel runs specified
	// in a path spec like "5@foo.json"
	ParallelRuns int

	// Path matches the literal path, e.g. foo.json in "@foo.json"
	Path string
}

PathSpec is a path specifier for including tests within manifests.

func ParsePathSpec added in v1.21.0

func ParsePathSpec(s string) (*PathSpec, error)

ParsePathSpec tries to parse the given string into a PathSpec.

The string takes the format "[n]@file.json". Invalid path specs result in an error.

func (PathSpec) LoadContents added in v1.21.0

func (ps PathSpec) LoadContents(manifestDir string) ([]byte, error)

Load loads the contents of the file pointed to by the PathSpec into a byte array.

Jump to

Keyboard shortcuts

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