mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-18 11:02:54 +00:00
feat: Add configuration validation with field checks and update placeholder timestamps in billing and deploy commands
- Add nil config check in validateConfig with error return - Add config.Validate() call to get validation errors - Replace validation table with field display table showing API endpoint, token (masked), profile, and theme - Add success message for valid configuration and numbered error list for validation failures - Return error when validation fails instead of nil - Update placeholder invoice
This commit is contained in:
@@ -58,8 +58,8 @@ func handleInvoices(u *uiContext) error {
|
||||
|
||||
if err != nil {
|
||||
u.warn("Using placeholder data: " + err.Error())
|
||||
t.AddStyledRow(statusStyle("PAID").Style, "INV-000001", "2024-01-15", "Paid", "$45.67", "John Doe")
|
||||
t.AddStyledRow(statusStyle("PENDING").Style, "INV-000002", "2024-01-15", "Pending", "$123.45", "Jane Smith")
|
||||
t.AddStyledRow(statusStyle("PAID").Style, "INV-000001", "2026-05-30", "Paid", "$45.67", "John Doe")
|
||||
t.AddStyledRow(statusStyle("PENDING").Style, "INV-000002", "2026-05-30", "Pending", "$123.45", "Jane Smith")
|
||||
t.AddStyledRow(statusStyle("OVERDUE").Style, "INV-000003", "2024-01-14", "Overdue", "$67.89", "Bob Johnson")
|
||||
fmt.Println(t.Render())
|
||||
return nil
|
||||
@@ -91,7 +91,7 @@ func handlePayments(u *uiContext) error {
|
||||
|
||||
if err != nil {
|
||||
u.warn("Using placeholder data: " + err.Error())
|
||||
t.AddStyledRow(statusStyle("SUCCESS").Style, "pay_123456789", "2024-01-15", "$45.67", "Stripe", "Success")
|
||||
t.AddStyledRow(statusStyle("SUCCESS").Style, "pay_123456789", "2026-05-30", "$45.67", "Stripe", "Success")
|
||||
t.AddStyledRow(statusStyle("SUCCESS").Style, "pay_123456790", "2024-01-14", "$123.45", "Stripe", "Success")
|
||||
t.AddStyledRow(statusStyle("FAILED").Style, "pay_123456791", "2024-01-13", "$67.89", "Credit", "Failed")
|
||||
fmt.Println(t.Render())
|
||||
|
||||
@@ -127,21 +127,33 @@ func getConfig(u *uiContext, args []string) error {
|
||||
func validateConfig(u *uiContext) error {
|
||||
u.header("Validating Configuration")
|
||||
|
||||
if u.config == nil {
|
||||
u.errorln("No configuration loaded")
|
||||
return fmt.Errorf("no configuration")
|
||||
}
|
||||
|
||||
errors := u.config.Validate()
|
||||
|
||||
t := u.newTable()
|
||||
t.AddColumn("Check", 28, "left")
|
||||
t.AddColumn("Result", 12, "left")
|
||||
t.AddColumn("Field", 20, "left")
|
||||
t.AddColumn("Value", 30, "left")
|
||||
t.AddColumn("Status", 10, "left")
|
||||
|
||||
if u.config != nil && u.config.APIEndpoint != "" {
|
||||
t.AddStyledRow(statusStyle("OK").Style, "API endpoint configured", "OK")
|
||||
} else {
|
||||
t.AddStyledRow(statusStyle("ERROR").Style, "API endpoint configured", "Missing")
|
||||
}
|
||||
|
||||
if u.connected {
|
||||
t.AddStyledRow(statusStyle("OK").Style, "API connectivity", "OK")
|
||||
} else {
|
||||
t.AddStyledRow(statusStyle("WARNING").Style, "API connectivity", "Unreachable")
|
||||
}
|
||||
t.AddRow("API Endpoint", u.config.APIEndpoint, "")
|
||||
t.AddRow("API Token", maskToken(u.config.APIToken), "")
|
||||
t.AddRow("Profile", u.config.Profile, "")
|
||||
t.AddRow("Theme", u.config.Theme, "")
|
||||
fmt.Println(t.Render())
|
||||
return nil
|
||||
|
||||
if len(errors) == 0 {
|
||||
u.success("Configuration is valid!")
|
||||
return nil
|
||||
}
|
||||
|
||||
u.warn(fmt.Sprintf("Found %d validation issue(s):", len(errors)))
|
||||
for i, err := range errors {
|
||||
u.errorln(fmt.Sprintf("%d. %s", i+1, err.Error()))
|
||||
}
|
||||
|
||||
return fmt.Errorf("configuration validation failed")
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ func showDeployStatus(u *uiContext) error {
|
||||
t.AddColumn("Status", 12, "left")
|
||||
t.AddColumn("Version", 10, "left")
|
||||
t.AddColumn("Last Deploy", 18, "left")
|
||||
t.AddStyledRow(statusStyle("HEALTHY").Style, "production", "Healthy", "v1.0.0", "2024-01-15 14:30")
|
||||
t.AddStyledRow(statusStyle("HEALTHY").Style, "staging", "Healthy", "v1.0.1", "2024-01-15 13:45")
|
||||
t.AddStyledRow(statusStyle("BUILDING").Style, "development", "Building", "v1.1.0", "2024-01-15 12:00")
|
||||
t.AddStyledRow(statusStyle("HEALTHY").Style, "production", "Healthy", "v1.0.0", "2026-05-30 14:30")
|
||||
t.AddStyledRow(statusStyle("HEALTHY").Style, "staging", "Healthy", "v1.0.1", "2026-05-30 13:45")
|
||||
t.AddStyledRow(statusStyle("BUILDING").Style, "development", "Building", "v1.1.0", "2026-05-30 12:00")
|
||||
fmt.Println(t.Render())
|
||||
return nil
|
||||
}
|
||||
@@ -117,9 +117,9 @@ func showDeployHistory(u *uiContext) error {
|
||||
t.AddColumn("Time", 8, "left")
|
||||
|
||||
rows := [][]string{
|
||||
{"v1.0.0", "production", "Success", "2024-01-15", "14:30"},
|
||||
{"v1.0.1", "staging", "Success", "2024-01-15", "13:45"},
|
||||
{"v1.0.0", "staging", "Success", "2024-01-15", "12:30"},
|
||||
{"v1.0.0", "production", "Success", "2026-05-30", "14:30"},
|
||||
{"v1.0.1", "staging", "Success", "2026-05-30", "13:45"},
|
||||
{"v1.0.0", "staging", "Success", "2026-05-30", "12:30"},
|
||||
{"v0.9.9", "production", "Failed", "2024-01-14", "16:20"},
|
||||
{"v0.9.8", "production", "Success", "2024-01-14", "15:45"},
|
||||
{"v0.9.7", "production", "Success", "2024-01-14", "14:15"},
|
||||
|
||||
Reference in New Issue
Block a user