58 lines
1.7 KiB
Go
58 lines
1.7 KiB
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/BlackRoad-OS/blackroad-cli/internal/api"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var deployCmd = &cobra.Command{
|
|
Use: "deploy <project>",
|
|
Short: "Deploy a project",
|
|
Long: `Deploy a project to BlackRoad infrastructure.
|
|
|
|
This creates a deployment task that will be picked up by the appropriate agent.
|
|
|
|
Examples:
|
|
blackroad deploy my-service
|
|
blackroad deploy auth-api --priority urgent --division Security`,
|
|
Args: cobra.ExactArgs(1),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
client, err := api.NewClient()
|
|
if err != nil {
|
|
printError(err.Error())
|
|
return
|
|
}
|
|
|
|
project := args[0]
|
|
priority, _ := cmd.Flags().GetString("priority")
|
|
division, _ := cmd.Flags().GetString("division")
|
|
env, _ := cmd.Flags().GetString("env")
|
|
|
|
title := fmt.Sprintf("Deploy %s", project)
|
|
description := fmt.Sprintf("Deploy project %s to %s environment", project, env)
|
|
|
|
task, err := client.DispatchTask(title, description, priority, division)
|
|
if err != nil {
|
|
printError(err.Error())
|
|
return
|
|
}
|
|
|
|
fmt.Printf("%s Deployment task created\n", green("✓"))
|
|
fmt.Printf("%s %s\n", bold("Task ID:"), task.ID)
|
|
fmt.Printf("%s %s\n", bold("Project:"), project)
|
|
fmt.Printf("%s %s\n", bold("Priority:"), task.Priority)
|
|
if division != "" {
|
|
fmt.Printf("%s %s\n", bold("Division:"), division)
|
|
}
|
|
fmt.Printf("\n%s Track progress with: blackroad tasks get %s\n", yellow("→"), task.ID[:12])
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
deployCmd.Flags().StringP("priority", "p", "high", "Deployment priority (low, medium, high, urgent)")
|
|
deployCmd.Flags().StringP("division", "d", "", "Target division")
|
|
deployCmd.Flags().StringP("env", "e", "production", "Target environment")
|
|
}
|