cli

package
v4.17.11 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 98 Imported by: 1

Documentation

Overview

DigitalRebar Provision CLI provides the core parts of the CLI. This CLI uses an access core based upon a set of generated files from the generated swagger.json file.

cli/exports.go

Copyright © 2020 RackN <support@rackn.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	AgentConfigFileName = "agent-cfg.yml"
	AgentConfigFileMode = 0600
)

Variables

View Source
var (
	// ActuallyPowerThings is a boolean to use in testing to keep from power off the test machine
	ActuallyPowerThings = true
	// DefaultStateLoc is the default location to save agent state
	DefaultStateLoc string
	AgentName       = "drp-agent"
)

AllKinds is the canonical list of reference kinds. Add new kinds here and they’ll automatically be picked up everywhere.

View Source
var AllowedCallsFields = map[string]info{

	"Param":              {/* contains filtered or unexported fields */},
	"ParamExists":        {/* contains filtered or unexported fields */},
	"ParamExpand":        {/* contains filtered or unexported fields */},
	"ParamAsJSON":        {/* contains filtered or unexported fields */},
	"ParamAsYAML":        {/* contains filtered or unexported fields */},
	"ParamCompose":       {/* contains filtered or unexported fields */},
	"ParamComposeExpand": {/* contains filtered or unexported fields */},
	"ComposeParam":       {/* contains filtered or unexported fields */},
	"ExpandParam":        {/* contains filtered or unexported fields */},

	"CallTemplate": {/* contains filtered or unexported fields */},

	"CurrentJob":                   {/* contains filtered or unexported fields */},
	"GenerateInfiniteToken":        {/* contains filtered or unexported fields */},
	"GenerateCreateOrMachineToken": {/* contains filtered or unexported fields */},
	"GenerateInfiniteMachineToken": {/* contains filtered or unexported fields */},
	"GenerateJobToken":             {/* contains filtered or unexported fields */},
	"GenerateToken":                {/* contains filtered or unexported fields */},
	"GenerateCreateToken":          {/* contains filtered or unexported fields */},
	"GenerateMachineToken":         {/* contains filtered or unexported fields */},
	"GenerateUserToken":            {/* contains filtered or unexported fields */},
	"GenerateProfileToken":         {/* contains filtered or unexported fields */},
	"BootParams":                   {/* contains filtered or unexported fields */},
	"ProvisionerAddress":           {/* contains filtered or unexported fields */},
	"ProvisionerPort":              {/* contains filtered or unexported fields */},
	"ProvisionerURL":               {/* contains filtered or unexported fields */},
	"ProvisionerHostURL":           {/* contains filtered or unexported fields */},
	"SecureProvisionerPort":        {/* contains filtered or unexported fields */},
	"SecureProvisionerURL":         {/* contains filtered or unexported fields */},
	"SecureProvisionerHostURL":     {/* contains filtered or unexported fields */},
	"BootParamsFor":                {/* contains filtered or unexported fields */},
	"ApiURL":                       {/* contains filtered or unexported fields */},
	"ApiHostURL":                   {/* contains filtered or unexported fields */},
	"MachineRepos":                 {/* contains filtered or unexported fields */},
	"InstallRepos":                 {/* contains filtered or unexported fields */},
	"Tasks":                        {/* contains filtered or unexported fields */},
	"CurrentTask":                  {/* contains filtered or unexported fields */},
	"NetmaskToCIDR":                {/* contains filtered or unexported fields */},
	"ParseUrl":                     {/* contains filtered or unexported fields */},

	"Machine": {
		// contains filtered or unexported fields
	},

	"Env": {
		// contains filtered or unexported fields
	},

	"WorkOrder": {
		// contains filtered or unexported fields
	},

	"ObjectExpand": {/* contains filtered or unexported fields */},
	"StringExpand": {/* contains filtered or unexported fields */},

	"ServerPathInfo": {
		// contains filtered or unexported fields
	},

	"Info": {
		// contains filtered or unexported fields
	},
}
View Source
var McpListFunc func(out io.Writer, app *cobra.Command, readOnly bool, docs McpDocsConfig) error

McpListFunc is called by `drpcli mcp list`. Same indirection rationale as McpServeFunc — set from cmds/drpcli to avoid the import cycle.

View Source
var McpServeFunc func(app *cobra.Command, readOnly bool, outputFormat string, docs McpDocsConfig, transports McpTransportConfig, limits McpLimitsConfig) error

McpServeFunc is called by `drpcli mcp serve`. It must be set before cli.NewApp() is called. The canonical setter is in cmds/drpcli which imports gitlab.com/rackn/provision/v4/cli/mcp; cli/mcp.go avoids that direct import to break the cli ↔ cli/mcp import cycle.

If nil, `drpcli mcp serve` returns an error at runtime.

View Source
var (

	// Session is the global client access session
	Session *api.Client
)

Functions

func AddDirToZip

func AddDirToZip(zipWriter *zip.Writer, dirname string) error

given a top level dir this will walk it adding files and folders. to the archive

func AddFileToZip

func AddFileToZip(zipWriter *zip.Writer, filename string) error

adds an individual file to the archive

func ComponentsFromGohai added in v4.17.6

func ComponentsFromGohai(buf []byte) ([]models.Component, error)

ComponentsFromGohai converts a gohai payload into normalized Components.

func Format added in v4.17.0

func Format() string

Format returns the current output format ("json", "yaml", "text", "table").

func IsGohaiPayload added in v4.17.6

func IsGohaiPayload(buf []byte) bool

IsGohaiPayload reports whether buf looks like the output of gohai rather than a ComponentSet or a bare Devices array.

func NewApp

func NewApp() *cobra.Command

NewApp is the app start function

func NewBasicKeyRequest

func NewBasicKeyRequest() *basicKeyReq

NewBasicKeyRequest returns a default BasicKeyRequest.

func NoColor added in v4.17.0

func NoColor() bool

NoColor returns whether colorized output is disabled.

func NoHeader added in v4.17.0

func NoHeader() bool

NoHeader returns whether table headers are suppressed.

func ObjectErrorsAreFatal added in v4.17.0

func ObjectErrorsAreFatal() bool

ObjectErrorsAreFatal returns whether commands exit non-zero when a returned object has Errors set.

func PatchWithFunction

func PatchWithFunction(key string, op *ops, fn func(models.Model) (models.Model, bool)) error

The input function takes the object and returns the modified object and if the object changed.

func PatchWithString

func PatchWithString(key, js string, op *ops) error

func ResetDefaults

func ResetDefaults()

func SessionForToken added in v4.17.3

func SessionForToken(token string) (*api.Client, error)

SessionForToken builds a DRP client authenticated with the supplied bearer token, against the endpoint and TLS settings this drpcli invocation was configured with.

cli/mcp needs this to give each MCP request its own credential, and the inputs -- endpoint, caCert, serverVerify, ignoreUnixProxy -- are unexported package state here. Exposing one constructor keeps that knowledge in cli rather than duplicating the flag semantics in another package.

Note this does NOT validate the token: api.TokenSessionProxyServer stores it and returns without a round trip, so an invalid token fails on first use.

func SetFormat added in v4.17.0

func SetFormat(s string)

SetFormat overrides the output format. Used by the MCP server to force JSON.

func SetNoColor added in v4.17.0

func SetNoColor(b bool)

SetNoColor overrides the no-color setting. Used by the MCP server.

func SetNoHeader added in v4.17.0

func SetNoHeader(b bool)

SetNoHeader overrides the no-header setting. Used by the MCP server.

func SetObjectErrorsAreFatal added in v4.17.0

func SetObjectErrorsAreFatal(b bool)

SetObjectErrorsAreFatal overrides the exit-early setting. Used by the MCP server.

Types

type DocData

type DocData struct {
	Name          string
	Prefix        string
	RefName       string
	RefPrefix     string
	DisplayName   string
	Full          string
	Version       string
	Documentation string
	Description   string
	Content       string
	RefString     string
	Objects       [][]models.Model
}

func (*DocData) LengthString

func (dd *DocData) LengthString(str, pat string) string

func (*DocData) PrefixToTag added in v4.12.0

func (dd *DocData) PrefixToTag() string

type Item added in v4.15.0

type Item struct {
	Name         string
	Version      string
	CatalogEntry *models.CatalogItem
}

type LabDocData added in v4.10.0

type LabDocData struct {
	Lab        *models.Lab
	LabSection *models.LabSection
	Depth      int
	InTab      bool
	VideoTag   string
	VideoTime  string
}

func (*LabDocData) Encapsulate added in v4.10.0

func (dd *LabDocData) Encapsulate(str, first, pat string) string

func (*LabDocData) GenerateLabMd added in v4.13.0

func (dd *LabDocData) GenerateLabMd() string

func (*LabDocData) GenerateSectionMarkdown added in v4.13.0

func (dd *LabDocData) GenerateSectionMarkdown(section *models.LabSection, depth int, inTab bool) string

func (*LabDocData) LengthString added in v4.10.0

func (dd *LabDocData) LengthString(str, pat string) string

func (*LabDocData) MarkdownToRst added in v4.10.0

func (dd *LabDocData) MarkdownToRst(data string) string

func (*LabDocData) RenderSection added in v4.10.0

func (dd *LabDocData) RenderSection(tmplFile string, ls *models.LabSection, depth int, tab string) string

func (*LabDocData) StringCleanup added in v4.13.0

func (dd *LabDocData) StringCleanup(str string) string

StringCleanup removes new lines and replaces them with a single space. Also doesn't change it if it contains a table.

func (*LabDocData) ToRef added in v4.10.0

func (dd *LabDocData) ToRef(names ...string) string

type McpDocsConfig added in v4.17.0

type McpDocsConfig struct {
	Disabled bool   // --no-docs
	Version  string // --docs-version
	LocalZip string // --local-docs
	BaseURL  string // --docs-url
}

McpDocsConfig carries the `drpcli mcp serve` documentation-source flags through to the mcp package (which cli/mcp.go must not import directly, to avoid the cli ↔ cli/mcp import cycle). cmds/drpcli maps it to mcp.DocsConfig.

type McpLimitsConfig added in v4.17.9

type McpLimitsConfig struct {
	MaxToolBytes int // --max-tool-bytes
}

McpLimitsConfig carries the `drpcli mcp serve` result-size limits.

type McpTransportConfig added in v4.17.3

type McpTransportConfig struct {
	Unix     string // --unix
	UnixMode string // --unix-mode, octal, empty means 0600
	HTTPS    string // --https
	TLSCert  string // --tls-cert
	TLSKey   string // --tls-key
}

McpTransportConfig carries the `drpcli mcp serve` listener flags through to the mcp package. Same import-cycle rationale as McpDocsConfig: cli must not import cli/mcp, so cmds/drpcli maps this onto mcp.Options.

The zero value means stdio, which must stay byte-identical to the behaviour that shipped before the listeners existed.

type Output added in v4.16.0

type Output struct {
	Index    map[RefKind]map[string][]RefLoc `json:"index"`
	RevIndex map[RefKind]map[string][]RefLoc `json:"rev_index"`
	Summary  struct {
		Packs           int `json:"packs"`
		Objects         int `json:"objects"`
		TemplateRefs    int `json:"templateRefs"`
		ParamRefs       int `json:"paramRefs"`
		StageRefs       int `json:"stageRefs"`
		TaskRefs        int `json:"taskRefs"`
		BootenvRefs     int `json:"bootenvRefs"`
		ContextRefs     int `json:"contextRefs"`
		ProfileRefs     int `json:"profileRefs"`
		UniqueTemplates int `json:"uniqueTemplates"`
		UniqueParams    int `json:"uniqueParams"`
		UniqueProfiles  int `json:"uniqueProfiles"`
	} `json:"summary"`
}

Output aggregates a normalized reverse index and summary

type PackID added in v4.16.0

type PackID struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

PackID identifies a content pack

type RefKind added in v4.16.0

type RefKind string

Normalized kinds for a unified index

const (
	KindTemplate  RefKind = "templates"
	KindParam     RefKind = "params"
	KindStage     RefKind = "stages"
	KindTask      RefKind = "tasks"
	KindBootEnv   RefKind = "bootenvs"
	KindContext   RefKind = "contexts"
	KindProfile   RefKind = "profiles"
	KindWorkflow  RefKind = "workflows"
	KindBlueprint RefKind = "blueprints"
	KindTrigger   RefKind = "triggers"
)

type RefLoc added in v4.16.0

type RefLoc struct {
	Pack       PackID `json:"pack"`
	Section    string `json:"section"`
	ObjectName string `json:"objectName"`
	FieldPath  string `json:"fieldPath"`
	Via        string `json:"via"`
	Value      any    `json:"value"`
}

RefLoc points to a specific field in an object

type Service added in v4.9.3

type Service struct {
	Service string
	Port    string
}

type Services added in v4.9.3

type Services struct {
	Services []Service
	Warnings []Warning
}

type Warning added in v4.9.3

type Warning struct {
	Service string
	Port    string
	Warn    string
}

Directories

Path Synopsis
cli/mcp/credential.go
cli/mcp/credential.go

Jump to

Keyboard shortcuts

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