system

package
v1.5.0-dev14 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 21 Imported by: 4

Documentation

Index

Constants

View Source
const InstallationIDFile = "installation_id"

InstallationIDFile is the name of the file storing the installation ID.

Variables

View Source
var MaxStderrFileLength = 1 * datasize.GB

MaxStderrFileLength sets the max size for stderr file during container execution (needed to prevent DoS)

View Source
var MaxStderrReturnLength = 2 * datasize.KB

MaxStderrReturnLength sets the max size for stderr string return into RunOutput (with truncation) from container execution (needed to prevent DoS)

View Source
var MaxStdoutFileLength = 1 * datasize.GB

MaxStdoutFileLength sets the max size for stdout file during container execution (needed to prevent DoS)

View Source
var MaxStdoutReturnLength = 2 * datasize.KB

MaxStdoutReturnLength sets the max size for stdout string return into RunOutput (with truncation) from container execution (needed to prevent DoS)

Functions

func ConvertToClientID added in v1.2.1

func ConvertToClientID(key *rsa.PublicKey) string

ConvertToClientID converts a public key to a client ID:

func DecodePublicKey added in v1.2.1

func DecodePublicKey(key string) (*rsa.PublicKey, error)

DecodePublicKey decodes a public key from a string:

func FindJobIDInTestOutput

func FindJobIDInTestOutput(testOutput string) string

func FindJobIDInTestOutputLegacy added in v1.1.0

func FindJobIDInTestOutputLegacy(testOutput string) string

func InstallationID added in v1.5.0

func InstallationID() string

InstallationID is a convenience function that returns the installation ID using the DefaultGlobalConfig.

func IsDebugMode added in v1.5.0

func IsDebugMode() bool

IsDebugMode returns true if the environment variable DEBUG is set to true

func MustParseURL added in v0.3.25

func MustParseURL(uri string) *url.URL

func PathExists

func PathExists(path string) (bool, error)

PathExists returns whether the given file or directory exists

func PublicKeyMatchesID

func PublicKeyMatchesID(publicKey, clientID string) (bool, error)

PublicKeyMatchesID returns true if the given base64-encoded public key and the given client ID correspond to each other:

func ReverseList

func ReverseList(s []string) []string

func SplitLines

func SplitLines(s string) []string

func Verify

func Verify(msg []byte, sig, publicKey string) error

Verify verifies a signed message with the given encoding of a public key. Returns non nil if the key is invalid.

Types

type CleanupManager

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

CleanupManager provides utilities for ensuring that sub-goroutines can clean up their resources before the main goroutine exits. Can be used to register callbacks for long-running system processes.

func NewCleanupManager

func NewCleanupManager() *CleanupManager

NewCleanupManager returns a new CleanupManager instance.

func (*CleanupManager) Cleanup

func (cm *CleanupManager) Cleanup(ctx context.Context)

Cleanup runs all registered clean-up functions in sub-goroutines and waits for them all to complete before exiting.

func (*CleanupManager) RegisterCallback

func (cm *CleanupManager) RegisterCallback(fn cleanUpWithoutContext)

RegisterCallback registers a clean-up function.

func (*CleanupManager) RegisterCallbackWithContext

func (cm *CleanupManager) RegisterCallbackWithContext(fn cleanUpWithContext)

RegisterCallbackWithContext registers a clean-up function. The context passed is guaranteed not to be already canceled.

type FunctionWaiter

type FunctionWaiter struct {
	Name        string
	MaxAttempts int
	Delay       time.Duration
	Handler     func() (bool, error)
}

func (*FunctionWaiter) Wait

func (waiter *FunctionWaiter) Wait(ctx context.Context) error

type GlobalConfig added in v1.5.0

type GlobalConfig interface {
	// InstallationID returns the unique identifier for this installation, if available.
	InstallationID() string
	// ConfigDir returns the path to the configuration directory.
	ConfigDir() string
}

GlobalConfig defines the interface for accessing global configuration settings. The interface is used to abstract the configuration directory and installation ID and allows for easy testing, such as testing migration logic.

var DefaultGlobalConfig GlobalConfig = &realGlobalConfig{}

DefaultGlobalConfig is the default implementation of GlobalConfig.

type MessageSigner added in v1.3.2

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

func NewMessageSigner added in v1.3.2

func NewMessageSigner(sk *rsa.PrivateKey) *MessageSigner

func (*MessageSigner) PublicKey added in v1.3.2

func (m *MessageSigner) PublicKey() *rsa.PublicKey

func (*MessageSigner) PublicKeyString added in v1.3.2

func (m *MessageSigner) PublicKeyString() string

PublicKeyString returns a base64-encoding of the user's public ID key:

func (*MessageSigner) Sign added in v1.3.2

func (m *MessageSigner) Sign(msg []byte) (string, error)

type Signer added in v1.3.2

type Signer interface {
	// Sign signs a message with the user's private ID key.
	Sign(msg []byte) (string, error)
	PublicKey() *rsa.PublicKey
	PublicKeyString() string
}

Jump to

Keyboard shortcuts

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