util

package
v0.0.0-...-bc69434 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Green ANSI Escape Code
	Green = "\033[32m"
	// Red ANSI Escape Code
	Red = "\033[31m"
	// Reset ANSI Escape Code
	Reset = "\033[0m"
	// Yellow ANSI Escape Code
	Yellow = "\033[33m"
)

Functions

func Colorize

func Colorize(color, message string) string

Colorize wraps a given message in a given color.

func ElapsedTime

func ElapsedTime(ctx context.Context, action string)

ElapsedTime log task elapsed time

func FetchCommits

func FetchCommits(repository *git.Repository, info *hook.Info, hookType string) (commitIter object.CommitIter, err error)

FetchCommits fetching commits

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID will get requestID from a git push

func GetStartTime

func GetStartTime(ctx context.Context) time.Time

GetStartTime get start time

func GetUserID

func GetUserID(ctx context.Context) string

GetUserID will get userID from a git push

func InitializeContext

func InitializeContext() context.Context

InitializeContext initialize context

func ItemExists

func ItemExists(arrayType interface{}, item interface{}) bool

ItemExists check if an element exists in array

func LoadRepository

func LoadRepository(ctx context.Context, options *config.Options) (*git.Repository, error)

LoadRepository load git repository

func ParseGitPushOptions

func ParseGitPushOptions()

ParseGitPushOptions parse git push options

func PrintBanner

func PrintBanner(ctx context.Context, options *config.Options) error

PrintBanner Print watchdog banner

func PrintMessage

func PrintMessage(message string)

PrintMessage print message in the stdout

func RevList

func RevList(repository *git.Repository, info *hook.Info) (object.CommitIter, error)

RevList is native implemetation of git rev-list command

Types

type ConcurrentSliceItem

type ConcurrentSliceItem struct {
	Index int
	Value interface{}
}

ConcurrentSliceItem Concurrent slice item

type ContextKey

type ContextKey string

ContextKey is used for context.Context value. The value requires a key that is not primitive type.

const (
	// ContextKeyRequestID is the ContextKey for RequestID
	ContextKeyRequestID ContextKey = "requestID"
	// ContextKeyStartTime is the ContextKey for UserID
	ContextKeyStartTime ContextKey = "startTime"
	// ContextKeyUserID is the ContextKey for UserID
	ContextKeyUserID ContextKey = "userId"
	// ContextKeyValues is the ContextKey for all values
	ContextKeyValues ContextKey = "contextValues"
)

type ContextValues

type ContextValues struct {
	ValuesMap map[ContextKey]interface{}
}

ContextValues context values

func (ContextValues) Get

func (values ContextValues) Get(key ContextKey) interface{}

Get return value for given key

type HTTPClient

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

HTTPClient data structure

func CreateHTTPClient

func CreateHTTPClient(httpClient *http.Client, baseURL string) (*HTTPClient, error)

CreateHTTPClient create new http client

func (*HTTPClient) CreateRequest

func (client *HTTPClient) CreateRequest(method string, endpointURL string, body io.Reader) (*http.Request, error)

CreateRequest create raw request

func (*HTTPClient) Do

func (client *HTTPClient) Do(req *http.Request, mapper interface{}) (*http.Response, error)

Do excute http request

type RevListOptions

type RevListOptions struct {
	// OldRev is the first reference hash to link
	OldRev plumbing.Hash
	// NewRev is the second reference hash to link
	NewRev plumbing.Hash
}

RevListOptions defines the rules of rev-list func

type Set

type Set struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Set struct

func NewSet

func NewSet() *Set

NewSet create new thread safe set

func (*Set) Add

func (s *Set) Add(items []issue.Issue)

Add add

func (*Set) Clear

func (s *Set) Clear()

Clear removes all items from the set

func (*Set) Iter

func (s *Set) Iter() <-chan ConcurrentSliceItem

Iter Iterates over the items in the concurrent slice

func (*Set) Len

func (s *Set) Len() int

Len returns the number of items in a set.

func (*Set) List

func (s *Set) List() []issue.Issue

List returns a slice of all items

Jump to

Keyboard shortcuts

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