Documentation
¶
Overview ¶
Package cli holds the kubepkg commands. A distribution builds its own CLI from NewRootCommand: its own name and API group, plus commands of its own.
Example (Distribution) ¶
A distribution's own CLI: its name and API group, and a command of its own next to the kubepkg ones.
package main
import (
"github.com/spf13/cobra"
"github.com/kuberoot-dev/kubepkg/pkg/cli"
)
func main() {
opts := cli.DefaultOptions()
opts.Name = "examplectl"
opts.APIGroup = "packages.example.com"
root := cli.NewRootCommand(opts)
root.AddCommand(&cobra.Command{
Use: "upgrade-platform",
Short: "Upgrade the whole platform to the next release",
RunE: func(*cobra.Command, []string) error { return nil },
})
_ = root.Execute()
}
Output:
Index ¶
- Constants
- Variables
- func Apply(ctx context.Context, c client.Client, steps []Step) error
- func NewRootCommand(o Options) *cobra.Command
- func Render(ctx context.Context, store *repo.Store, policy repo.Policy, ...) ([]byte, error)
- func WritePlan(w io.Writer, steps []Step) error
- type AdoptComponent
- type AdoptPlan
- type Options
- type ReleaseReader
- type Removal
- type RenderOptions
- type ScanResult
- type Scanner
- type Step
Examples ¶
Constants ¶
const AnnotationDependency = "kubepkg.dev/dependency"
AnnotationDependency marks a Package the CLI installed because another package required it, not because it was asked for.
Variables ¶
var RenderFormats = []string{"flux", "argo", "helmfile"}
RenderFormats are the formats Render writes.
Functions ¶
func Apply ¶
Apply creates or updates the Packages of a plan. Kept packages are left alone; the operator does the installing.
func NewRootCommand ¶
NewRootCommand returns the root command with every kubepkg command.
func Render ¶
func Render(ctx context.Context, store *repo.Store, policy repo.Policy, reqs []resolve.Request, o RenderOptions) ([]byte, error)
Render resolves the requested packages and their requirements for an empty cluster and writes what another delivery tool needs to install them, in the order kubepkg would: Flux sources and HelmReleases with dependsOn, Argo CD Applications with sync waves, or a helmfile with needs. Requirements on APIs no package provides are assumed served.
Types ¶
type AdoptComponent ¶
type AdoptComponent struct {
Name, Namespace, Release string
// Overridden is true when the release is not where the package would
// put it, so the Package must say where it is.
Overridden bool
Existing *helm.ReleaseInfo
}
AdoptComponent is what adopting finds for one component.
type AdoptPlan ¶
type AdoptPlan struct {
Package string
Repository string
Version repo.Version
Variant string
Components []AdoptComponent
// Missing are required packages the cluster does not have.
Missing []string
}
AdoptPlan is what adopting a package would do.
func PlanAdopt ¶
func PlanAdopt(ctx context.Context, store *repo.Store, policy repo.Policy, releases ReleaseReader, installed map[string]bool, name, constraint, variant string, placements map[string]string) (*AdoptPlan, error)
PlanAdopt finds the release each component of the package's chosen version would be, existing or not. placements maps component names to namespace/release where the release is not where the package puts it.
func (*AdoptPlan) PackageObject ¶
Package is the Package that adopts, carrying each release's values.
type Options ¶
type Options struct {
// Name is the binary name shown in help.
Name string
// Short is the one-line description.
Short string
// APIGroup is the default of --api-group.
APIGroup string
// IndexFetchers fetch repository indexes by URL scheme, as in the
// operator; a distribution adds its transports.
IndexFetchers repo.Fetchers
// Policy admits versions, as in the operator, so plans offer only
// what the operator will install.
Policy repo.Policy
}
Options configure the root command.
type ReleaseReader ¶
type ReleaseReader interface {
Release(namespace, name string) (*helm.ReleaseInfo, error)
}
ReleaseReader reads existing Helm releases.
type Removal ¶
Removal is one package a remove deletes, and why.
func PlanRemove ¶
func PlanRemove(ctx context.Context, c client.Client, names []string, autoremove bool) ([]Removal, error)
PlanRemove works out what removing names takes. It refuses while a package that stays requires one of them, directly or as the only provider of a capability. With autoremove it also removes packages that were installed as requirements and that nothing staying needs any more.
type RenderOptions ¶
type RenderOptions struct {
Format string
Variant string
// ArgoNamespace and ArgoProject place Applications (argo format).
ArgoNamespace, ArgoProject string
// Insecure lets Flux pull from registries over plain HTTP.
Insecure bool
}
RenderOptions tune the output of Render.
type ScanResult ¶
ScanResult is one image of one package.
type Scanner ¶
Scanner reports the vulnerabilities of an image by severity.
func TrivyScanner ¶
TrivyScanner runs trivy image on each image.
type Step ¶
type Step struct {
resolve.Change
// Repository and Entry are where the target version comes from.
Repository string
Entry repo.Version
// Constraint is what Package.spec.version is set to.
Constraint string
Dependency bool
// Local means a hand-written PackageSource decides, not repositories.
Local bool
}
Step is one line of an install plan.
func Plan ¶
func Plan(ctx context.Context, c client.Client, store *repo.Store, policy repo.Policy, apis controller.APIs, variant string, reqs []resolve.Request) ([]Step, error)
Plan works out what installing reqs takes: the requested packages and everything they require, from the cluster's repositories, as the operator would select them.