utils

package
v0.3.85 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCDApiUrl              = "/api"
	DefaultCacApiUrl             = "/api/setup-as-code/yaml"
	DefaultNGApiUrl              = "/ng/api"
	BaseUrl                      = "https://app.harness.io/gateway"
	GraphQLInvalidTokenErrorCode = "INVALID_TOKEN"
)

Variables

This section is empty.

Functions

func CheckRequiredParameters

func CheckRequiredParameters(param string, badValue interface{}) (bool, error)

func CoalesceObj

func CoalesceObj(val interface{}, fallback func() interface{}) interface{}

func CoalesceStr

func CoalesceStr(val string, fallback string) string

func GetDefaultHttpClient

func GetDefaultHttpClient(logger *log.Logger) *retryablehttp.Client

func GetEnv

func GetEnv(key, fallback string) string

Get a value from the environment or use default

func HasField

func HasField(i interface{}, fieldName string) bool

func MapToStringSlice

func MapToStringSlice(m map[string]string, separator string) []string

func MustSetField

func MustSetField(i interface{}, fieldName string, value interface{})

func RandStringBytes

func RandStringBytes(n int) string

func RequiredFieldsCheck

func RequiredFieldsCheck(obj interface{}, fields []string) (bool, error)

func RequiredFieldsSet

func RequiredFieldsSet(obj interface{}, defaultValues map[string]interface{}) (bool, error)

func RequiredFieldsSetWithDefaultValues

func RequiredFieldsSetWithDefaultValues(obj interface{}, fieldValues map[string]interface{}) (bool, error)

Takes an object with a list of field names and their default values. Returns true if the all of the fields are set with a non-default value. Example usage:

if ok, err := utils.RequiredFieldsSetWithDefaultValues(obj, map[string]interface{}{
	"field1": "default1",
	"field2": "default2",
})
if !ok {
	panic(err)
}

func RequiredStringFieldsSet

func RequiredStringFieldsSet(obj interface{}, fields []string) (bool, error)

func RequiredValueOptionsSet

func RequiredValueOptionsSet(obj interface{}, fieldValuesMap map[string][]interface{}) (bool, error)

func RequiredValuesSet

func RequiredValuesSet(obj interface{}, fieldValues map[string]interface{}) (bool, error)

func TrimFileExtension

func TrimFileExtension(fileName string) string

func TryGetFieldValue

func TryGetFieldValue(i interface{}, fieldName string) (interface{}, bool)

func TrySetField

func TrySetField(i interface{}, fieldName string, value interface{}) (bool, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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