112 lines
3.9 KiB
Go
112 lines
3.9 KiB
Go
package config
|
|
|
|
import "net/url"
|
|
|
|
type Config struct {
|
|
WorkspaceDir string `yaml:"workspaceDir"`
|
|
Git GitConfig `yaml:"git"`
|
|
Flux FluxConfig `yaml:"flux"`
|
|
Talos TalosConfig `yaml:"talos"`
|
|
Templates TemplateConfig `yaml:"templates"`
|
|
}
|
|
|
|
type GitConfig struct {
|
|
Provider string `yaml:"provider"`
|
|
BaseURL string `yaml:"baseUrl"`
|
|
Username string `yaml:"username"`
|
|
Token string `yaml:"token"`
|
|
Owner string `yaml:"owner"`
|
|
UseSSH bool `yaml:"useSsh"`
|
|
SSHKeyPath string `yaml:"sshKeyPath,omitempty"`
|
|
CloneParent string `yaml:"cloneParent"`
|
|
}
|
|
|
|
type FluxConfig struct {
|
|
RepoName string `yaml:"repoName"`
|
|
Branch string `yaml:"branch"`
|
|
ClusterPath string `yaml:"clusterPath"`
|
|
ClusterDomain string `yaml:"clusterDomain"`
|
|
ManifestsRepo string `yaml:"manifestsRepo"`
|
|
}
|
|
|
|
type TemplateConfig struct {
|
|
TalosRepoURL string `yaml:"talosRepoUrl"`
|
|
TalosRepoRef string `yaml:"talosRepoRef"`
|
|
}
|
|
|
|
type TalosConfig struct {
|
|
RepoDirName string `yaml:"repoDirName"`
|
|
TerraformDir string `yaml:"terraformDir"`
|
|
GeneratedDir string `yaml:"generatedDir"`
|
|
ConfigFileName string `yaml:"configFileName"`
|
|
AutoRunTerraform bool `yaml:"autoRunTerraform"`
|
|
AutoBootstrap bool `yaml:"autoBootstrap"`
|
|
AutoBootstrapFlux bool `yaml:"autoBootstrapFlux"`
|
|
BootstrapNode string `yaml:"bootstrapNode"`
|
|
BootstrapEndpoint string `yaml:"bootstrapEndpoint"`
|
|
KubeconfigNode string `yaml:"kubeconfigNode"`
|
|
KubeconfigEndpoint string `yaml:"kubeconfigEndpoint"`
|
|
Proxmox TalosProxmoxConfig `yaml:"proxmox"`
|
|
Cluster TalosClusterConfig `yaml:"cluster"`
|
|
Image TalosImageConfig `yaml:"image"`
|
|
Nodes []TalosNode `yaml:"nodes"`
|
|
}
|
|
|
|
type TalosProxmoxConfig struct {
|
|
APIURL string `yaml:"apiUrl"`
|
|
APITokenID string `yaml:"apiTokenId"`
|
|
APITokenSecret string `yaml:"apiTokenSecret"`
|
|
DefaultNode string `yaml:"defaultNode"`
|
|
Pool string `yaml:"pool"`
|
|
NodeInterfaces map[string]string `yaml:"nodeInterfaces"`
|
|
NodeAddresses map[string]string `yaml:"nodeAddresses"`
|
|
Insecure bool `yaml:"insecure"`
|
|
}
|
|
|
|
type TalosClusterConfig struct {
|
|
Name string `yaml:"name"`
|
|
Domain string `yaml:"domain"`
|
|
ControlPlaneVIP string `yaml:"controlPlaneVip"`
|
|
DNSServers []string `yaml:"dnsServers"`
|
|
DiskStorage string `yaml:"diskStorage"`
|
|
AdditionalStorage string `yaml:"additionalStorage"`
|
|
CreateVLANInterface bool `yaml:"createVlanInterface"`
|
|
}
|
|
|
|
type TalosImageConfig struct {
|
|
TalosVersion string `yaml:"talosVersion"`
|
|
SchematicID string `yaml:"schematicId"`
|
|
UpdateMode string `yaml:"updateMode"`
|
|
Storage string `yaml:"storage"`
|
|
Architecture string `yaml:"architecture"`
|
|
}
|
|
|
|
type TalosNode struct {
|
|
Name string `yaml:"name"`
|
|
VMID int `yaml:"vmid"`
|
|
Role string `yaml:"role"`
|
|
Cores int `yaml:"cores"`
|
|
Memory int `yaml:"memory"`
|
|
DiskSize string `yaml:"diskSize"`
|
|
AdditionalDiskSize string `yaml:"additionalDiskSize,omitempty"`
|
|
Tags []string `yaml:"tags"`
|
|
ProxmoxNode string `yaml:"proxmoxNode"`
|
|
Networks []TalosNetwork `yaml:"networks"`
|
|
}
|
|
|
|
type TalosNetwork struct {
|
|
MACAddress string `yaml:"macAddress"`
|
|
CIDR string `yaml:"cidr"`
|
|
IP string `yaml:"ip,omitempty"`
|
|
Gateway string `yaml:"gateway,omitempty"`
|
|
VLANID int `yaml:"vlanId"`
|
|
}
|
|
|
|
func (c TalosProxmoxConfig) APIURLHost() string {
|
|
parsed, err := url.Parse(c.APIURL)
|
|
if err != nil || parsed.Hostname() == "" {
|
|
return "192.168.0.15"
|
|
}
|
|
return parsed.Hostname()
|
|
}
|