options

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 15 Imported by: 6

README

pkg/options

Intention

pkg/options is the shared runtime-options package for platform processes. It does not provide a general configuration framework. Its job is to define the common CLI flag surface and bootstrap behavior that services, controllers, and consumers are expected to share for core process concerns.

This package is also part of the deployment contract, not just the Go API. The common flags defined here are expected to stay aligned with shared chart helpers so services expose a consistent runtime configuration surface through Helm as well as through code.

It currently provides two shared option groups:

  • CoreOptions as the common process-bootstrap base layer for namespace, logging, and observability setup
  • ServerOptions for standard HTTP listener and timeout configuration used by API processes

Invariants And Guard Rails

  • CoreOptions is the canonical base options layer for common process concerns. Higher-level service and controller option structs should embed or build on it rather than redefining namespace, logging, or OTLP flags locally.
  • ServerOptions is the canonical shared flag surface for standard API server listener and timeout behavior.
  • AddFlags() methods here define shared CLI contract. Changes to flag names, meanings, or defaults have operational impact beyond this package.
  • SetupLogging() is the common path for wiring zap, controller-runtime logging, klog, and OpenTelemetry logging consistently in the same process.
  • SetupOpenTelemetry() is the common path for process-wide observability bootstrap. It sets global trace propagation plus tracer and meter providers for the process.
  • When an OTLP endpoint is configured, SetupOpenTelemetry() also bridges controller-runtime Prometheus metrics into OTLP export rather than only enabling trace export.
  • Helm chart helpers and values that surface these options are expected to stay aligned with the structs and flags defined here.

Caveats

  • The package name is broader than the actual scope. This is really shared runtime and bootstrap options, not a home for arbitrary application-specific settings.
  • CoreOptions mixes several cross-cutting deployment concerns in one struct: namespace, logging, tracing, and metrics bootstrap. That is practical for shared process setup, but it is not a particularly clean abstraction boundary.
  • The package registers flags and performs bootstrap wiring, but it does not validate higher-level application configuration or guarantee that callers use the options sensibly.
  • ServerOptions only covers generic listener and timeout behavior. Service-specific server dependencies, middleware, auth, and peer-client options belong in higher-level packages that embed this base layer.
  • The deployment contract is partly external to this package. If shared Helm helpers drift from these structs and flags, the shared process configuration contract is broken even if the Go code still compiles and starts.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CoreOptions

type CoreOptions struct {
	// Namespace is the namespace we are running in.
	Namespace string
	// OTLPEndpoint is used by OpenTelemetry.
	OTLPEndpoint string
	// TraceSampingRatio is the number percentage of trace samples to take
	// as a value between 0.0-1.0.
	TraceSampingRatio float64
	// Zap controls common logging.
	Zap zap.Options
}

CoreOptions are things all controllers, message consumers and servers will need. There is a corresponding Helm include that matches this type.

func (*CoreOptions) AddFlags

func (o *CoreOptions) AddFlags(flags *pflag.FlagSet)

func (*CoreOptions) SetupLogging

func (o *CoreOptions) SetupLogging()

func (*CoreOptions) SetupOpenTelemetry

func (o *CoreOptions) SetupOpenTelemetry(ctx context.Context, opts ...trace.TracerProviderOption) error

type ServerOptions

type ServerOptions struct {
	// ListenAddress tells the server what to listen on, you shouldn't
	// need to change this, its already non-privileged and the default
	// should be modified to avoid clashes with other services e.g prometheus.
	ListenAddress string

	// ReadTimeout defines how long before we give up on the client,
	// this should be fairly short.
	ReadTimeout time.Duration

	// ReadHeaderTimeout defines how long before we give up on the client,
	// this should be fairly short.
	ReadHeaderTimeout time.Duration

	// WriteTimeout defines how long we take to respond before we give up.
	// Ideally we'd like this to be short, but Openstack in general sucks
	// for performance.  Additionally some calls like cluster creation can
	// do a cascading create, e.g. create a default control plane, than in
	// turn creates a project.
	WriteTimeout time.Duration

	// RequestTimeout places a hard limit on all requests lengths.
	RequestTimeout time.Duration
}

ServerOptions are shared across all servers.

func (*ServerOptions) AddFlags

func (o *ServerOptions) AddFlags(f *pflag.FlagSet)

Jump to

Keyboard shortcuts

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