Documentation
¶
Index ¶
- Constants
- func AddJSONOutputFlag(cmd *cobra.Command)
- func ConvertJWKToPEM(jwkJSON string) ([]byte, error)
- func ConvertPEMToJWK(pemData string) (string, error)
- func CopyDir(src, dst string) error
- func CopyFile(src, dst string) error
- func FirstOrDash(items ...string) string
- func FormatBytes(bytes int64) string
- func FormatLocal(t time.Time) string
- func GetBaseURL() string
- func GetKernelClient(cmd *cobra.Command) kernel.Client
- func IsNotFound(err error) bool
- func IsPEMKey(data string) bool
- func JoinOrDash(items ...string) string
- func ModifyFile(path, oldStr, newStr string) error
- func NewClient(opts ...option.RequestOption) kernel.Client
- func OrDash(s string) string
- func PrintCompactJSONLine(v RawJSONProvider) error
- func PrintPrettyJSON(v RawJSONProvider) error
- func PrintPrettyJSONSlice[T RawJSONProvider](items []T) error
- func Unzip(zipFilePath, destDir string) error
- func ValidateJSONOutput(output string) error
- func ValidatePEMKey(pemData string) error
- func ZipDirectory(srcDir, destZip string, opts *ZipOptions) error
- type CleanedUpSdkError
- type ContextKey
- type RawJSONProvider
- type ZipOptions
Constants ¶
const DefaultTimeLayout = "2006-01-02 15:04:05 MST"
DefaultTimeLayout is the standard layout used for displaying timestamps. Includes the local timezone abbreviation to make it clear times are local.
const JSONOutputFlagDescription = "Output format: json for raw API response"
Variables ¶
This section is empty.
Functions ¶
func AddJSONOutputFlag ¶ added in v0.19.3
func ConvertJWKToPEM ¶ added in v0.13.4
ConvertJWKToPEM converts an Ed25519 JWK to PEM format
func ConvertPEMToJWK ¶ added in v0.13.4
ConvertPEMToJWK converts an Ed25519 PEM private key to JWK format
func FirstOrDash ¶
FirstOrDash returns the first non-empty string from the provided items. If all items are empty, it returns "-".
func FormatBytes ¶ added in v0.14.8
FormatBytes formats bytes in a human-readable format
func FormatLocal ¶
FormatLocal formats the provided time in the user's local timezone. If the time is zero, it returns "-".
func GetBaseURL ¶ added in v0.15.3
func GetBaseURL() string
GetBaseURL returns the Kernel API base URL, falling back to production. KERNEL_BASE_URL is never set in .env; it exists solely for internal dev/staging overrides.
func GetKernelClient ¶
GetKernelClient retrieves the kernel client from the command context
func IsNotFound ¶
IsNotFound returns true if the error is a Kernel API error with HTTP 404.
func JoinOrDash ¶
JoinOrDash joins the provided strings with ", " as separator. If no items are provided, it returns "-".
func ModifyFile ¶ added in v0.13.4
ModifyFile replaces all occurrences of oldStr with newStr in the file. Returns an error if the pattern is not found in the file
func NewClient ¶
func NewClient(opts ...option.RequestOption) kernel.Client
NewClient returns a kernel API client preconfigured with middleware that detects when a newer CLI/SDK version is required and informs the user.
It mirrors kernel.NewClient but injects an HTTP middleware that intercepts 400 responses with error codes "sdk_upgrade_required" or "sdk_update_required". When encountered, a helpful upgrade message is displayed once per process.
func PrintCompactJSONLine ¶ added in v0.19.3
func PrintCompactJSONLine(v RawJSONProvider) error
PrintCompactJSONLine prints v as a single compact JSON line followed by a newline. Use inside SSE loops where downstream tooling (jq -c, log shippers) expects newline-delimited JSON.
func PrintPrettyJSON ¶ added in v0.13.4
func PrintPrettyJSON(v RawJSONProvider) error
PrintPrettyJSON prints the raw JSON from an SDK response type with indentation. It uses the RawJSON() method to get the original API response, avoiding zero-value fields that would appear when re-marshaling the Go struct.
func PrintPrettyJSONSlice ¶ added in v0.13.4
func PrintPrettyJSONSlice[T RawJSONProvider](items []T) error
PrintPrettyJSONSlice prints a slice of SDK response types as a JSON array. Each element must implement RawJSONProvider.
func ValidateJSONOutput ¶ added in v0.19.3
func ValidatePEMKey ¶ added in v0.13.4
ValidatePEMKey validates that a PEM-encoded string contains a valid Ed25519 private key
func ZipDirectory ¶
func ZipDirectory(srcDir, destZip string, opts *ZipOptions) error
ZipDirectory compresses the given source directory into the destination file path.
Types ¶
type CleanedUpSdkError ¶
type CleanedUpSdkError struct {
Err error
}
CleanedUpSdkError extracts a message field from the raw JSON resposne. This is the convention we use in the API for error response bodies (400s and 500s)
func (CleanedUpSdkError) Error ¶
func (e CleanedUpSdkError) Error() string
func (CleanedUpSdkError) Unwrap ¶
func (e CleanedUpSdkError) Unwrap() error
type ContextKey ¶
type ContextKey string
ContextKey is the type for context keys
const KernelClientKey ContextKey = "kernel_client"
KernelClientKey is the context key for the kernel client
type RawJSONProvider ¶ added in v0.13.4
type RawJSONProvider interface {
RawJSON() string
}
RawJSONProvider is an interface for SDK types that provide raw JSON responses.
type ZipOptions ¶ added in v0.14.8
type ZipOptions struct {
// ExcludeDirectories: exact directory names to exclude (case-sensitive)
ExcludeDirectories []string
// ExcludeFilenamePatterns: glob patterns for filename exclusion (e.g., "*.test.js")
ExcludeFilenamePatterns []string
}
ZipOptions which directories and files to exclude from the zip