{"modulePath":"github.com/windsorcli/cli","version":"v0.7.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package services\n\n## Types\n\n```go\ntype BaseService struct {\n\t// contains filtered or unexported fields\n}\n```\nBaseService is a base implementation of the Service interface\n\n```go\nfunc NewBaseService(injector di.Injector) *BaseService\n```\nNewBaseService is a constructor for BaseService\n\n```go\nfunc (s *BaseService) GetAddress() string\n```\nGetAddress returns the current address of the service\n\n```go\nfunc (s *BaseService) GetContainerName() string\n```\nGetContainerName returns the container name with the DNS domain\n\n```go\nfunc (s *BaseService) GetHostname() string\n```\nGetHostname returns the hostname for the service, handling domain names specially\n\n```go\nfunc (s *BaseService) GetName() string\n```\nGetName returns the current name of the service\n\n```go\nfunc (s *BaseService) Initialize() error\n```\n\n```go\nfunc (s *BaseService) SetAddress(address string) error\n```\nSetAddress sets the address if it is a valid IPv4 address\n\n```go\nfunc (s *BaseService) SetName(name string)\n```\nSetName sets the name of the service\n\n```go\nfunc (s *BaseService) SupportsWildcard() bool\n```\nSupportsWildcard returns whether the service supports wildcard DNS entries\n\n```go\nfunc (s *BaseService) WriteConfig() error\n```\nWriteConfig is a no-op for the Service interface\n\n```go\ntype DNSService struct {\n\tBaseService\n\t// contains filtered or unexported fields\n}\n```\nDNSService handles DNS configuration\n\n```go\nfunc NewDNSService(injector di.Injector) *DNSService\n```\nNewDNSService creates a new DNSService\n\n```go\nfunc (s *DNSService) GetComposeConfig() (*types.Config, error)\n```\nGetComposeConfig sets up CoreDNS with context and domain, configures ports if localhost.\n\n```go\nfunc (s *DNSService) Initialize() error\n```\nInitialize sets up DNSService by resolving dependencies via DI.\n\n```go\nfunc (s *DNSService) SetAddress(address string) error\n```\nSetAddress updates DNS address in config and calls BaseService's SetAddress.\n\n```go\nfunc (s *DNSService) WriteConfig() error\n```\nWriteConfig 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.\n\n```go\ntype GitLivereloadService struct {\n\tBaseService\n}\n```\nGitLivereloadService is a service struct that provides various utility functions\n\n```go\nfunc NewGitLivereloadService(injector di.Injector) *GitLivereloadService\n```\nNewGitLivereloadService is a constructor for GitLivereloadService\n\n```go\nfunc (s *GitLivereloadService) GetComposeConfig() (*types.Config, error)\n```\nGetComposeConfig 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.\n\n```go\ntype LocalstackService struct {\n\tBaseService\n}\n```\nLocalstackService is a service struct that provides Localstack-specific utility functions\n\n```go\nfunc NewLocalstackService(injector di.Injector) *LocalstackService\n```\nNewLocalstackService is a constructor for LocalstackService\n\n```go\nfunc (s *LocalstackService) GetComposeConfig() (*types.Config, error)\n```\nGetComposeConfig returns the top-level compose configuration including a list of container data for docker-compose.\n\n```go\nfunc (s *LocalstackService) SupportsWildcard() bool\n```\nSupportsWildcard returns whether the service supports wildcard DNS entries\n\n```go\ntype MockService struct {\n\tBaseService\n\tGetComposeConfigFunc func() (*types.Config, error)\n\tWriteConfigFunc      func() error\n\tSetAddressFunc       func(address string) error\n\tGetAddressFunc       func() string\n\tInitializeFunc       func() error\n\tSetNameFunc          func(name string)\n\tGetNameFunc          func() string\n\tGetHostnameFunc      func() string\n\tSupportsWildcardFunc func() bool\n}\n```\nMockService is a mock implementation of the Service interface\n\n```go\nfunc NewMockService() *MockService\n```\nNewMockService is a constructor for MockService\n\n```go\nfunc (m *MockService) GetAddress() string\n```\nGetAddress calls the mock GetAddressFunc if it is set, otherwise returns an empty string\n\n```go\nfunc (m *MockService) GetComposeConfig() (*types.Config, error)\n```\nGetComposeConfig calls the mock GetComposeConfigFunc if it is set, otherwise returns nil\n\n```go\nfunc (m *MockService) GetHostname() string\n```\nGetHostname calls the mock GetHostnameFunc if it is set, otherwise returns an empty string\n\n```go\nfunc (m *MockService) GetName() string\n```\nGetName calls the mock GetNameFunc if it is set, otherwise returns the stored name\n\n```go\nfunc (m *MockService) Initialize() error\n```\nInitialize calls the mock InitializeFunc if it is set, otherwise returns nil\n\n```go\nfunc (m *MockService) SetAddress(address string) error\n```\nSetAddress calls the mock SetAddressFunc if it is set, otherwise returns nil\n\n```go\nfunc (m *MockService) SetName(name string)\n```\nSetName calls the mock SetNameFunc if it is set\n\n```go\nfunc (m *MockService) SupportsWildcard() bool\n```\nSupportsWildcard calls the mock SupportsWildcardFunc if it is set, otherwise returns false\n\n```go\nfunc (m *MockService) WriteConfig() error\n```\nWriteConfig calls the mock WriteConfigFunc if it is set, otherwise returns nil\n\n```go\ntype RegistryService struct {\n\tBaseService\n\t// contains filtered or unexported fields\n}\n```\nRegistryService is a service struct that provides Registry-specific utility functions\n\n```go\nfunc NewRegistryService(injector di.Injector) *RegistryService\n```\nNewRegistryService is a constructor for RegistryService\n\n```go\nfunc (s *RegistryService) GetComposeConfig() (*types.Config, error)\n```\nGetComposeConfig 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.\n\n```go\nfunc (s *RegistryService) SetAddress(address string) error\n```\nSetAddress 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\".\n\n```go\ntype Service interface {\n\tGetComposeConfig() (*types.Config, error)\n\tWriteConfig() error\n\tSetAddress(address string) error\n\tGetAddress() string\n\tSetName(name string)\n\tGetName() string\n\tInitialize() error\n\tSupportsWildcard() bool\n\tGetHostname() string\n}\n```\nService is an interface that defines methods for retrieving environment variables and can be implemented for individual providers.\n\n```go\ntype Shims struct {\n\tGetwd         func() (string, error)\n\tGlob          func(pattern string) (matches []string, err error)\n\tWriteFile     func(filename string, data []byte, perm os.FileMode) error\n\tStat          func(name string) (os.FileInfo, error)\n\tMkdir         func(path string, perm os.FileMode) error\n\tMkdirAll      func(path string, perm os.FileMode) error\n\tRemoveAll     func(path string) error\n\tRename        func(oldpath, newpath string) error\n\tYamlMarshal   func(in any) ([]byte, error)\n\tYamlUnmarshal func(in []byte, out any) error\n\tJsonUnmarshal func(data []byte, v any) error\n\tUserHomeDir   func() (string, error)\n}\n```\nShims provides mockable wrappers around system and runtime functions\n\n```go\nfunc NewShims() *Shims\n```\nNewShims creates a new Shims instance with default implementations\n\n```go\ntype TalosService struct {\n\tBaseService\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewTalosService(injector di.Injector, mode string) *TalosService\n```\nNewTalosService is a constructor for TalosService\n\n```go\nfunc (s *TalosService) GetComposeConfig() (*types.Config, error)\n```\nGetComposeConfig 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.\n\n```go\nfunc (s *TalosService) GetHostname() string\n```\nGetHostname returns the hostname without any TLD\n\n```go\nfunc (s *TalosService) SetAddress(address string) error\n```\nSetAddress 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.\n\n","path":"github.com/windsorcli/cli/pkg/services","name":"services","synopsis":"","isRedistributable":true}
