Documentation
¶
Overview ¶
Package sdk provides helper APIs for Go-based kongctl extensions.
Index ¶
- Constants
- type DispatchSessionContext
- type HostContext
- type InvocationContext
- type JQContext
- type MatchedCommandPath
- type Output
- type OutputContext
- type ResolvedContext
- type RuntimeContext
- func (r *RuntimeContext) Args() []string
- func (r *RuntimeContext) DataDir() string
- func (r *RuntimeContext) KongctlCommand(ctx context.Context, args ...string) *exec.Cmd
- func (r *RuntimeContext) KongctlPath() string
- func (r *RuntimeContext) KonnectSDK(ctx context.Context) (*konnectsdk.SDK, error)
- func (r *RuntimeContext) OriginalArgs() []string
- func (r *RuntimeContext) Output() Output
- func (r *RuntimeContext) RunKongctl(ctx context.Context, args ...string) error
Constants ¶
const ( // ContextEnvName is the environment variable that points to the extension // runtime context file written by the parent kongctl process. ContextEnvName = "KONGCTL_EXTENSION_CONTEXT" // KonnectPATEnvName carries a transient parent PAT for child extension // processes. The runtime context file itself never stores secrets. KonnectPATEnvName = "KONGCTL_EXTENSION_KONNECT_PAT" // #nosec G101 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DispatchSessionContext ¶
type HostContext ¶
type InvocationContext ¶
type MatchedCommandPath ¶
type Output ¶
type Output struct {
// contains filtered or unexported fields
}
Output renders extension output using the parent kongctl output settings.
type OutputContext ¶
type ResolvedContext ¶
type ResolvedContext struct {
Profile string `json:"profile"`
BaseURL string `json:"base_url"`
Output string `json:"output"`
LogLevel string `json:"log_level"`
ColorTheme string `json:"color_theme,omitempty"`
ConfigFile string `json:"config_file"`
ExtensionDataDir string `json:"extension_data_dir"`
AuthMode string `json:"auth_mode"`
AuthSource string `json:"auth_source"`
}
type RuntimeContext ¶
type RuntimeContext struct {
SchemaVersion int `json:"schema_version"`
MatchedCommandPath MatchedCommandPath `json:"matched_command_path"`
Invocation InvocationContext `json:"invocation"`
Resolved ResolvedContext `json:"resolved"`
OutputSettings OutputContext `json:"output"`
Host HostContext `json:"host"`
Session DispatchSessionContext `json:"session"`
}
RuntimeContext is the extension runtime context provided by the parent kongctl process.
func LoadRuntimeContextFile ¶
func LoadRuntimeContextFile(path string) (*RuntimeContext, error)
LoadRuntimeContextFile reads a kongctl extension runtime context file.
func LoadRuntimeContextFromEnv ¶
func LoadRuntimeContextFromEnv() (*RuntimeContext, error)
LoadRuntimeContextFromEnv reads the runtime context file referenced by KONGCTL_EXTENSION_CONTEXT.
func (*RuntimeContext) Args ¶
func (r *RuntimeContext) Args() []string
Args returns the arguments passed through to the extension executable after host-owned flags have been consumed.
func (*RuntimeContext) DataDir ¶
func (r *RuntimeContext) DataDir() string
DataDir returns the stable extension-owned data directory.
func (*RuntimeContext) KongctlCommand ¶
KongctlCommand creates a session-aware child kongctl command.
func (*RuntimeContext) KongctlPath ¶
func (r *RuntimeContext) KongctlPath() string
KongctlPath returns the parent kongctl executable path, falling back to "kongctl" when the runtime context did not provide one.
func (*RuntimeContext) KonnectSDK ¶
func (r *RuntimeContext) KonnectSDK(ctx context.Context) (*konnectsdk.SDK, error)
KonnectSDK returns an authenticated sdk-konnect-go client configured from the parent kongctl invocation context.
func (*RuntimeContext) OriginalArgs ¶
func (r *RuntimeContext) OriginalArgs() []string
OriginalArgs returns the original matched kongctl command path and arguments.
func (*RuntimeContext) Output ¶
func (r *RuntimeContext) Output() Output
Output returns a renderer configured from the runtime context.
func (*RuntimeContext) RunKongctl ¶
func (r *RuntimeContext) RunKongctl(ctx context.Context, args ...string) error
RunKongctl runs a session-aware child kongctl command.