Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/abiosoft/colima v0.8.1
github.com/aws/smithy-go v1.22.3
github.com/briandowns/spinner v1.23.2
github.com/compose-spec/compose-go v1.20.2
github.com/compose-spec/compose-go/v2 v2.6.4
github.com/fluxcd/kustomize-controller/api v1.5.1
github.com/fluxcd/pkg/apis/kustomize v1.9.0
github.com/fluxcd/pkg/apis/meta v1.10.0
Expand Down Expand Up @@ -99,6 +99,7 @@ require (
github.com/go-openapi/jsonpointer v0.21.1 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.1 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
Expand Down Expand Up @@ -151,6 +152,7 @@ require (
github.com/tetratelabs/wazero v1.9.0 // indirect
github.com/urfave/cli v1.22.16 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
github.com/zeebo/errs v1.4.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
Expand All @@ -163,7 +165,6 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.36.0 // indirect
go.opentelemetry.io/otel/trace v1.36.0 // indirect
go.opentelemetry.io/proto/otlp v1.6.0 // indirect
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
golang.org/x/mod v0.24.0 // indirect
golang.org/x/net v0.40.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 h1:aQ3y1lwWyqYPiWZThqv1aFbZMiM9vblcSArJRf2Irls=
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/compose-spec/compose-go v1.20.2 h1:u/yfZHn4EaHGdidrZycWpxXgFffjYULlTbRfJ51ykjQ=
github.com/compose-spec/compose-go v1.20.2/go.mod h1:+MdqXV4RA7wdFsahh/Kb8U0pAJqkg7mr4PM9tFKU8RM=
github.com/compose-spec/compose-go/v2 v2.6.4 h1:Gjv6x8eAhqwwWvoXIo0oZ4bDQBh0OMwdU7LUL9PDLiM=
github.com/compose-spec/compose-go/v2 v2.6.4/go.mod h1:vPlkN0i+0LjLf9rv52lodNMUTJF5YHVfHVGLLIP67NA=
github.com/containerd/continuity v0.4.5 h1:ZRoN1sXq9u7V6QoHMcVWGhOwDFqZ4B9i5H6un1Wh0x4=
github.com/containerd/continuity v0.4.5/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE=
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
Expand Down Expand Up @@ -380,6 +380,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
Expand Down Expand Up @@ -417,8 +419,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI=
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
Expand Down
6 changes: 4 additions & 2 deletions pkg/services/dns_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"
"strings"

"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"github.com/windsorcli/cli/pkg/constants"
"github.com/windsorcli/cli/pkg/di"
)
Expand Down Expand Up @@ -102,7 +102,9 @@ func (s *DNSService) GetComposeConfig() (*types.Config, error) {
}
}

services := []types.ServiceConfig{corednsConfig}
services := types.Services{
serviceName: corednsConfig,
}

return &types.Config{Services: services}, nil
}
Expand Down
47 changes: 30 additions & 17 deletions pkg/services/dns_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"github.com/windsorcli/cli/pkg/config"
"github.com/windsorcli/cli/pkg/di"
)
Expand Down Expand Up @@ -222,8 +222,8 @@ func TestDNSService_GetComposeConfig(t *testing.T) {
if len(cfg.Services) != 1 {
t.Errorf("Expected 1 service, got %d", len(cfg.Services))
}
if cfg.Services[0].Name != "dns" {
t.Errorf("Expected service name to be 'dns', got %s", cfg.Services[0].Name)
if service, exists := cfg.Services["dns"]; !exists || service.Name != "dns" {
t.Errorf("Expected service with name 'dns', got %+v", cfg.Services)
}
})

Expand All @@ -249,14 +249,27 @@ func TestDNSService_GetComposeConfig(t *testing.T) {
if len(cfg.Services) != 1 {
t.Errorf("Expected 1 service, got %d", len(cfg.Services))
}
if len(cfg.Services[0].Ports) != 2 {
t.Errorf("Expected 2 ports, got %d", len(cfg.Services[0].Ports))

// Get the DNS service from the map
var dnsService types.ServiceConfig
var found bool
for _, svc := range cfg.Services {
dnsService = svc
found = true
break
}
if !found {
t.Fatalf("No service found in Services map")
}

if len(dnsService.Ports) != 2 {
t.Errorf("Expected 2 ports, got %d", len(dnsService.Ports))
}
if cfg.Services[0].Ports[0].Published != "53" || cfg.Services[0].Ports[0].Protocol != "tcp" {
t.Errorf("Expected port 53 with protocol tcp, got port %s with protocol %s", cfg.Services[0].Ports[0].Published, cfg.Services[0].Ports[0].Protocol)
if dnsService.Ports[0].Published != "53" || dnsService.Ports[0].Protocol != "tcp" {
t.Errorf("Expected port 53 with protocol tcp, got port %s with protocol %s", dnsService.Ports[0].Published, dnsService.Ports[0].Protocol)
}
if cfg.Services[0].Ports[1].Published != "53" || cfg.Services[0].Ports[1].Protocol != "udp" {
t.Errorf("Expected port 53 with protocol udp, got port %s with protocol %s", cfg.Services[0].Ports[1].Published, cfg.Services[0].Ports[1].Protocol)
if dnsService.Ports[1].Published != "53" || dnsService.Ports[1].Protocol != "udp" {
t.Errorf("Expected port 53 with protocol udp, got port %s with protocol %s", dnsService.Ports[1].Published, dnsService.Ports[1].Protocol)
}
})
}
Expand Down Expand Up @@ -401,8 +414,8 @@ func TestDNSService_WriteConfig(t *testing.T) {
}
mockService.GetComposeConfigFunc = func() (*types.Config, error) {
return &types.Config{
Services: []types.ServiceConfig{
{Name: "test-service"},
Services: types.Services{
"test-service": {Name: "test-service"},
},
}, nil
}
Expand Down Expand Up @@ -454,8 +467,8 @@ func TestDNSService_WriteConfig(t *testing.T) {
}
mockService.GetComposeConfigFunc = func() (*types.Config, error) {
return &types.Config{
Services: []types.ServiceConfig{
{Name: "test-service"},
Services: types.Services{
"test-service": {Name: "test-service"},
},
}, nil
}
Expand Down Expand Up @@ -519,8 +532,8 @@ func TestDNSService_WriteConfig(t *testing.T) {
}
mockServiceNoName.GetComposeConfigFunc = func() (*types.Config, error) {
return &types.Config{
Services: []types.ServiceConfig{
{Name: ""},
Services: types.Services{
"": {Name: ""},
},
}, nil
}
Expand All @@ -535,8 +548,8 @@ func TestDNSService_WriteConfig(t *testing.T) {
}
mockServiceNoAddress.GetComposeConfigFunc = func() (*types.Config, error) {
return &types.Config{
Services: []types.ServiceConfig{
{Name: "test-service"},
Services: types.Services{
"test-service": {Name: "test-service"},
},
}, nil
}
Expand Down
20 changes: 12 additions & 8 deletions pkg/services/git_livereload_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"path/filepath"

"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"github.com/windsorcli/cli/pkg/constants"
"github.com/windsorcli/cli/pkg/di"
)
Expand Down Expand Up @@ -43,9 +43,6 @@ func (s *GitLivereloadService) GetComposeConfig() (*types.Config, error) {
// Get the context name
contextName := s.configHandler.GetContext()

// Prepare the services slice for docker-compose
var services []types.ServiceConfig

// Retrieve environment variables from config with defaults using Get* functions
rsyncExclude := s.configHandler.GetString("git.livereload.rsync_exclude", constants.DEFAULT_GIT_LIVE_RELOAD_RSYNC_EXCLUDE)
rsyncProtect := s.configHandler.GetString("git.livereload.rsync_protect", constants.DEFAULT_GIT_LIVE_RELOAD_RSYNC_PROTECT)
Expand Down Expand Up @@ -78,9 +75,12 @@ func (s *GitLivereloadService) GetComposeConfig() (*types.Config, error) {
// Get the git folder name
gitFolderName := filepath.Base(projectRoot)

// Add the git-livereload service
services = append(services, types.ServiceConfig{
Name: s.name,
// Get the service name
serviceName := s.name

// Create the service config
serviceConfig := types.ServiceConfig{
Name: serviceName,
ContainerName: s.GetContainerName(),
Image: image,
Restart: "always",
Expand All @@ -97,7 +97,11 @@ func (s *GitLivereloadService) GetComposeConfig() (*types.Config, error) {
Target: fmt.Sprintf("/repos/mount/%s", gitFolderName),
},
},
})
}

services := types.Services{
serviceName: serviceConfig,
}

return &types.Config{
Services: services,
Expand Down
42 changes: 22 additions & 20 deletions pkg/services/localstack_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"
"strings"

"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"github.com/windsorcli/cli/pkg/constants"
"github.com/windsorcli/cli/pkg/di"
)
Expand Down Expand Up @@ -63,36 +63,38 @@ func (s *LocalstackService) GetComposeConfig() (*types.Config, error) {
containerName := s.GetContainerName()

// Create the service config
services := []types.ServiceConfig{
{
Name: serviceName,
ContainerName: containerName,
Image: image,
Restart: "always",
Environment: map[string]*string{
"ENFORCE_IAM": ptrString("1"),
"PERSISTENCE": ptrString("1"),
"IAM_SOFT_MODE": ptrString("0"),
"DEBUG": ptrString("0"),
"SERVICES": ptrString(servicesList),
},
Labels: map[string]string{
"role": "localstack",
"managed_by": "windsor",
"wildcard": "true",
},
serviceConfig := types.ServiceConfig{
Name: serviceName,
ContainerName: containerName,
Image: image,
Restart: "always",
Environment: map[string]*string{
"ENFORCE_IAM": ptrString("1"),
"PERSISTENCE": ptrString("1"),
"IAM_SOFT_MODE": ptrString("0"),
"DEBUG": ptrString("0"),
"SERVICES": ptrString(servicesList),
},
Labels: map[string]string{
"role": "localstack",
"managed_by": "windsor",
"wildcard": "true",
},
}

// If the localstack auth token is set, add it to the secrets
if localstackAuthToken != "" {
services[0].Secrets = []types.ServiceSecretConfig{
serviceConfig.Secrets = []types.ServiceSecretConfig{
{
Source: "LOCALSTACK_AUTH_TOKEN",
},
}
}

services := types.Services{
serviceName: serviceConfig,
}

return &types.Config{Services: services}, nil
}

Expand Down
10 changes: 8 additions & 2 deletions pkg/services/localstack_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ func TestLocalstackService_GetComposeConfig(t *testing.T) {
t.Fatalf("expected non-nil composeConfig with services, got %v", composeConfig)
}

composeService := composeConfig.Services[0]
composeService, exists := composeConfig.Services["aws"]
if !exists {
t.Fatalf("expected service 'aws' to exist in compose config")
}
if composeService.Name != "aws" {
t.Errorf("expected service name 'aws', got %v", composeService.Name)
}
Expand Down Expand Up @@ -93,7 +96,10 @@ func TestLocalstackService_GetComposeConfig(t *testing.T) {
t.Fatalf("expected non-nil composeConfig with services, got %v", composeConfig)
}

composeService := composeConfig.Services[0]
composeService, exists := composeConfig.Services["aws"]
if !exists {
t.Fatalf("expected service 'aws' to exist in compose config")
}
if len(composeService.Secrets) == 0 || composeService.Secrets[0].Source != "LOCALSTACK_AUTH_TOKEN" {
t.Errorf("expected service to have LOCALSTACK_AUTH_TOKEN secret, got %v", composeService.Secrets)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/mock_service.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package services

import (
"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
)

// The MockService is a test implementation of the Service interface
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/mock_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package services
import (
"testing"

"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
)

// The MockServiceTest provides test coverage for the MockService implementation.
Expand Down
5 changes: 3 additions & 2 deletions pkg/services/registry_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"sync"

"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"github.com/windsorcli/cli/api/v1alpha1/docker"
"github.com/windsorcli/cli/pkg/constants"
"github.com/windsorcli/cli/pkg/di"
Expand Down Expand Up @@ -60,7 +60,8 @@ func (s *RegistryService) GetComposeConfig() (*types.Config, error) {
if err != nil {
return nil, fmt.Errorf("failed to generate registry service: %w", err)
}
return &types.Config{Services: []types.ServiceConfig{service}}, nil
serviceName := getBasename(s.GetHostname())
return &types.Config{Services: types.Services{serviceName: service}}, nil
}

return nil, fmt.Errorf("no registry found with name: %s", s.name)
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/registry_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"github.com/windsorcli/cli/api/v1alpha1"
"github.com/windsorcli/cli/api/v1alpha1/docker"
"github.com/windsorcli/cli/pkg/config"
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net"
"strings"

"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"github.com/windsorcli/cli/pkg/config"
"github.com/windsorcli/cli/pkg/di"
"github.com/windsorcli/cli/pkg/shell"
Expand Down
Loading
Loading