Documentation
¶
Overview ¶
Package commands provides the command-line interface for the azd-app CLI.
Package commands provides the command-line interface for the azd-app CLI.
Package commands provides the command-line interface for the azd-app CLI.
Package commands provides the command-line interface for the azd-app CLI.
Package commands provides the command-line interface for the azd-app CLI.
Index ¶
- Constants
- Variables
- func NewAddCommand() *cobra.Command
- func NewDepsCommand() *cobra.Command
- func NewHealthCommand() *cobra.Command
- func NewInfoCommand() *cobra.Command
- func NewListenCommand() *cobra.Command
- func NewLogsCommand() *cobra.Command
- func NewMCPCommand() *cobra.Command
- func NewMetadataCommand(rootCmdProvider func() *cobra.Command) *cobra.Command
- func NewNotificationsCommand() *cobra.Command
- func NewReqsCommand() *cobra.Command
- func NewRestartCommand() *cobra.Command
- func NewRunCommand() *cobra.Command
- func NewStartCommand() *cobra.Command
- func NewStopCommand() *cobra.Command
- func NewTestCommand() *cobra.Command
- func NewVersionCommand(outputFormat *string) *cobra.Command
- func ResetDepsOptions()
- func SetCacheEnabled(enabled bool)
- type AddResult
- type AzureYaml
- type BulkServiceControlResult
- type CleanDependenciesError
- type CollectedLogs
- type DashboardClient
- type DependencyInstaller
- type DepsOptions
- func GetDepsOptions() *DepsOptionsdeprecated
- type DepsResult
- type DetectedRequirement
- type ExecutionContext
- type FixResult
- type GenerateConfig
- type GenerateResult
- type InstallResult
- type LogContext
- type LogEntryWithContext
- type LogManagerInterface
- type LogSource
- type Prerequisite
- type PrerequisiteChecker
- type ProjectInfo
- type ProjectServiceSummary
- type ReqResult
- type ReqsDockerConfig
- type ReqsResult
- type ReqsService
- type RequirementStatus
- type RequirementsResult
- type ResultFormatter
- type ServiceControlResult
- type ServiceController
- func (c *ServiceController) BulkRestart(ctx context.Context, serviceNames []string) *BulkServiceControlResult
- func (c *ServiceController) BulkStart(ctx context.Context, serviceNames []string) *BulkServiceControlResult
- func (c *ServiceController) BulkStop(ctx context.Context, serviceNames []string) *BulkServiceControlResult
- func (c *ServiceController) GetAllServices() []string
- func (c *ServiceController) GetRunningServices() []string
- func (c *ServiceController) GetStoppedServices() []string
- func (c *ServiceController) RestartService(ctx context.Context, serviceName string) *ServiceControlResult
- func (c *ServiceController) StartService(ctx context.Context, serviceName string) *ServiceControlResult
- func (c *ServiceController) StopService(ctx context.Context, serviceName string) *ServiceControlResult
- type ServiceDetails
- type ServiceInfo
- type TestOptions
- type ToolConfig
Constants ¶
const LogLevelAll service.LogLevel = -1
LogLevelAll is a sentinel value indicating no level filtering should be applied.
Variables ¶
var BuildTime = "unknown"
BuildTime is set at build time via -ldflags.
var Commit = "unknown"
Commit is set at build time via -ldflags.
var Version = "dev"
Version is set at build time via -ldflags.
var VersionInfo = coreversion.New("jongio.azd.app", "azd app")
VersionInfo provides the shared version information for this extension.
Functions ¶
func NewHealthCommand ¶
NewHealthCommand creates the health command.
func NewListenCommand ¶
NewListenCommand creates the listen command using the azdext SDK helper. It registers a local service target provider and post-provision event handler.
func NewMCPCommand ¶
NewMCPCommand creates the mcp command with subcommands.
func NewMetadataCommand ¶
NewMetadataCommand creates the metadata command using the azdext SDK helper. rootCmdProvider returns the root command for introspection.
func NewNotificationsCommand ¶
NewNotificationsCommand creates the notifications command.
func NewRestartCommand ¶
NewRestartCommand creates the restart command.
func NewStartCommand ¶
NewStartCommand creates the start command.
func NewVersionCommand ¶
NewVersionCommand creates the version command.
func ResetDepsOptions ¶
func ResetDepsOptions()
ResetDepsOptions resets the global options to defaults. This is primarily used for testing to ensure clean state.
func SetCacheEnabled ¶
func SetCacheEnabled(enabled bool)
SetCacheEnabled configures whether caching should be enabled.
Types ¶
type AddResult ¶
type AddResult struct {
Service string `json:"service"`
Added bool `json:"added"`
Message string `json:"message,omitempty"`
ConnectionStrings map[string]string `json:"connectionStrings,omitempty"`
}
AddResult represents the result of adding a service.
type AzureYaml ¶
type AzureYaml struct {
Reqs []Prerequisite `yaml:"reqs"`
Services map[string]ReqsService `yaml:"services,omitempty"`
}
AzureYaml represents the structure of azure.yaml.
type BulkServiceControlResult ¶
type BulkServiceControlResult struct {
Success bool `json:"success"`
Message string `json:"message"`
Results []ServiceControlResult `json:"results"`
SuccessCount int `json:"successCount"`
FailureCount int `json:"failureCount"`
TotalTime string `json:"totalDuration"` // Human-readable duration string
}
BulkServiceControlResult contains results for bulk service operations.
type CleanDependenciesError ¶
CleanDependenciesError represents an error during dependency cleaning with details.
func (*CleanDependenciesError) Error ¶
func (e *CleanDependenciesError) Error() string
Error implements the error interface.
type CollectedLogs ¶
type CollectedLogs struct {
// Entries holds log entries when no context extraction is needed.
// Initialized to empty slice (not nil) so JSON marshaling produces [] not null.
Entries []service.LogEntry
// EntriesWithContext holds log entries with surrounding context lines.
// Populated when contextLines > 0 and a level filter is active.
// Initialized to empty slice (not nil) so JSON marshaling produces [] not null.
EntriesWithContext []LogEntryWithContext
// HasContext indicates whether EntriesWithContext is populated (true)
// or Entries is populated (false).
HasContext bool
// DashboardAvailable indicates whether the dashboard was reachable.
DashboardAvailable bool
// ServiceCount is the number of services discovered via dashboard.
ServiceCount int
// Source is the log source that was used ("local", "azure", "all").
Source string
// Warnings holds non-fatal warning messages (e.g., "Azure logs unavailable").
// CLI displays these via cliout.Warning; MCP can include them in responses.
Warnings []string
}
CollectedLogs holds the result of log collection, including metadata for callers to make display/error decisions. collect() returns this; execute() and MCP handlers consume it.
type DashboardClient ¶
type DashboardClient interface {
Ping(ctx context.Context) error
GetServices(ctx context.Context) ([]*serviceinfo.ServiceInfo, error)
StreamLogs(ctx context.Context, serviceName string, logs chan<- service.LogEntry) error
GetAzureLogs(ctx context.Context, services []string, tail int, since time.Time) ([]service.LogEntry, error)
GetAzureStatus(ctx context.Context) (*service.AzureStatus, error) //nolint:staticcheck // backward-compatible API
StreamAzureLogs(ctx context.Context, logs chan<- service.LogEntry) error
}
DashboardClient defines the interface for dashboard operations needed by logs. This interface enables testing by allowing mock implementations.
type DependencyInstaller ¶
type DependencyInstaller struct {
// contains filtered or unexported fields
}
DependencyInstaller handles installation of project dependencies.
func NewDependencyInstaller ¶
func NewDependencyInstaller(searchRoot string) *DependencyInstaller
NewDependencyInstaller creates a new dependency installer.
func (*DependencyInstaller) InstallAll ¶
func (di *DependencyInstaller) InstallAll() ([]InstallResult, error)
InstallAll installs dependencies for all detected project types. Returns results for all attempted installations and any detection errors.
func (*DependencyInstaller) InstallAllFiltered ¶
func (di *DependencyInstaller) InstallAllFiltered() ([]InstallResult, error)
InstallAllFiltered installs dependencies for pre-filtered projects. Use this when projects have already been detected and filtered (e.g., by service name).
type DepsOptions ¶
type DepsOptions struct {
Verbose bool
Clean bool
NoCache bool
Force bool
DryRun bool // Show what would be installed without installing
Services []string // Filter to specific services by name
}
DepsOptions holds the options for the deps command. Using a struct instead of global variables for better testability and concurrency safety.
func GetDepsOptions
deprecated
func GetDepsOptions() *DepsOptions
GetDepsOptions is a legacy getter function for backward compatibility.
Deprecated: Use executor pattern instead.
type DepsResult ¶
type DepsResult struct {
Success bool `json:"success"`
Projects []InstallResult `json:"projects"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
}
DepsResult represents the JSON output structure for deps command.
type DetectedRequirement ¶
type DetectedRequirement struct {
Name string // Tool identifier (e.g., "node", "docker")
InstalledVersion string // Currently installed version (e.g., "22.3.0")
MinVersion string // Normalized minimum version (e.g., "22.0.0")
CheckRunning bool // Whether tool must be running
Source string // What triggered detection (e.g., "package.json", "AppHost.cs")
}
DetectedRequirement represents a requirement found during project scanning.
type ExecutionContext ¶
type ExecutionContext struct {
CacheEnabled bool
}
ExecutionContext holds runtime configuration for command execution.
type FixResult ¶
type FixResult struct {
Name string `json:"name"`
Fixed bool `json:"fixed"`
Found bool `json:"found"`
Path string `json:"path,omitempty"`
Message string `json:"message"`
Satisfied bool `json:"satisfied"`
}
FixResult represents the result of attempting to fix a requirement.
type GenerateConfig ¶
type GenerateConfig struct {
DryRun bool // Don't write files, just show what would happen
WorkingDir string // Directory to start search from
}
GenerateConfig holds configuration for requirement generation.
type GenerateResult ¶
type GenerateResult struct {
Reqs []DetectedRequirement
AzureYamlPath string
Created bool // True if azure.yaml was created vs updated
Added int // Number of reqs added
Skipped int // Number of existing reqs preserved
}
GenerateResult contains the outcome of reqs generation.
type InstallResult ¶
type InstallResult struct {
Type string `json:"type"`
Dir string `json:"dir,omitempty"`
Path string `json:"path,omitempty"`
Manager string `json:"manager,omitempty"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
}
InstallResult represents the result of installing dependencies for a project.
type LogContext ¶
type LogContext struct {
Before []string `json:"before,omitempty"`
After []string `json:"after,omitempty"`
}
LogContext contains log lines before and after a matching entry.
type LogEntryWithContext ¶
type LogEntryWithContext struct {
Service string `json:"service"`
Message string `json:"message"`
Level string `json:"level"`
Timestamp time.Time `json:"timestamp"`
IsStderr bool `json:"isStderr,omitempty"`
Context *LogContext `json:"context,omitempty"`
}
LogEntryWithContext represents a log entry with surrounding context lines. Used when --context flag is specified to include lines before/after matches.
type LogManagerInterface ¶
type LogManagerInterface interface {
GetBuffer(serviceName string) (*service.LogBuffer, bool)
GetAllBuffers() map[string]*service.LogBuffer
}
LogManagerInterface defines the interface for log manager operations. This interface enables testing by allowing mock implementations.
type LogSource ¶
type LogSource string
LogSource represents where logs are collected from.
const ( // LogSourceLocal indicates logs from locally running services. LogSourceLocal LogSource = "local" // LogSourceAzure indicates logs from Azure-deployed services. LogSourceAzure LogSource = "azure" // LogSourceAll indicates logs from both local and Azure sources. LogSourceAll LogSource = "all" )
type Prerequisite ¶
type Prerequisite struct {
Name string `yaml:"name"`
MinVersion string `yaml:"minVersion"`
// Custom tool configuration (optional)
Command string `yaml:"command,omitempty"` // Override command to execute
Args []string `yaml:"args,omitempty"` // Override arguments
VersionPrefix string `yaml:"versionPrefix,omitempty"` // Override version prefix to strip
VersionField int `yaml:"versionField,omitempty"` // Override which field contains version
// Runtime check configuration (optional)
CheckRunning bool `yaml:"checkRunning,omitempty"` // Whether to check if the tool is running
RunningCheckCommand string `yaml:"runningCheckCommand,omitempty"` // Command to check if tool is running
RunningCheckArgs []string `yaml:"runningCheckArgs,omitempty"` // Arguments for running check command
RunningCheckExpected string `yaml:"runningCheckExpected,omitempty"` // Expected substring in output (optional)
RunningCheckExitCode *int `yaml:"runningCheckExitCode,omitempty"` // Expected exit code (default: 0)
// Install URL configuration (optional)
InstallURL string `yaml:"installUrl,omitempty"` // URL to installation page (overrides built-in)
}
Prerequisite represents a prerequisite from azure.yaml.
type PrerequisiteChecker ¶
type PrerequisiteChecker struct {
// contains filtered or unexported fields
}
PrerequisiteChecker handles checking of prerequisites.
func NewPrerequisiteChecker ¶
func NewPrerequisiteChecker() *PrerequisiteChecker
NewPrerequisiteChecker creates a new prerequisite checker.
func (*PrerequisiteChecker) Check ¶
func (pc *PrerequisiteChecker) Check(prereq Prerequisite) ReqResult
Check checks a prerequisite and returns structured result.
type ProjectInfo ¶
type ProjectInfo struct {
Project map[string]interface{} `json:"project" jsonschema:"description=Project metadata"`
Services []ProjectServiceSummary `json:"services" jsonschema:"description=Summary of services defined in the project"`
}
ProjectInfo represents the output schema for get_project_info tool
type ProjectServiceSummary ¶
type ProjectServiceSummary struct {
Name string `json:"name" jsonschema:"description=Service name"`
Language string `json:"language" jsonschema:"description=Programming language"`
Framework string `json:"framework" jsonschema:"description=Framework used"`
Project string `json:"project" jsonschema:"description=Project directory path"`
}
ProjectServiceSummary represents a simplified service summary
type ReqResult ¶
type ReqResult struct {
Name string `json:"name"`
Installed bool `json:"installed"`
Version string `json:"version,omitempty"`
Required string `json:"required"`
Satisfied bool `json:"satisfied"`
Running bool `json:"running,omitempty"`
CheckedRun bool `json:"checkedRunning,omitempty"`
Message string `json:"message,omitempty"`
IsPodman bool `json:"isPodman,omitempty"` // True when Podman is aliased to Docker
InstallURL string `json:"installUrl,omitempty"` // URL to installation page
}
ReqResult represents the result of checking a requirement.
type ReqsDockerConfig ¶
type ReqsDockerConfig struct {
Image string `yaml:"image,omitempty"`
}
ReqsDockerConfig represents minimal Docker configuration for reqs parsing.
type ReqsResult ¶
ReqsResult represents the JSON output structure for reqs command.
type ReqsService ¶
type ReqsService struct {
Image string `yaml:"image,omitempty"`
Docker *ReqsDockerConfig `yaml:"docker,omitempty"`
}
ReqsService represents a minimal service definition for reqs parsing. Only includes fields needed to detect container services.
type RequirementStatus ¶
type RequirementStatus struct {
Name string `json:"name" jsonschema:"description=Requirement name (e.g. node, python, docker)"`
Required string `json:"required" jsonschema:"description=Required version"`
Installed string `json:"installed,omitempty" jsonschema:"description=Installed version if found"`
Met bool `json:"met" jsonschema:"description=Whether requirement is satisfied"`
InstallCommand string `json:"installCommand,omitempty" jsonschema:"description=Command to install if missing"`
}
RequirementStatus represents individual requirement check result
type RequirementsResult ¶
type RequirementsResult struct {
Requirements []RequirementStatus `json:"requirements" jsonschema:"description=List of requirements and their status"`
AllMet bool `json:"allMet" jsonschema:"description=Whether all requirements are satisfied"`
}
RequirementsResult represents the output schema for check_requirements tool
type ResultFormatter ¶
type ResultFormatter struct{}
ResultFormatter handles formatting of requirement check results.
func NewResultFormatter ¶
func NewResultFormatter() *ResultFormatter
NewResultFormatter creates a new result formatter.
func (*ResultFormatter) Print ¶
func (rf *ResultFormatter) Print(result ReqResult)
Print formats and prints a single requirement result.
func (*ResultFormatter) PrintAll ¶
func (rf *ResultFormatter) PrintAll(results []ReqResult)
PrintAll formats and prints all requirement results.
type ServiceControlResult ¶
type ServiceControlResult struct {
ServiceName string `json:"serviceName"`
Success bool `json:"success"`
Message string `json:"message"`
Status string `json:"status,omitempty"`
Error string `json:"error,omitempty"`
Duration string `json:"duration,omitempty"` // Human-readable duration string
}
ServiceControlResult contains the result of a service control operation.
type ServiceController ¶
type ServiceController struct {
// contains filtered or unexported fields
}
ServiceController provides shared logic for service lifecycle CLI commands.
func NewServiceController ¶
func NewServiceController(projectDir string) (*ServiceController, error)
NewServiceController creates a new service controller for the given project directory.
func (*ServiceController) BulkRestart ¶
func (c *ServiceController) BulkRestart(ctx context.Context, serviceNames []string) *BulkServiceControlResult
BulkRestart restarts multiple services.
func (*ServiceController) BulkStart ¶
func (c *ServiceController) BulkStart(ctx context.Context, serviceNames []string) *BulkServiceControlResult
BulkStart starts multiple services.
func (*ServiceController) BulkStop ¶
func (c *ServiceController) BulkStop(ctx context.Context, serviceNames []string) *BulkServiceControlResult
BulkStop stops multiple services.
func (*ServiceController) GetAllServices ¶
func (c *ServiceController) GetAllServices() []string
GetAllServices returns a list of all registered service names.
func (*ServiceController) GetRunningServices ¶
func (c *ServiceController) GetRunningServices() []string
GetRunningServices returns a list of running service names.
func (*ServiceController) GetStoppedServices ¶
func (c *ServiceController) GetStoppedServices() []string
GetStoppedServices returns a list of stopped service names.
func (*ServiceController) RestartService ¶
func (c *ServiceController) RestartService(ctx context.Context, serviceName string) *ServiceControlResult
RestartService restarts a single service.
func (*ServiceController) StartService ¶
func (c *ServiceController) StartService(ctx context.Context, serviceName string) *ServiceControlResult
StartService starts a single service.
func (*ServiceController) StopService ¶
func (c *ServiceController) StopService(ctx context.Context, serviceName string) *ServiceControlResult
StopService stops a single service.
type ServiceDetails ¶
type ServiceDetails struct {
Name string `json:"name" jsonschema:"description=Service name"`
Language string `json:"language" jsonschema:"description=Programming language (e.g. python, javascript, dotnet)"`
Framework string `json:"framework" jsonschema:"description=Framework used (e.g. flask, express, aspnet)"`
Project string `json:"project" jsonschema:"description=Path to the project directory"`
Status string `json:"status,omitempty" jsonschema:"description=Current running status"`
Health string `json:"health,omitempty" jsonschema:"description=Health check status"`
URL string `json:"url,omitempty" jsonschema:"description=Local URL where service is running"`
Port int `json:"port,omitempty" jsonschema:"description=Port number the service is listening on"`
PID int `json:"pid,omitempty" jsonschema:"description=Process ID of the running service"`
Env map[string]string `json:"env,omitempty" jsonschema:"description=Environment variables configured for the service"`
}
ServiceDetails represents individual service information
type ServiceInfo ¶
type ServiceInfo struct {
Project map[string]interface{} `json:"project" jsonschema:"description=Project metadata including name and directory"`
Services []ServiceDetails `json:"services" jsonschema:"description=List of services with their status and configuration"`
}
ServiceInfo represents the output schema for get_services tool
type TestOptions ¶
type TestOptions struct {
Type string
Coverage bool
ServiceFilter string
Watch bool
UpdateSnapshots bool
FailFast bool
Parallel bool
Threshold int
Verbose bool
DryRun bool
OutputFormat string
OutputDir string
Stream bool
NoStream bool
Timeout time.Duration
Save bool
NoSave bool
}
TestOptions holds the options for the test command. Using a struct instead of global variables for better testability and concurrency safety.
type ToolConfig ¶
type ToolConfig struct {
Command string // The command to execute
Args []string // Arguments to get version
VersionPrefix string // Prefix to strip from version output (e.g., "v" for node)
VersionField int // Which field contains version (0 = whole output, 1 = second field, etc.)
}
ToolConfig defines how to check a specific tool.