utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MPL-2.0-no-copyleft-exception Imports: 11 Imported by: 3

Documentation

Index

Constants

View Source
const MaxPerPage int64 = 100

MaxPerPage is the maximum size of a single page that tinyCI will generate when rendering responses.

Variables

View Source
var (
	// ErrNotFound is a generic error for things that don't exist.
	ErrNotFound = errors.New("not found")

	// ErrInvalidAuth is for authentication events that do not succeed.
	ErrInvalidAuth = errors.New("invalid authentication")

	// ErrRunCanceled is thrown to github when the run is canceled.
	ErrRunCanceled = errors.New("run canceled by user intervention")
)
View Source
var (
	//ErrInvalidCharacters occurs when one of "%><$." is found in either Owner or repo
	ErrInvalidCharacters = errors.New("repository name contains invalid characters")
)

Functions

func CreateTracer

func CreateTracer(serviceName string) (io.Closer, error)

CreateTracer creates an opentracing-compatible jaegertracing client.

func IsOwnerRepo

func IsOwnerRepo(repoName string) bool

IsOwnerRepo is a predicate to determine whether or not a github repo name is valid.

func IsSHA

func IsSHA(sha string) bool

IsSHA detects if the string looks like a real SHA1 digest or not.

func JSONContext

func JSONContext(ctx *gin.Context, parameter string, obj interface{}) error

JSONContext provides an easy method to extract json from gin parameters.

func JSONIO

func JSONIO(from, to interface{}) error

JSONIO is a copy function that uses JSON as an intermediary.

func OwnerRepo

func OwnerRepo(repoName string) (string, string, error)

OwnerRepo returns the owner and repository parts of a github full repository name. It returns an error if there are issues.

func QualifyBranch

func QualifyBranch(branch string) (string, error)

QualifyBranch corrects branch data to reflect our internal ref-type/ref-name strategy for tracking branches. It returns an error when it can't figure it out.

func ScopePagination

func ScopePagination(pg, ppg string) (int64, int64, error)

ScopePagination applies constraints to pagination; it sets a maximum and a default if not supplied to perPage. String version.

func ScopePaginationInt

func ScopePaginationInt(page, perPage int64) (int64, int64, error)

ScopePaginationInt applies constraints to pagination; it sets a maximum and a default if not supplied to perPage. Integer-only version.

func SetUpGRPCTracing

func SetUpGRPCTracing(client string) (io.Closer, []grpc.DialOption, error)

SetUpGRPCTracing configures grpc dial functions for tracing.

func WrapError added in v0.3.0

func WrapError(err error, message string, args ...interface{}) error

WrapError wraps an error with fmt.Error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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