(cmd *cobra.Command)
| 88 | } |
| 89 | |
| 90 | func runStatus(cmd *cobra.Command) error { |
| 91 | ctx := context.Background() |
| 92 | |
| 93 | // Load configuration |
| 94 | configPath, _ := cmd.Flags().GetString("config") |
| 95 | cfg, err := config.LoadCLIConfig(configPath) |
| 96 | if err != nil { |
| 97 | return fmt.Errorf("failed to load configuration: %w", err) |
| 98 | } |
| 99 | |
| 100 | // Apply command line flag overrides |
| 101 | if region, _ := cmd.Flags().GetString("region"); cmd.Flags().Changed("region") { |
| 102 | cfg.AWS.Region = region |
| 103 | } |
| 104 | if stackName, _ := cmd.Flags().GetString("stack-name"); cmd.Flags().Changed("stack-name") { |
| 105 | cfg.Deployment.StackName = stackName |
| 106 | } |
| 107 | |
| 108 | // Validate configuration |
| 109 | if errors := config.ValidateCLIConfig(cfg); len(errors) > 0 { |
| 110 | fmt.Printf("Configuration validation errors:\n") |
| 111 | for _, err := range errors { |
| 112 | fmt.Printf(" - %s\n", err.Error()) |
| 113 | } |
| 114 | return fmt.Errorf("configuration validation failed") |
| 115 | } |
| 116 | |
| 117 | // Create AWS clients |
| 118 | clientFactory, err := awsclients.NewClientFactory(cfg) |
| 119 | if err != nil { |
| 120 | return fmt.Errorf("failed to create AWS clients: %w", err) |
| 121 | } |
| 122 | |
| 123 | // Validate AWS credentials |
| 124 | if err := clientFactory.ValidateCredentials(ctx); err != nil { |
| 125 | return fmt.Errorf("invalid AWS credentials: %w", err) |
| 126 | } |
| 127 | |
| 128 | clients := clientFactory.GetClients() |
| 129 | |
| 130 | // Gather status information |
| 131 | statusInfo := &StatusInfo{ |
| 132 | Summary: &StatusSummary{ |
| 133 | LastUpdated: time.Now().Format("2006-01-02 15:04:05 MST"), |
| 134 | }, |
| 135 | } |
| 136 | |
| 137 | // Get stack status |
| 138 | stackDeployer := deploy.NewStackDeployer(clients, cfg) |
| 139 | if stackOutput, err := stackDeployer.GetStackOutputs(ctx); err == nil { |
| 140 | statusInfo.Stack = &StackStatus{ |
| 141 | Name: stackOutput.StackName, |
| 142 | Status: stackOutput.StackStatus, |
| 143 | CreatedAt: stackOutput.CreationTime, |
| 144 | UpdatedAt: stackOutput.LastUpdatedTime, |
| 145 | BucketName: stackOutput.CoordinationBucketName, |
| 146 | RoleArn: stackOutput.LambdaExecutionRoleArn, |
| 147 | } |
no test coverage detected