Documentation
¶
Overview ¶
Copyright Thought Machine, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func CloseAndIgnoreError(closer interface{ ... })
- func Fprintf(writer io.Writer, format string, args ...interface{})
- func GetPackageTaskFromId(taskId string) (packageName string, task string)
- func GetTaskId(pkgName interface{}, target string) string
- func HelpForCobraCmd(cmd *cobra.Command) string
- func InitPrintf()
- func IsNMLinker(cwd string) (bool, error)
- func IsPackageTask(task string) bool
- func IsYarn(backendName string) bool
- func PositiveMod(x, d int) int
- func Printf(format string, args ...interface{})
- func RootTaskID(target string) string
- func RootTaskTaskName(taskID string) string
- func Sprintf(format string, args ...interface{}) string
- func StripPackageName(taskID string) string
- func ToTaskOutputModeString(value TaskOutputMode) (string, error)
- func ValidateGraph(graph *dag.AcyclicGraph) error
- type CacheDisabledError
- type CachingStatus
- type ConcurrencyValue
- type ExitCodeError
- type Hashable
- type Semaphore
- type Set
- func (s Set) Add(v interface{})
- func (s Set) Copy() Set
- func (s Set) Delete(v interface{})
- func (s Set) Difference(other Set) Set
- func (s Set) Filter(cb func(interface{}) bool) Set
- func (s Set) Includes(v interface{}) bool
- func (s Set) Intersection(other Set) Set
- func (s Set) Len() int
- func (s Set) List() []interface{}
- func (s Set) Some(cb func(interface{}) bool) bool
- func (s Set) UnsafeListOfStrings() []string
- type TaskOutputMode
- type YarnRC
Constants ¶
const ( // TaskDelimiter separates a package name from a task name in a task id TaskDelimiter = "#" // RootPkgName is the reserved name that specifies the root package RootPkgName = "//" )
Variables ¶
var TaskOutputModeStrings = []string{
fullTaskOutputString,
noTaskOutputString,
hashTaskOutputString,
newTaskOutputString,
}
TaskOutputModeStrings is an array containing the string representations for task output modes
Functions ¶
func CloseAndIgnoreError ¶
func CloseAndIgnoreError(closer interface{ Close() error })
CloseAndIgnoreError is a utility to tell our linter that we explicitly deem it okay to not check a particular error on closing of a resource.
We use `errcheck` as a linter, which is super-opinionated about checking errors, even in places where we don't necessarily care to check the error.
`golangci-lint` has a default ignore list for this lint problem (EXC0001) which can be used to sidestep this problem but it's possibly a little too-heavy-handed in exclusion. At the expense of discoverability, this utility function forces opt-in to ignoring errors on closing of things that can be `Close`d.
func GetPackageTaskFromId ¶
GetPackageTaskFromId returns a tuple of the package name and target task
func HelpForCobraCmd ¶
HelpForCobraCmd returns the help string for a given command Note that this overwrites the output for the command
func IsNMLinker ¶
func IsPackageTask ¶
IsPackageTask returns true if a is a package-specific task (e.g. myapp#build)
func PositiveMod ¶
PostitiveMod returns a modulo operator like JavaScripts
func RootTaskID ¶
RootTaskID returns the task id for running the given task in the root package
func RootTaskTaskName ¶
RootTaskTaskName returns the task portion of a root task taskID
func Sprintf ¶
printf is used throughout this package to print something to stderr with some replacements for pseudo-shell variables for ANSI formatting codes.
func StripPackageName ¶
StripPackageName removes the package portion of a taskID if it is a package task. Non-package tasks are returned unmodified
func ToTaskOutputModeString ¶
func ToTaskOutputModeString(value TaskOutputMode) (string, error)
ToTaskOutputModeString converts a task output mode enum value into the string representation
func ValidateGraph ¶
func ValidateGraph(graph *dag.AcyclicGraph) error
ValidateGraph checks that a given DAG has no cycles and no self-referential edges. We differ from the underlying DAG Validate method in that we allow multiple roots.
Types ¶
type CacheDisabledError ¶
type CacheDisabledError struct { Status CachingStatus Message string }
CacheDisabledError is an error used to indicate that remote caching is not available.
func (*CacheDisabledError) Error ¶
func (cd *CacheDisabledError) Error() string
type CachingStatus ¶
type CachingStatus int
CachingStatus represents the api server's perspective on whether remote caching should be allowed
const ( // CachingStatusDisabled indicates that the server will not accept or serve artifacts CachingStatusDisabled CachingStatus = iota // CachingStatusEnabled indicates that the server will accept and serve artifacts CachingStatusEnabled // CachingStatusOverLimit indicates that a usage limit has been hit and the // server will temporarily not accept or serve artifacts CachingStatusOverLimit // CachingStatusPaused indicates that a customer's spending has been paused and the // server will temporarily not accept or serve artifacts CachingStatusPaused )
func CachingStatusFromString ¶
func CachingStatusFromString(raw string) (CachingStatus, error)
CachingStatusFromString parses a raw string to a caching status enum value
type ConcurrencyValue ¶
type ConcurrencyValue struct { Value *int // contains filtered or unexported fields }
ConcurrencyValue allows pflag to accept either a number or percentage of available CPUs as a value for concurrency
func (*ConcurrencyValue) Set ¶
func (cv *ConcurrencyValue) Set(value string) error
Set implements pflag.Value.Set for ConcurrencyValue
func (*ConcurrencyValue) String ¶
func (cv *ConcurrencyValue) String() string
String implements pflag.Value.String for ConcurrencyValue
func (*ConcurrencyValue) Type ¶
func (cv *ConcurrencyValue) Type() string
Type implements pflag.Value.Type for ConcurrencyValue
type ExitCodeError ¶
type ExitCodeError struct {
ExitCode int
}
ExitCodeError is a specific error that is returned by the command to specify the exit code
func (*ExitCodeError) Error ¶
func (e *ExitCodeError) Error() string
type Hashable ¶
type Hashable interface {
Hashcode() interface{}
}
Hashable is the interface used by set to get the hash code of a value. If this isn't given, then the value of the item being added to the set itself is used as the comparison value.
type Semaphore ¶
type Semaphore chan struct{}
Semaphore is a wrapper around a channel to provide utility methods to clarify that we are treating the channel as a semaphore
func NewSemaphore ¶
NewSemaphore creates a semaphore that allows up to a given limit of simultaneous acquisitions
func (Semaphore) Acquire ¶
func (s Semaphore) Acquire()
Acquire is used to acquire an available slot. Blocks until available.
func (Semaphore) Release ¶
func (s Semaphore) Release()
Release is used to return a slot. Acquire must be called as a pre-condition.
func (Semaphore) TryAcquire ¶
TryAcquire is used to do a non-blocking acquire. Returns a bool indicating success
type Set ¶
type Set map[interface{}]interface{}
Set is a set data structure.
func SetFromStrings ¶
SetFromStrings creates a Set containing the strings from the given slice
func (Set) Difference ¶
Difference returns a set with the elements that s has but other doesn't.
func (Set) Filter ¶
Filter returns a set that contains the elements from the receiver where the given callback returns true.
func (Set) Intersection ¶
Intersection computes the set intersection with other.
func (Set) Some ¶
Some tests whether at least one element in the array passes the test implemented by the provided function. It returns a Boolean value.
func (Set) UnsafeListOfStrings ¶
UnsafeListOfStrings dangerously casts list to a string
type TaskOutputMode ¶
type TaskOutputMode int
TaskOutputMode defines the ways titan can display task output during a run
const ( // FullTaskOutput will show all task output FullTaskOutput TaskOutputMode = iota // NoTaskOutput will hide all task output NoTaskOutput // HashTaskOutput will display titan-computed task hashes HashTaskOutput // NewTaskOutput will show all new task output and titan-computed task hashes for cached output NewTaskOutput )
func FromTaskOutputModeString ¶
func FromTaskOutputModeString(value string) (TaskOutputMode, error)
FromTaskOutputModeString converts a task output mode's string representation into the enum value
func (*TaskOutputMode) UnmarshalJSON ¶
func (c *TaskOutputMode) UnmarshalJSON(data []byte) error
UnmarshalJSON converts a task output mode string representation into an enum