Thanks to visit codestin.com
Credit goes to pkg.go.dev

cliutil

package
v2.24.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const AWSIPRangesURL = "https://ip-ranges.amazonaws.com/ip-ranges.json"

Variables

This section is empty.

Functions

func DiscardAfterClose

func DiscardAfterClose(wc io.WriteCloser) io.WriteCloser

DiscardAfterClose is an io.WriteCloser that discards writes after it is closed without errors. It is useful as a target for a slog.Sink such that an underlying WriteCloser, like a file, can be cleaned up without race conditions from still-active loggers.

func Hostname added in v2.5.0

func Hostname() string

Hostname returns the hostname of the machine, lowercased, with any trailing domain suffix stripped. It is cached after the first call. If the hostname cannot be determined, for any reason, localhost will be returned instead.

func NewLicenseFormatter added in v2.24.0

func NewLicenseFormatter() *cliui.OutputFormatter

NewLicenseFormatter returns a new license formatter. The formatter will return a table and JSON output.

func WarnMatchedProvisioners added in v2.18.1

func WarnMatchedProvisioners(w io.Writer, mp *codersdk.MatchedProvisioners, job codersdk.ProvisionerJob)

WarnMatchedProvisioners warns the user if there are no provisioners that match the requested tags for a given provisioner job. If the job is not pending, it is ignored.

Types

type AWSIPRanges added in v2.15.0

type AWSIPRanges struct {
	V4 []netip.Prefix
	V6 []netip.Prefix
}

func FetchAWSIPRanges added in v2.15.0

func FetchAWSIPRanges(ctx context.Context, url string) (*AWSIPRanges, error)

func (*AWSIPRanges) CheckIP added in v2.15.0

func (r *AWSIPRanges) CheckIP(ip netip.Addr) bool

CheckIP checks if the given IP address is an AWS IP.

type Queue added in v2.24.0

type Queue[T any] struct {
	// contains filtered or unexported fields
}

Queue is a FIFO queue with a fixed size. If the size is exceeded, the first item is dropped.

func NewQueue added in v2.24.0

func NewQueue[T any](size int) *Queue[T]

NewQueue creates a queue with the given size.

func (*Queue[T]) Close added in v2.24.0

func (q *Queue[T]) Close()

Close aborts any pending pops and makes future pushes error.

func (*Queue[T]) Len added in v2.24.0

func (q *Queue[T]) Len() int

func (*Queue[T]) Pop added in v2.24.0

func (q *Queue[T]) Pop() (T, bool)

Pop removes and returns the first item from the queue, waiting until there is something to pop if necessary. If closed, returns false.

func (*Queue[T]) Push added in v2.24.0

func (q *Queue[T]) Push(x T) error

Push adds an item to the queue. If closed, returns an error.

func (*Queue[T]) WithPredicate added in v2.24.0

func (q *Queue[T]) WithPredicate(pred func(x T) (T, bool)) *Queue[T]

WithPredicate adds the given predicate function, which can control what is pushed to the queue.

type StatusQueue added in v2.24.0

type StatusQueue struct {
	Queue[reportTask]
	// contains filtered or unexported fields
}

statusQueue is a Queue that: 1. Only pushes items that are not duplicates. 2. Preserves the existing message and URI when one a message is not provided. 3. Ignores "working" updates from the status watcher.

func (*StatusQueue) Push added in v2.24.0

func (q *StatusQueue) Push(report reportTask) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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