util

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadClientMTLSConfig

func LoadClientMTLSConfig(certs MTLSSpecShape) (*tls.Config, error)

func LoadServingCertBundle

func LoadServingCertBundle(certsSpec CertsSpecShape) (*tls.Certificate, *x509.CertPool, error)

func Must

func Must[T any](t T, err ...error) T

func ParsePEMEncodedCert

func ParsePEMEncodedCert(data []byte) (*x509.Certificate, error)

func ParsePEMEncodedCertChain

func ParsePEMEncodedCertChain(chain []byte) ([]*x509.Certificate, error)

func WaitAll added in v0.1.1

func WaitAll(ctx context.Context, ca context.CancelCauseFunc, channels ...<-chan error) error

WaitAll waits for all the given channels to be closed, under the following rules: 1. The lifetime of the task represented by each channel is directly tied to the provided context. 2. If a task exits with an error before the context is canceled, the context should be canceled. 3. If a task exits successfully, the context should not be canceled and other tasks should continue to run.

Types

type CertsSpecShape

type CertsSpecShape = struct {
	// Path to a PEM encoded CA certificate file. Mutually exclusive with CACertData
	CACert *string `json:"caCert,omitempty" toml:"caCert"`
	// String containing PEM encoded CA certificate data. Mutually exclusive with CACert
	CACertData []byte `json:"caCertData,omitempty" toml:"caCertData"`
	// Path to a PEM encoded server certificate file. Mutually exclusive with ServingCertData
	ServingCert *string `json:"servingCert,omitempty" toml:"servingCert"`
	// String containing PEM encoded server certificate data. Mutually exclusive with ServingCert
	ServingCertData []byte `json:"servingCertData,omitempty" toml:"servingCertData"`
	// Path to a PEM encoded server key file. Mutually exclusive with ServingKeyData
	ServingKey *string `json:"servingKey,omitempty" toml:"servingKey"`
	// String containing PEM encoded server key data. Mutually exclusive with ServingKey
	ServingKeyData []byte `json:"servingKeyData,omitempty" toml:"servingKeyData"`
}

type Initializer added in v0.1.1

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

func (*Initializer) InitOnce added in v0.1.1

func (i *Initializer) InitOnce(f func())

func (*Initializer) Initialized added in v0.1.1

func (i *Initializer) Initialized() bool

func (*Initializer) WaitForInit added in v0.1.1

func (i *Initializer) WaitForInit()

func (*Initializer) WaitForInitContext added in v0.1.1

func (i *Initializer) WaitForInitContext(ctx context.Context) error

type MTLSSpecShape

type MTLSSpecShape = struct {
	// Path to the server CA certificate.
	ServerCA string `json:"serverCA,omitempty" toml:"serverCA"`
	// Path to the client CA certificate (not needed in all cases).
	ClientCA string `json:"clientCA,omitempty" toml:"clientCA"`
	// Path to the certificate used for client-cert auth.
	ClientCert string `json:"clientCert,omitempty" toml:"clientCert"`
	// Path to the private key used for client-cert auth.
	ClientKey string `json:"clientKey,omitempty" toml:"clientKey"`
}

type MultiErrGroup

type MultiErrGroup struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

tasks := []func() error{/* */}

for _, task := range tasks {
	eg.Go(func() error {
	return task()
	}
}

eg.Wait()

if err := eg.Error(); err != nil {
	// handle error
}

func (*MultiErrGroup) Add

func (i *MultiErrGroup) Add(tasks int)

func (*MultiErrGroup) Done

func (i *MultiErrGroup) Done()

func (*MultiErrGroup) Error

func (i *MultiErrGroup) Error() error

func (*MultiErrGroup) Errors

func (i *MultiErrGroup) Errors() []error

func (*MultiErrGroup) Go

func (i *MultiErrGroup) Go(fn func() error)

func (*MultiErrGroup) Wait

func (i *MultiErrGroup) Wait()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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