client

package
v8.85.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package client is what the repo commands that call giantswarm-repo-manager share: the muster token from the keychain, the manager client over the person's muster endpoint, the output flag, and the text renderers of the answers the verbs have in common. Each verb is one tool of the manager; `-o json` prints the tool's answer as it came.

Index

Constants

View Source
const (
	OutputText = "text"
	OutputJSON = "json"
)

The output formats.

Variables

View Source
var InvalidFlagError = &microerror.Error{
	Kind: "invalidFlagError",
}

InvalidFlagError is a flag or argument the command cannot use.

View Source
var UnexpectedAnswerError = &microerror.Error{
	Kind: "unexpectedAnswerError",
}

UnexpectedAnswerError is an answer of the manager devctl cannot read.

Functions

func Decode

func Decode[T any](tool string, payload json.RawMessage) (*T, error)

Decode reads a tool's answer into the manager's type.

func Indent

func Indent(s, prefix string) string

Indent prefixes every line of s.

func IsInvalidFlag

func IsInvalidFlag(err error) bool

IsInvalidFlag asserts InvalidFlagError.

func IsUnexpectedAnswer

func IsUnexpectedAnswer(err error) bool

IsUnexpectedAnswer asserts UnexpectedAnswerError.

func PrintCommitted

func PrintCommitted(w io.Writer, c *manager.Committed)

PrintCommitted writes a write's outcome in mode commit.

func PrintFindings

func PrintFindings(w io.Writer, findings []manager.Finding)

PrintFindings writes the record's findings with their fix and source.

func PrintJSON

func PrintJSON(w io.Writer, payload json.RawMessage) error

PrintJSON writes the answer as it came, indented.

func PrintPendingRun

func PrintPendingRun(w io.Writer, p *manager.PendingRun)

PrintPendingRun writes the reconciler run a record expects.

func PrintPlan

func PrintPlan(w io.Writer, plan *manager.Plan)

PrintPlan writes a write's dry run.

func PrintRecord

func PrintRecord(w io.Writer, r *manager.Record)

PrintRecord writes an inventory record: the declaration, the reality on GitHub, CircleCI, the CI configuration, Renovate, the catalog and the mapping, the set-up state with its steps and runs, and the findings.

func PrintSteps

func PrintSteps(w io.Writer, res *reconcile.Result)

PrintSteps writes the engine's steps the way `repo status` does: step, verdict, summary, then the changes a repair would make and the findings with their fix.

func Repository

func Repository(arg string) (string, error)

Repository checks the [OWNER/]NAME argument; the manager takes the name with or without the organisation.

func Verdict

func Verdict(res *reconcile.Result) string

Verdict is the one line that closes a set-up state.

func WriteArgs

func WriteArgs(args map[string]any, dryRun bool) map[string]any

WriteArgs completes a write's arguments: dryRun: true, or mode: commit.

Types

type Flags

type Flags struct {
	Output string
}

Flags are the flags every manager-backed verb takes.

func (*Flags) Init

func (f *Flags) Init(cmd *cobra.Command)

Init registers -o/--output.

func (*Flags) JSON

func (f *Flags) JSON() bool

JSON says whether the answer is printed as it came.

func (*Flags) Validate

func (f *Flags) Validate() error

Validate checks the output format.

type Opener

type Opener func(ctx context.Context) (*Session, error)

Opener opens a Session; the commands use Open, tests a fake.

type Session

type Session struct {
	Caller   manager.Caller
	Endpoint string
	// Login is the account the muster token acts as, as the sign-in read it.
	Login string
}

Session is the manager reached as the person: the muster token of the keychain on every call.

func Open

func Open(ctx context.Context) (*Session, error)

Open reads the muster token from the keychain, refreshed when it expired, and returns the session; without a usable token it is the auth store's error naming `devctl auth login --muster-only`.

func (*Session) Call

func (s *Session) Call(ctx context.Context, tool string, args map[string]any) (json.RawMessage, error)

Call calls one tool of the manager and returns its answer; a bearer muster refuses is the auth store's error, so the person is sent to the login.

Jump to

Keyboard shortcuts

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