util

package
v1.12.4 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: Apache-2.0 Imports: 25 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckedCast added in v1.12.0

func CheckedCast[To, From Int](v From) (To, error)

func DedupRegistrationEntries

func DedupRegistrationEntries(entries []*common.RegistrationEntry) []*common.RegistrationEntry

func EqualsSelectors added in v1.1.0

func EqualsSelectors(a, b []*common.Selector) bool

func GetSHA256Digest added in v1.3.1

func GetSHA256Digest(path string, limit int64) (string, error)

GetSHA256Digest calculates the sha256 digest of a file specified by path. If the size of the file exceeds the provided limit, the hash will not be calculated and an error will be returned instead.

func GetTargetName added in v1.2.2

func GetTargetName(addr net.Addr) (string, error)

GetTargetName gets the fully qualified, self-contained name used for gRPC channel construction. Supported networks are unix and tcp. Unix paths must be absolute.

func GetUnixAddr added in v1.3.0

func GetUnixAddr(name string) *net.UnixAddr

func GetUnixAddrWithAbsPath added in v1.2.2

func GetUnixAddrWithAbsPath(path string) (*net.UnixAddr, error)

GetUnixAddr returns a unix address with the designated path. Path is converted to an absolute path when constructing the returned unix domain socket address.

func GetWorkloadAPIClientOption added in v1.3.0

func GetWorkloadAPIClientOption(addr net.Addr) (workloadapi.ClientOption, error)

func LoadCertPool

func LoadCertPool(path string) (*x509.CertPool, error)

LoadCertPool loads one or more certificates into an *x509.CertPool from a PEM file on disk.

func LoadCertificates

func LoadCertificates(path string) ([]*x509.Certificate, error)

LoadCertificates loads one or more certificates into an []*x509.Certificate from a PEM file on disk.

func MakeCSR

func MakeCSR(privateKey any, spiffeID spiffeid.ID) ([]byte, error)

func MakeCSRWithoutURISAN

func MakeCSRWithoutURISAN(privateKey any) ([]byte, error)

func MustCast added in v1.12.0

func MustCast[To, From Int](v From) To

func NewCertPool

func NewCertPool(certs ...*x509.Certificate) *x509.CertPool

NewCertPool creates a new *x509.CertPool based on the certificates given as parameters.

func NewGRPCClient added in v1.11.2

func NewGRPCClient(target string, options ...grpc.DialOption) (*grpc.ClientConn, error)

func RunTasks

func RunTasks(ctx context.Context, tasks ...func(context.Context) error) error

RunTasks executes all the provided functions concurrently and waits for them all to complete. If a function returns an error, all other functions are canceled (i.e. the context they are passed is canceled) and the error is returned. If all functions finish to completion successfully, RunTasks returns nil. If the context passed to RunTasks is canceled then each function is canceled and RunTasks returns ctx.Err(). Tasks passed to RunTasks MUST support cancellation via the provided context for RunTasks to work properly.

func SortRegistrationEntries

func SortRegistrationEntries(entries []*common.RegistrationEntry)

func SortSelectors

func SortSelectors(selectors []*common.Selector)

func SortTypesEntries added in v0.12.0

func SortTypesEntries(entries []*types.Entry)

func SortTypesSelectors added in v0.12.0

func SortTypesSelectors(selectors []*types.Selector)

Types

type Int added in v1.12.0

type Int interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

Jump to

Keyboard shortcuts

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