Documentation
¶
Overview ¶
Package target resolves and represents the Kubernetes destination used by a Deployah invocation.
A Target owns Kubernetes context, namespace, and kubeconfig resolution. It does not load Deployah specs or platform files and does not construct Helm or Kubernetes clients.
Context precedence ¶
- explicit context override (--context)
- platform environment context name supplied to Resolver.Resolve
- kubeconfig current-context
Target.Context is the effective context name. Target.ContextSource records which rule selected it. When Context is non-empty, Target.ClientConfig and Target.RESTConfig pin that name. Both use the snapshotted kubeconfig loading rules, pin Target.Namespace, and do not select in-cluster configuration.
Namespace precedence ¶
- explicit namespace override
- namespace of the selected kubeconfig context
- "default"
Resolve pins context, source selection, and loading rules against later KUBECONFIG or HOME changes. Kubeconfig file contents stay live until configuration is loaded.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// KubeconfigPath is an explicit kubeconfig file. When set it takes
// full precedence over extra paths and KUBECONFIG.
KubeconfigPath string
// ContextOverride is an explicit context name, typically --context.
ContextOverride string
// NamespaceOverride is an explicit namespace, typically --namespace.
NamespaceOverride string
// ExtraKubeconfigPaths are prepended to default kubeconfig precedence
// when KubeconfigPath is empty. Missing files are tolerated.
ExtraKubeconfigPaths []string
}
Config holds Kubernetes destination inputs for a Resolver. It describes kubeconfig and override selection only.
type ContextSource ¶
type ContextSource uint8
ContextSource identifies which rule selected Target.Context.
const ( // ContextSourceKubeconfig means the kubeconfig current-context was used. ContextSourceKubeconfig ContextSource = iota // ContextSourcePlatform means the caller supplied a platform context. ContextSourcePlatform // ContextSourceExplicit means an explicit context override was set. ContextSourceExplicit )
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver owns immutable destination-resolution configuration.
func NewResolver ¶
NewResolver returns a Resolver that copies config so later mutation of ExtraKubeconfigPaths cannot change resolution.
func (*Resolver) Resolve ¶
Resolve returns an immutable Target for platformContext.
platformContext is a Kubernetes context name already chosen by the caller. Resolve does not load Deployah platform or spec files. Kubeconfig read failures do not fail Resolve; Target.RESTConfig reports them when a connection config is required.
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
Target is an immutable resolved Kubernetes destination.
After Resolver.Resolve, Context, ContextSource, Namespace, and the kubeconfig loading snapshot do not change. Concurrent calls to the getters, Target.ClientConfig, and Target.RESTConfig are safe.
func (*Target) ClientConfig ¶
func (t *Target) ClientConfig() clientcmd.ClientConfig
ClientConfig returns a lazy Kubernetes client configuration for this destination.
The returned value does not read kubeconfig files until RawConfig or ClientConfig is called. Namespace returns the Target namespace without loading. When Context is non-empty, that context is pinned. Namespace is always pinned to Target.Namespace. Loading rules come from the Resolve snapshot. It does not use in-cluster configuration.
func (*Target) Context ¶
Context returns the effective Kubernetes context name. An empty string means no context could be resolved.
func (*Target) ContextSource ¶
func (t *Target) ContextSource() ContextSource
ContextSource returns which rule selected Target.Context.
func (*Target) Namespace ¶
Namespace returns the effective namespace. Precedence is explicit override, then the selected kubeconfig context namespace, then "default".
func (*Target) RESTConfig ¶
RESTConfig returns a kubeconfig-based REST config for this destination.
It uses Target.ClientConfig. When Context is non-empty, the config pins that context. Namespace is pinned to Target.Namespace. Loading rules come from the snapshot taken at Resolve, not from the current process environment. It does not use in-cluster configuration. Load errors from the snapshotted rules are returned; kubeconfig file contents are read at call time.