Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package deploy

import (
"fmt"
"os"

"github.com/deviantony/pctl/internal/build"
"github.com/deviantony/pctl/internal/compose"
Expand All @@ -12,6 +13,7 @@ import (

"github.com/charmbracelet/lipgloss"
"github.com/spf13/cobra"
"golang.org/x/term"
)

var (
Expand Down Expand Up @@ -98,16 +100,29 @@ func runDeploy(cmd *cobra.Command, args []string) error {
// Create Portainer client
client := portainer.NewClientWithTLS(cfg.PortainerURL, cfg.APIToken, cfg.SkipTLSVerify)

// Extract service names and setup build logger
serviceNames := make([]string, len(servicesWithBuild))
for i, svc := range servicesWithBuild {
serviceNames[i] = svc.ServiceName
}

// Setup build logger with optional dashboard for interactive terminals
dashboardSetup := build.SetupBuildLogger(serviceNames, term.IsTerminal(int(os.Stdout.Fd())))

// Create build orchestrator
logger := build.NewStyledBuildLogger("BUILD")
orchestrator := build.NewBuildOrchestrator(client, buildConfig, cfg.EnvironmentID, cfg.StackName, logger)
orchestrator := build.NewBuildOrchestrator(client, buildConfig, cfg.EnvironmentID, cfg.StackName, dashboardSetup.Logger)

// Build services
imageTags, err := orchestrator.BuildServices(servicesWithBuild)
if err != nil {
// Stop dashboard before returning error
dashboardSetup.StopDashboard(build.DashboardErrorDisplayDuration)
return fmt.Errorf("build failed: %w", err)
}

// Keep dashboard visible for a moment before stopping
dashboardSetup.StopDashboard(build.DashboardSuccessDisplayDuration)

// Transform compose file
transformer, err := compose.TransformComposeFile(composeContent, imageTags)
if err != nil {
Expand Down
19 changes: 17 additions & 2 deletions cmd/redeploy/redeploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package redeploy

import (
"fmt"
"os"

"github.com/deviantony/pctl/internal/build"
"github.com/deviantony/pctl/internal/compose"
Expand All @@ -12,6 +13,7 @@ import (

"github.com/charmbracelet/lipgloss"
"github.com/spf13/cobra"
"golang.org/x/term"
)

var (
Expand Down Expand Up @@ -111,16 +113,29 @@ func runRedeploy(cmd *cobra.Command, args []string) error {
// Create Portainer client
client := portainer.NewClientWithTLS(cfg.PortainerURL, cfg.APIToken, cfg.SkipTLSVerify)

// Extract service names and setup build logger
serviceNames := make([]string, len(servicesWithBuild))
for i, svc := range servicesWithBuild {
serviceNames[i] = svc.ServiceName
}

// Setup build logger with optional dashboard for interactive terminals
dashboardSetup := build.SetupBuildLogger(serviceNames, term.IsTerminal(int(os.Stdout.Fd())))

// Create build orchestrator
logger := build.NewStyledBuildLogger("BUILD")
orchestrator := build.NewBuildOrchestrator(client, buildConfig, cfg.EnvironmentID, cfg.StackName, logger)
orchestrator := build.NewBuildOrchestrator(client, buildConfig, cfg.EnvironmentID, cfg.StackName, dashboardSetup.Logger)

// Build services
imageTags, err := orchestrator.BuildServices(servicesWithBuild)
if err != nil {
// Stop dashboard before returning error
dashboardSetup.StopDashboard(build.DashboardErrorDisplayDuration)
return fmt.Errorf("build failed: %w", err)
}

// Keep dashboard visible for a moment before stopping
dashboardSetup.StopDashboard(build.DashboardSuccessDisplayDuration)

// Transform compose file
transformer, err := compose.TransformComposeFile(composeContent, imageTags)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/charmbracelet/lipgloss v1.1.0
github.com/spf13/cobra v1.10.1
github.com/stretchr/testify v1.11.1
golang.org/x/term v0.28.0
gopkg.in/yaml.v3 v3.0.1
)

Expand Down
Loading
Loading