Documentation
¶
Overview ¶
Package k8simport maps Kubernetes manifests onto Levelrail stack documents. It parses text only: it never fetches, executes or applies.
Index ¶
Constants ¶
const ( EnvMaxBytes = "APP_K8S_IMPORT_MAX_BYTES" EnvMaxDocs = "APP_K8S_IMPORT_MAX_DOCS" EnvMaxNodes = "APP_K8S_IMPORT_MAX_NODES" EnvMaxDepth = "APP_K8S_IMPORT_MAX_DEPTH" EnvMaxAnchorDepth = "APP_K8S_IMPORT_MAX_ANCHOR_DEPTH" // EnvDefaultPort is the placeholder port for workloads that declare none. EnvDefaultPort = "APP_K8S_IMPORT_DEFAULT_PORT" )
Caps read from the environment so an operator can tune them without a rebuild.
const ( NamespaceEnvironment = "environment" NamespacePrefix = "prefix" NamespaceIgnore = "ignore" )
Namespace handling modes for Options.NamespaceAs.
Variables ¶
var ErrInput = errors.New("k8simport: input refused")
ErrInput marks every refusal of the raw input (size, shape, bombs).
Functions ¶
func DefaultPortFromEnv ¶
func DefaultPortFromEnv() int
DefaultPortFromEnv is the port given to a workload that names none, since every app needs one even when nothing listens on it.
Types ¶
type AppSummary ¶
type AppSummary struct {
Name string `json:"name"`
Source string `json:"source"`
Image string `json:"image"`
Port int `json:"port,omitempty"`
Replicas int `json:"replicas"`
Domains []string `json:"domains,omitempty"`
EnvKeys []string `json:"envKeys,omitempty"`
SecretKeys []string `json:"secretKeys,omitempty"`
}
AppSummary describes one app the import would create.
type Finding ¶
type Finding struct {
Kind string `json:"kind"`
Name string `json:"name"`
Field string `json:"field"`
Reason string `json:"reason"`
Severity Severity `json:"severity"`
}
Finding is one field the importer could not map faithfully. It never carries a Secret or ConfigMap value, only names and paths.
type Limits ¶
type Limits struct {
MaxBytes int
MaxDocs int
// MaxNodes counts YAML nodes after alias expansion, the yaml-bomb guard.
MaxNodes int
MaxDepth int
MaxAnchorDepth int
}
Limits bound the input so a hostile file cannot exhaust memory or CPU.
func LimitsFromEnv ¶
func LimitsFromEnv() Limits
LimitsFromEnv reads the caps, falling back to the defaults.
type Options ¶
type Options struct {
AppPrefix string
NamespaceAs string
// Project names the project documents when NamespaceAs is environment.
Project string
Limits Limits
}
Options tune a conversion.
type Result ¶
type Result struct {
// Documents is multi-document YAML in the stack format apply accepts.
Documents string `json:"documents"`
Apps []AppSummary `json:"apps"`
Findings []Finding `json:"findings"`
// contains filtered or unexported fields
}
Result is the outcome of a conversion. Documents hold no secret value.