config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config turns the environment and Keychain token into a Config. It never reads process state; callers pass everything in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	HubURL         *url.URL // no trailing slash; may include a base path
	Token          Secret
	TokenSource    TokenSource
	TokenUserID    string    // the token's "id" claim
	TokenExpiresAt time.Time // checked later; an expired token still parses
	LogLevel       slog.Level
}

Config is the validated startup configuration.

func Parse

func Parse(env map[string]string, keychainToken string) (Config, error)

Parse validates env and the Keychain token (empty if none) into a Config. It reports every problem at once.

type Secret

type Secret string

Secret is a string that prints as "***" in fmt, slog and JSON.

func (Secret) GoString

func (Secret) GoString() string

GoString redacts %#v.

func (Secret) LogValue

func (Secret) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (Secret) MarshalJSON

func (Secret) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (Secret) Reveal

func (s Secret) Reveal() string

Reveal returns the raw value.

func (Secret) String

func (Secret) String() string

type TokenInfo

type TokenInfo struct {
	UserID    string
	ExpiresAt time.Time // an expired token still parses
}

TokenInfo is what a token says about itself.

func ParseToken

func ParseToken(tok string) (TokenInfo, error)

ParseToken runs the same checks on tok as Parse.

type TokenSource added in v0.2.0

type TokenSource string

TokenSource is where the hub token came from.

const (
	SourceKeychain TokenSource = "keychain"
	SourceEnv      TokenSource = "env"
)

The token sources.

Jump to

Keyboard shortcuts

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