Documentation
¶
Index ¶
- Variables
- func AssertCommandError(t *testing.T, cmd *cobra.Command, args []string, expectedErr string)
- func AssertCommandOutput(t *testing.T, cmd *cobra.Command, args []string, expected ...string)
- func CaptureOutput(t *testing.T, fn func()) string
- func ConfirmDeployment(preview *DeploymentPreview, forceYes bool) (bool, error)
- func CreateTestComponent(t *testing.T, dir, name, language string)
- func CreateTestProject(t *testing.T, format string) string
- func Debug(format string, args ...interface{})
- func Error(format string, args ...interface{})
- func Execute() error
- func ExecuteCommandTest(t *testing.T, test TestCommandExecution)
- func Fatal(format string, args ...interface{})
- func Info(format string, args ...interface{})
- func IsVerbose() bool
- func MockExecCommandHelper(command string, args ...string) *exec.Cmd
- func MockSurveyAsk(responses map[string]interface{}) func(qs []*survey.Question, response interface{}, opts ...survey.AskOpt) error
- func MockSurveyAskOne(response interface{}) func(p survey.Prompt, response interface{}, opts ...survey.AskOpt) error
- func PrintStep(step int, total int, message string)
- func SetVersion(v, c, b string)
- func SetupTestEnvironment(t *testing.T, config TestConfig) string
- func ShowDeploymentPreview(preview *DeploymentPreview)
- func Success(format string, args ...interface{})
- func Warn(format string, args ...interface{})
- type AddComponentOptions
- type AddOptions
- type ComponentPreview
- type DataWriter
- type DeployOptions
- type DeploymentChanges
- type DeploymentPreview
- type InitOptions
- type KeyValueBuilder
- type LogsOptions
- type MockCommandExecutor
- type MockExecCommand
- type OutputFormat
- type TableBuilder
- type TestCommandExecution
- type TestComponent
- type TestConfig
- type VariableChange
Constants ¶
This section is empty.
Variables ¶
var ExecCommand = exec.Command
ExecCommand is a variable that can be mocked in tests
Functions ¶
func AssertCommandError ¶
AssertCommandError checks that command fails with expected error
func AssertCommandOutput ¶
AssertCommandOutput checks that command output contains expected strings
func CaptureOutput ¶
CaptureOutput captures stdout/stderr during function execution
func ConfirmDeployment ¶
func ConfirmDeployment(preview *DeploymentPreview, forceYes bool) (bool, error)
ConfirmDeployment prompts for deployment confirmation with preview
func CreateTestComponent ¶
CreateTestComponent creates a test component directory structure
func CreateTestProject ¶
CreateTestProject creates a temporary test project structure
func Debug ¶
func Debug(format string, args ...interface{})
Debug prints a debug message if verbose mode is enabled
func ExecuteCommandTest ¶
func ExecuteCommandTest(t *testing.T, test TestCommandExecution)
ExecuteCommandTest runs a command test with proper setup/teardown
func MockExecCommandHelper ¶
MockExecCommandHelper is used to create fake commands for testing
func MockSurveyAsk ¶
func MockSurveyAsk(responses map[string]interface{}) func(qs []*survey.Question, response interface{}, opts ...survey.AskOpt) error
MockSurveyAsk mocks survey.Ask for testing multiple prompts
func MockSurveyAskOne ¶
func MockSurveyAskOne(response interface{}) func(p survey.Prompt, response interface{}, opts ...survey.AskOpt) error
MockSurveyAskOne mocks survey.AskOne for testing interactive prompts
func SetupTestEnvironment ¶
func SetupTestEnvironment(t *testing.T, config TestConfig) string
SetupTestEnvironment creates a complete test environment
func ShowDeploymentPreview ¶
func ShowDeploymentPreview(preview *DeploymentPreview)
ShowDeploymentPreview displays a comprehensive deployment preview
Types ¶
type AddComponentOptions ¶
type AddComponentOptions struct {
Name string
Source string
Registry string
Description string
Template string
Build string
}
AddComponentOptions holds options for adding a component
type AddOptions ¶
AddOptions holds options for the add command
type ComponentPreview ¶
type ComponentPreview struct {
Name string
Type string
Source string
Size string
IsLocal bool
Registry string
Version string
}
ComponentPreview represents a component in the preview
type DataWriter ¶
type DataWriter struct {
// contains filtered or unexported fields
}
DataWriter handles formatted output of structured data
func NewDataWriter ¶
func NewDataWriter(output io.Writer, format string) *DataWriter
NewDataWriter creates a new DataWriter
func (*DataWriter) WriteKeyValue ¶
func (dw *DataWriter) WriteKeyValue(title string, data map[string]interface{}) error
WriteKeyValue writes key-value pairs in the specified format
func (*DataWriter) WriteStruct ¶
func (dw *DataWriter) WriteStruct(data interface{}) error
WriteStruct writes a struct in the specified format
func (*DataWriter) WriteTable ¶
func (dw *DataWriter) WriteTable(headers []string, rows [][]string) error
WriteTable writes tabular data with headers
type DeployOptions ¶
type DeployOptions struct {
Environment string
ConfigFile string
DryRun bool
Yes bool
AccessControl string
JWTIssuer string
JWTAudience string
AllowedRoles []string
Variables map[string]string
OrgID string // Explicitly specify organization ID
}
DeployOptions holds options for the deploy command
type DeploymentChanges ¶
type DeploymentChanges struct {
AccessModeChanged bool
OldAccessMode string
NewAccessMode string
ComponentsAdded []string
ComponentsRemoved []string
ComponentsUpdated []string
VariablesChanged map[string]VariableChange
EnvironmentChanged bool
OldEnvironment string
NewEnvironment string
}
DeploymentChanges tracks what's changing in an update
type DeploymentPreview ¶
type DeploymentPreview struct {
IsUpdate bool
AppName string
AppID string
AccessMode string
Environment string
Organization string
Components []ComponentPreview
Variables map[string]string
ExistingAppID string
ExistingAccess string
Changes *DeploymentChanges
}
DeploymentPreview represents the deployment preview information
func BuildDeploymentPreview ¶
func BuildDeploymentPreview( manifest *validation.Application, opts *DeployOptions, existingAppID string, existingAccess string, orgID string, ) *DeploymentPreview
BuildDeploymentPreview creates a preview from the manifest and context
func BuildDeploymentPreviewWithOrg ¶
func BuildDeploymentPreviewWithOrg( manifest *validation.Application, opts *DeployOptions, existingAppID string, existingAccess string, orgID string, orgName string, ) *DeploymentPreview
BuildDeploymentPreviewWithOrg creates a preview with full org information
type InitOptions ¶
type InitOptions struct {
Name string
Description string
Template string
Language string // Configuration language: yaml, go, cue, json
NoInteractive bool
Force bool
}
InitOptions holds options for the init command
type KeyValueBuilder ¶
type KeyValueBuilder struct {
// contains filtered or unexported fields
}
KeyValueBuilder helps build key-value data
func NewKeyValueBuilder ¶
func NewKeyValueBuilder(title string) *KeyValueBuilder
NewKeyValueBuilder creates a new KeyValueBuilder
func (*KeyValueBuilder) Add ¶
func (kvb *KeyValueBuilder) Add(key string, value interface{}) *KeyValueBuilder
Add adds a key-value pair
func (*KeyValueBuilder) AddIf ¶
func (kvb *KeyValueBuilder) AddIf(condition bool, key string, value interface{}) *KeyValueBuilder
AddIf conditionally adds a key-value pair
func (*KeyValueBuilder) Write ¶
func (kvb *KeyValueBuilder) Write(dw *DataWriter) error
Write outputs the key-value data using the DataWriter
type LogsOptions ¶
type LogsOptions struct {
// AppID can be either a UUID or an application name.
// When a name is provided, it will be resolved to a UUID.
AppID string
// Since specifies the time range for logs.
// Supported formats:
// - Relative: "30m", "1h", "7d"
// - RFC3339: "2024-01-15T10:00:00Z"
// - Unix timestamp: "1705315200"
Since string
// Tail limits the number of log lines returned.
// Valid range: 1-1000, default: 100
Tail string
}
LogsOptions holds configuration for the logs command. All options are validated server-side to ensure consistency.
type MockCommandExecutor ¶
type MockCommandExecutor struct {
Commands map[string]*MockExecCommand
History []string
}
MockCommandExecutor manages mocked commands
func NewMockCommandExecutor ¶
func NewMockCommandExecutor() *MockCommandExecutor
NewMockCommandExecutor creates a new mock executor
func (*MockCommandExecutor) Execute ¶
func (m *MockCommandExecutor) Execute(name string, args ...string) ([]byte, error)
Execute simulates command execution
func (*MockCommandExecutor) GetHistory ¶
func (m *MockCommandExecutor) GetHistory() []string
GetHistory returns command execution history
func (*MockCommandExecutor) RegisterCommand ¶
func (m *MockCommandExecutor) RegisterCommand(cmd string, mock *MockExecCommand)
RegisterCommand registers a mock command
func (*MockCommandExecutor) ResetHistory ¶
func (m *MockCommandExecutor) ResetHistory()
ResetHistory clears the command history
type MockExecCommand ¶
type MockExecCommand struct {
Command string
Args []string
ReturnOutput string
ReturnError error
ReturnCode int
}
MockExecCommand represents a mocked external command
type OutputFormat ¶
type OutputFormat string
OutputFormat represents the output format type
const ( OutputFormatTable OutputFormat = "table" OutputFormatJSON OutputFormat = "json" )
type TableBuilder ¶
type TableBuilder struct {
// contains filtered or unexported fields
}
TableBuilder helps build table data incrementally
func NewTableBuilder ¶
func NewTableBuilder(headers ...string) *TableBuilder
NewTableBuilder creates a new TableBuilder
func (*TableBuilder) AddRow ¶
func (tb *TableBuilder) AddRow(values ...string) *TableBuilder
AddRow adds a row to the table
func (*TableBuilder) Write ¶
func (tb *TableBuilder) Write(dw *DataWriter) error
Write outputs the table using the DataWriter
type TestCommandExecution ¶
type TestCommandExecution struct {
Command *cobra.Command
Args []string
ExpectError bool
ExpectOutput []string
Setup func(t *testing.T) string
Cleanup func(string)
Validate func(t *testing.T, output string, err error)
}
TestCommandExecution helps test cobra command execution
type TestComponent ¶
type TestConfig ¶
type TestConfig struct {
WorkDir string
ConfigFormat string
Components []TestComponent
}
TestConfig holds test configuration for commands
type VariableChange ¶
VariableChange represents a variable modification