Documentation
¶
Overview ¶
Package cli holds the shared dependencies threaded through every command: the logger, the loaded config, and the global flag overrides. It is the single place commands go to obtain a ready-to-use OpenFGA client.
Index ¶
- type CLI
- func (cli *CLI) Client() (*openfga.Client, error)
- func (cli *CLI) ClientWithStore() (*openfga.Client, config.Resolved, error)
- func (*CLI) GroupRunE(cmd *cobra.Command, args []string) error
- func (cli *CLI) Resolve() (config.Resolved, error)
- func (cli *CLI) RetrySecretCleanup() (int, error)
- func (cli *CLI) SaveConfig() error
- func (cli *CLI) SaveConfigWithSecretCleanup(profile string, all bool, fields ...string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLI ¶
type CLI struct {
Logger *log.Logger
Config *config.Config
Overrides config.Overrides // populated from persistent flags before Execute
// Output is the -o/--output mode (json|yaml|plain|table); it is the
// primary form, with --json/--yaml/--plain kept as aliases that set the
// corresponding toggles directly.
Output string
// JSON toggles machine-readable output across commands.
JSON bool
// YAML toggles machine-readable YAML output across commands.
YAML bool
// Quiet suppresses incidental success/info output.
Quiet bool
// NoInput prevents prompts and the interactive TUI.
NoInput bool
// Plain renders unstyled, tab-separated tables.
Plain bool
// NoColor disables color regardless of terminal/theme.
NoColor bool
// ThemeName, when set via --theme, overrides the configured theme.
ThemeName string
// RequestTimeout bounds each HTTP exchange; zero disables the deadline.
RequestTimeout time.Duration
// Runtime secret files provide process-scoped credentials without exposing
// their contents in argv or environment variables.
APITokenFile string
ClientSecretFile string
PrivateKeyFile string
// Version is the build version, injected from main.
Version string
}
CLI is the dependency container shared across commands.
func (*CLI) ClientWithStore ¶
ClientWithStore returns a client and guarantees a store ID is configured, returning a friendly error otherwise. Most commands need a store.
func (*CLI) GroupRunE ¶
GroupRunE is the RunE for a command group (a command whose only job is to hold sub-commands). Without it, a group like `ofga stores` is not runnable, so cobra prints help and exits 0 even for a mistyped subcommand like `ofga stores delet` — a typo'd destructive command appears to succeed. As a RunE the group is reached with the stray token as args: no args prints help (the natural `ofga stores` behavior), a stray token is rejected with the same "unknown command … Did you mean" suggestion the root gives.
It is a method on *CLI purely so command constructors can reference it as `cli.GroupRunE` even though their parameter shadows the package name; it uses no receiver state.
func (*CLI) RetrySecretCleanup ¶
RetrySecretCleanup retries cleanup work durably recorded in the config.
func (*CLI) SaveConfig ¶
SaveConfig persists the config and logs the location at debug level.