services

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2025 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseService

type BaseService struct {
	// contains filtered or unexported fields
}

BaseService is a base implementation of the Service interface

func NewBaseService

func NewBaseService(rt *runtime.Runtime) *BaseService

NewBaseService is a constructor for BaseService

func (*BaseService) GetAddress

func (s *BaseService) GetAddress() string

GetAddress returns the current address of the service

func (*BaseService) GetContainerName

func (s *BaseService) GetContainerName() string

GetContainerName returns the container name with the DNS domain

func (*BaseService) GetHostname

func (s *BaseService) GetHostname() string

GetHostname returns the hostname for the service, handling domain names specially

func (*BaseService) GetName

func (s *BaseService) GetName() string

GetName returns the current name of the service

func (*BaseService) SetAddress

func (s *BaseService) SetAddress(address string, portAllocator *PortAllocator) error

SetAddress sets the address if it is a valid IPv4 address. portAllocator is provided for services that need port allocation (e.g., TalosService).

func (*BaseService) SetName

func (s *BaseService) SetName(name string)

SetName sets the name of the service

func (*BaseService) SupportsWildcard

func (s *BaseService) SupportsWildcard() bool

SupportsWildcard returns whether the service supports wildcard DNS entries

func (*BaseService) WriteConfig

func (s *BaseService) WriteConfig() error

WriteConfig is a no-op for the Service interface

type DNSService

type DNSService struct {
	BaseService
	// contains filtered or unexported fields
}

DNSService handles DNS configuration

func NewDNSService

func NewDNSService(rt *runtime.Runtime) *DNSService

NewDNSService creates a new DNSService

func (*DNSService) GetComposeConfig

func (s *DNSService) GetComposeConfig() (*types.Config, error)

GetComposeConfig sets up CoreDNS with context and domain, configures ports if localhost.

func (*DNSService) SetAddress

func (s *DNSService) SetAddress(address string, portAllocator *PortAllocator) error

SetAddress updates DNS address in config and calls BaseService's SetAddress.

func (*DNSService) SetServices

func (s *DNSService) SetServices(services []Service)

SetServices sets the services list for DNS service

func (*DNSService) WriteConfig

func (s *DNSService) WriteConfig() error

WriteConfig generates and writes a CoreDNS Corefile for the Windsor project. It collects the project root directory, top-level domain (TLD), and service IP addresses. For each service, it adds DNS entries mapping hostnames to IP addresses, and includes wildcard DNS entries if supported. In localhost mode, it uses a template for local DNS resolution and sets up forwarding rules for DNS queries. The generated Corefile is saved in the .windsor directory for CoreDNS to manage project DNS queries.

type GitLivereloadService

type GitLivereloadService struct {
	BaseService
}

GitLivereloadService is a service struct that provides various utility functions

func NewGitLivereloadService

func NewGitLivereloadService(rt *runtime.Runtime) *GitLivereloadService

NewGitLivereloadService is a constructor for GitLivereloadService

func (*GitLivereloadService) GetComposeConfig

func (s *GitLivereloadService) GetComposeConfig() (*types.Config, error)

GetComposeConfig constructs and returns a docker-compose configuration for the GitLivereloadService. It retrieves configuration values for environment variables, image, and service metadata from the config handler. The method builds the environment variable map, sets up service labels, and binds the project root as a volume. Returns a types.Config pointer containing the service definition, or an error if the project root cannot be determined.

type LocalstackService

type LocalstackService struct {
	BaseService
}

LocalstackService is a service struct that provides Localstack-specific utility functions

func NewLocalstackService

func NewLocalstackService(rt *runtime.Runtime) *LocalstackService

NewLocalstackService is a constructor for LocalstackService

func (*LocalstackService) GetComposeConfig

func (s *LocalstackService) GetComposeConfig() (*types.Config, error)

GetComposeConfig returns the top-level compose configuration including a list of container data for docker-compose.

func (*LocalstackService) SupportsWildcard

func (s *LocalstackService) SupportsWildcard() bool

SupportsWildcard returns whether the service supports wildcard DNS entries

type MockService

type MockService struct {
	BaseService
	GetComposeConfigFunc func() (*types.Config, error)
	WriteConfigFunc      func() error
	SetAddressFunc       func(address string, portAllocator *PortAllocator) error
	GetAddressFunc       func() string
	SetNameFunc          func(name string)
	GetNameFunc          func() string
	GetHostnameFunc      func() string
	SupportsWildcardFunc func() bool
}

MockService is a mock implementation of the Service interface

func NewMockService

func NewMockService() *MockService

NewMockService is a constructor for MockService

func (*MockService) GetAddress

func (m *MockService) GetAddress() string

GetAddress calls the mock GetAddressFunc if it is set, otherwise returns an empty string

func (*MockService) GetComposeConfig

func (m *MockService) GetComposeConfig() (*types.Config, error)

GetComposeConfig calls the mock GetComposeConfigFunc if it is set, otherwise returns nil

func (*MockService) GetHostname

func (m *MockService) GetHostname() string

GetHostname calls the mock GetHostnameFunc if it is set, otherwise returns an empty string

func (*MockService) GetName

func (m *MockService) GetName() string

GetName calls the mock GetNameFunc if it is set, otherwise returns the stored name

func (*MockService) SetAddress

func (m *MockService) SetAddress(address string, portAllocator *PortAllocator) error

SetAddress calls the mock SetAddressFunc if it is set, otherwise returns nil

func (*MockService) SetName

func (m *MockService) SetName(name string)

SetName calls the mock SetNameFunc if it is set

func (*MockService) SupportsWildcard

func (m *MockService) SupportsWildcard() bool

SupportsWildcard calls the mock SupportsWildcardFunc if it is set, otherwise returns false

func (*MockService) WriteConfig

func (m *MockService) WriteConfig() error

WriteConfig calls the mock WriteConfigFunc if it is set, otherwise returns nil

type PortAllocator

type PortAllocator struct {
	// contains filtered or unexported fields
}

PortAllocator manages port allocation for services during network initialization. It tracks allocated ports to prevent conflicts.

func NewPortAllocator

func NewPortAllocator() *PortAllocator

NewPortAllocator creates a new PortAllocator with initial state.

func (*PortAllocator) NextAvailablePort

func (p *PortAllocator) NextAvailablePort(basePort int) int

NextAvailablePort finds the next available port starting from basePort. If basePort is already allocated, it increments until finding an available port. Returns the allocated port.

type RegistryService

type RegistryService struct {
	BaseService
	// contains filtered or unexported fields
}

RegistryService is a service struct that provides Registry-specific utility functions

func NewRegistryService

func NewRegistryService(rt *runtime.Runtime) *RegistryService

NewRegistryService is a constructor for RegistryService

func (*RegistryService) GetComposeConfig

func (s *RegistryService) GetComposeConfig() (*types.Config, error)

GetComposeConfig returns a Docker Compose configuration for the registry matching s.name. It retrieves the context configuration, finds the registry, and generates a service config. If no matching registry is found, it returns an error.

func (*RegistryService) SetAddress

func (s *RegistryService) SetAddress(address string, portAllocator *PortAllocator) error

SetAddress configures the registry's address, forms a hostname, and updates the registry config. It assigns the "registry_url" and the default host port for the first non-remote registry, storing it as "localRegistry".

type Service

type Service interface {
	GetComposeConfig() (*types.Config, error)
	WriteConfig() error
	SetAddress(address string, portAllocator *PortAllocator) error
	GetAddress() string
	SetName(name string)
	GetName() string
	SupportsWildcard() bool
	GetHostname() string
}

Service is an interface that defines methods for retrieving environment variables and can be implemented for individual providers.

type Shims

type Shims struct {
	Getwd         func() (string, error)
	Glob          func(pattern string) (matches []string, err error)
	WriteFile     func(filename string, data []byte, perm os.FileMode) error
	Stat          func(name string) (os.FileInfo, error)
	Mkdir         func(path string, perm os.FileMode) error
	MkdirAll      func(path string, perm os.FileMode) error
	RemoveAll     func(path string) error
	Rename        func(oldpath, newpath string) error
	YamlMarshal   func(in any) ([]byte, error)
	YamlUnmarshal func(in []byte, out any) error
	JsonUnmarshal func(data []byte, v any) error
	UserHomeDir   func() (string, error)
}

Shims provides mockable wrappers around system and runtime functions

func NewShims

func NewShims() *Shims

NewShims creates a new Shims instance with default implementations

type TalosService

type TalosService struct {
	BaseService
	// contains filtered or unexported fields
}

func NewTalosService

func NewTalosService(rt *runtime.Runtime, mode string) *TalosService

NewTalosService is a constructor for TalosService.

func (*TalosService) GetComposeConfig

func (s *TalosService) GetComposeConfig() (*types.Config, error)

GetComposeConfig creates a Docker Compose configuration for Talos services. It dynamically retrieves CPU and RAM settings based on whether the node is a worker or part of the control plane. The function identifies endpoint ports for service communication and ensures that all necessary volume directories are defined. It configures the container with the appropriate image (prioritizing node-specific, then group-specific, then cluster-wide, and finally default image settings), environment variables, security options, and volume mounts. The service name is constructed using the node name, and port mappings are set up, including both default and node-specific ports. The resulting configuration provides comprehensive service and volume specifications for deployment.

func (*TalosService) GetHostname

func (s *TalosService) GetHostname() string

GetHostname returns the hostname without any TLD

func (*TalosService) SetAddress

func (s *TalosService) SetAddress(address string, portAllocator *PortAllocator) error

SetAddress configures the Talos service's hostname and endpoint using the provided address. It assigns the default API port to the leader controlplane or a unique port if the address is not local. For other nodes, it assigns unique API ports starting from 50001, incrementing for each node. The portAllocator is used for port allocation if provided; otherwise falls back to global state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL