util

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandUser

func ExpandUser(s string) (string, error)

ExpandUser turns, e.g., ~/hello to /home/youruser/hello it does *not* work on ~user/blah paths, however

func RunContextuallyInParallel

func RunContextuallyInParallel(ctx context.Context, funcs ...func(context.Context) error) error

RunContextuallyInParallel runs a set of goroutines which take a context and waits for them to terminate if any of the goroutines fail with an error, they will all immediately have their context cancelled and this method will return that error

func WaitCmdContextually

func WaitCmdContextually(ctx context.Context, cmd *exec.Cmd) error

WaitCmdContextually waits for a given exec.Cmd "in" the given context. There are two cases:

  1. If the command finishes before the context is finished, the result of cmd.Run is returned
  2. If the context is cancelled before the command finishes, the command's process is killed forcefully and this method returns immediately.

Types

type BuildableService

type BuildableService struct {
	Dir        string
	Dockerfile string
	Name       string
}

func FindServices

func FindServices(dir string, ignorePaths []string) ([]BuildableService, error)

FindServices finds all of the buildable services in the given directory (e.g., folders which contain a Dockerfile)

type StringRingBuffer

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

StringRingBuffer is a type which implements a ring buffer for strings

func CreateStringRingBuffer

func CreateStringRingBuffer(size int) *StringRingBuffer

CreateStringRingBuffer creates a StringRingBuffer of a fixed, given size

func (*StringRingBuffer) Peek

func (r *StringRingBuffer) Peek(num int) []string

Peek gets the last N elements inserted into this buffer, where the latest is the last element returned

func (*StringRingBuffer) Push

func (r *StringRingBuffer) Push(s string)

Push adds a new element to this ring buffer

func (*StringRingBuffer) Usage

func (r *StringRingBuffer) Usage() int

Usage returns the number of elements, up to capacity, which have been inserted into this ring buffer.

Jump to

Keyboard shortcuts

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