services

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 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 (*BaseService) GetAddress

func (s *BaseService) GetAddress() string

GetAddress returns the current address of the service

func (*BaseService) GetHostname added in v0.3.0

func (s *BaseService) GetHostname() string

GetHostname returns the name plus the tld from the config

func (*BaseService) GetName

func (s *BaseService) GetName() string

GetName returns the current name of the service

func (*BaseService) Initialize

func (s *BaseService) Initialize() error

Initialize resolves and assigns configHandler and shell dependencies using the injector.

func (*BaseService) IsLocalhost added in v0.4.0

func (s *BaseService) IsLocalhost() bool

IsLocalhost checks if the current address is a localhost address

func (*BaseService) SetAddress

func (s *BaseService) SetAddress(address string) error

SetAddress sets the address if it is a valid IPv4 address

func (*BaseService) SetName

func (s *BaseService) SetName(name string)

SetName sets the name of the service

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(injector di.Injector) *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) Initialize

func (s *DNSService) Initialize() error

Initialize sets up DNSService by resolving dependencies via DI.

func (*DNSService) SetAddress

func (s *DNSService) SetAddress(address string) error

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

func (*DNSService) WriteConfig

func (s *DNSService) WriteConfig() error

WriteConfig generates a Corefile for DNS configuration by gathering project root, TLD, and service IPs, constructing DNS host entries, and appending static DNS records. It adapts the Corefile for localhost by adding a template for local DNS resolution. Additionally, it configures DNS forwarding by including specified forward addresses, ensuring DNS queries are directed appropriately. The final Corefile is written to the .windsor config directory

type GitLivereloadService

type GitLivereloadService struct {
	BaseService
}

GitLivereloadService is a service struct that provides various utility functions

func NewGitLivereloadService

func NewGitLivereloadService(injector di.Injector) *GitLivereloadService

NewGitLivereloadService is a constructor for GitLivereloadService

func (*GitLivereloadService) GetComposeConfig

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

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

type LocalstackService

type LocalstackService struct {
	BaseService
}

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

func NewLocalstackService

func NewLocalstackService(injector di.Injector) *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.

type MockService

type MockService struct {
	BaseService
	// GetComposeConfigFunc is a function that mocks the GetComposeConfig method
	GetComposeConfigFunc func() (*types.Config, error)
	// WriteConfigFunc is a function that mocks the WriteConfig method
	WriteConfigFunc func() error
	// SetAddressFunc is a function that mocks the SetAddress method
	SetAddressFunc func(address string) error
	// GetAddressFunc is a function that mocks the GetAddress method
	GetAddressFunc func() string
	// InitializeFunc is a function that mocks the Initialize method
	InitializeFunc func() error
	// SetNameFunc is a function that mocks the SetName method
	SetNameFunc func(name string)
	// GetNameFunc is a function that mocks the GetName method
	GetNameFunc func() string
	// GetHostnameFunc is a function that mocks the GetHostname method
	GetHostnameFunc func() string
}

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 added in v0.3.0

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 an empty string

func (*MockService) Initialize

func (m *MockService) Initialize() error

Initialize calls the mock InitializeFunc if it is set, otherwise returns nil

func (*MockService) SetAddress

func (m *MockService) SetAddress(address string) 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) WriteConfig

func (m *MockService) WriteConfig() error

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

type RegistryService

type RegistryService struct {
	BaseService
	HostPort int // If set, this port is routed to the registry port from the host
}

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

func NewRegistryService

func NewRegistryService(injector di.Injector) *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) GetHostname added in v0.3.0

func (s *RegistryService) GetHostname() string

GetHostname returns the hostname of the registry service. This is constructed by removing the existing domain from the name and appending the configured domain.

func (*RegistryService) SetAddress

func (s *RegistryService) SetAddress(address string) error

SetAddress configures the registry's address, forms a hostname, and updates the registry config. It selects a port by checking the registry's HostPort; if unset and on localhost, it defaults to REGISTRY_DEFAULT_HOST_PORT. The port's availability is verified before assignment. If the registry is not a proxy ("remote" is not set), and it is localhost, it attempts to set HostPort to the default registry port.

type Service

type Service interface {
	// GetComposeConfig returns the top-level compose configuration including a list of container data for docker-compose.
	GetComposeConfig() (*types.Config, error)

	// WriteConfig writes any necessary configuration files needed by the service
	WriteConfig() error

	// SetAddress sets the address if it is a valid IPv4 address
	SetAddress(address string) error

	// GetAddress returns the current address of the service
	GetAddress() string

	// SetName sets the name of the service
	SetName(name string)

	// GetName returns the current name of the service
	GetName() string

	// Initialize performs any necessary initialization for the service.
	Initialize() error

	// GetHostname returns the name plus the tld from the config
	GetHostname() string

	// IsLocalhost checks if the current address is a localhost address
	IsLocalhost() bool
}

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

type TalosService added in v0.4.0

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

func NewTalosService added in v0.4.0

func NewTalosService(injector di.Injector, mode string) *TalosService

NewTalosService is a constructor for TalosService

func (*TalosService) GetComposeConfig added in v0.4.0

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 latest image, 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, ensuring compatibility with the docker-compose.yml file.

func (*TalosService) SetAddress added in v0.4.0

func (s *TalosService) SetAddress(address string) 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. A mutex is used to safely manage concurrent access to the port allocation. Node ports are configured based on the cluster configuration, ensuring no conflicts.

Jump to

Keyboard shortcuts

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