preview

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 9 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 preview manages preview feature gates enabled via the --preview flag.

The gates are process-wide. A binary calls Init exactly once, before anything calls IsEnabled or AsMap.

Index

Constants

View Source
const All = "ALL"

All is the pseudo-gate name that enables every known gate.

View Source
const Header = "Ate-Preview-Allowed"

Header is the gRPC metadata key with which an API client says it intends to use preview features. It is a coarse guard against using them by accident, not an access control: any client may send it, and it applies to every enabled gate at once. Its value is a boolean, e.g. "true".

Variables

This section is empty.

Functions

func AsMap

func AsMap() map[string]bool

AsMap returns the map of known gate names to their enabled state. The returned map MUST NOT be modified.

TODO: Fix this to use an interface when DV supports it.

func ContextWithOptIn

func ContextWithOptIn(ctx context.Context) context.Context

ContextWithOptIn marks ctx as being opted-in to preview features, overriding any earlier ContextWithOptOut. Code which acts for the system rather than for a user, such as workflows, uses it so that work which an API request started is not limited by that request's opt-out.

func ContextWithOptOut

func ContextWithOptOut(ctx context.Context) context.Context

ContextWithOptOut marks ctx as being opted-out from preview features.

func DialOptionsWithOptIn

func DialOptionsWithOptIn() []grpc.DialOption

DialOptionsWithOptIn returns gRPC dial options which send Header on every call made over the connection.

func DisabledMap

func DisabledMap() map[string]bool

DisabledMap returns the map of known gate names, all disabled. The returned map MUST NOT be modified.

TODO: Fix this to use an interface when DV supports it.

func Init

func Init(values ...string) error

Init sets the process-wide preview gates from the --preview flag values. The special value All enables all known gates. With no values, all gates are disabled. It panics if called again after the first successful call.

func InitForTest

func InitForTest(tb testingTB, values ...string)

InitForTest sets the process-wide preview gates for the duration of tb, as Init would with values, and restores the previous state when tb ends. It may be called whether or not Init has been. Tests that use it must not run in parallel.

func InitForTestFake

func InitForTestFake(tb testingTB, fakeKnownGates []Gate, values ...string)

InitForTestFake is InitForTest with fake gate names. Tests of the preview gate system itself should use this to avoid depending on the real gate names. Tests that use it must not run in parallel.

func IsEnabled

func IsEnabled(gate Gate) bool

IsEnabled reports whether the given preview gate is enabled. Unknown gates are always treated as disabled.

func IsEnabledFor

func IsEnabledFor(ctx context.Context, gate Gate) bool

IsEnabledFor reports whether gate is enabled in this process and ctx has not opted-out of preview features.

func IsOptedOut

func IsOptedOut(ctx context.Context) bool

IsOptedOut reports whether the context has opted-out of using preview features. By default, contexts are allowed to use preview, but some call-paths (e.g. public API) may restrict that, so we provide this mechanism to explicitly opt out.

func StreamServerInterceptor

func StreamServerInterceptor(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error

StreamServerInterceptor restricts each stream that did not send Header.

func UnaryServerInterceptor

func UnaryServerInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

UnaryServerInterceptor restricts each request that did not send Header.

func Verify

func Verify(values ...string) error

Verify checks that the given values are all valid preview gates.

Types

type Gate

type Gate string

Gate identifies a gate-controlled preview feature. Preview gates are disabled by default, except:

  • when a gated feature becomes "stable" (aka GA)
  • when a gated feature is removed

In both cases, the gate is retained for a while (for compatibility with existing uses of the --preview flag), but the feature is either always enabled or totally disabled, respectively. Such gates are "vestigial".

const (
	// GateExternalVolumes controls whether external volumes are supported.
	GateExternalVolumes Gate = "ExternalVolumes"

	// GateGoldenEgressPolicy controls configuring a golden actor's egress policy on its template.
	GateGoldenEgressPolicy Gate = "GoldenEgressPolicy"

	// GatePerTemplateSnapshotLocation controls whether an ActorTemplate may
	// set snapshotConfig.storage_location. When disabled, the API rejects the
	// field and snapshots are stored under ate-api-server's
	// --snapshot-location.
	GatePerTemplateSnapshotLocation Gate = "PerTemplateSnapshotLocation"
)

Gates should always be named in UpperCamelCase. Please keep this list sorted alphabetically by value.

Jump to

Keyboard shortcuts

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