k8simport

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 13 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 k8simport maps Kubernetes manifests onto Levelrail stack documents. It parses text only: it never fetches, executes or applies.

Index

Constants

View Source
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.

View Source
const (
	NamespaceEnvironment = "environment"
	NamespacePrefix      = "prefix"
	NamespaceIgnore      = "ignore"
)

Namespace handling modes for Options.NamespaceAs.

Variables

View Source
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.

func Convert

func Convert(data []byte, opts Options) (*Result, error)

Convert maps Kubernetes manifests to stack documents plus a report.

func (*Result) Blockers

func (r *Result) Blockers() int

Blockers counts blocker findings.

func (*Result) Secrets

func (r *Result) Secrets() map[string]string

Secrets returns "app/NAME" to value for the apply step. Callers must never print or log it.

type Severity

type Severity string

Severity ranks how much an unmapped field matters.

const (
	SeverityIgnoredSafe     Severity = "ignored-safe"
	SeverityChangesBehavior Severity = "changes-behavior"
	SeverityBlocker         Severity = "blocker"
)

Finding severities. A blocker stops a non-dry-run import unless forced.

Jump to

Keyboard shortcuts

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