187 lines
7.3 KiB
Go
187 lines
7.3 KiB
Go
package config
|
|
|
|
import "net/url"
|
|
|
|
type Config struct {
|
|
ClusterID string `yaml:"clusterId"`
|
|
WorkspaceDir string `yaml:"workspaceDir"`
|
|
Git GitConfig `yaml:"git"`
|
|
Flux FluxConfig `yaml:"flux"`
|
|
Talos TalosConfig `yaml:"talos"`
|
|
Templates TemplateConfig `yaml:"templates"`
|
|
Cilium CiliumConfig `yaml:"cilium"`
|
|
DemocraticCSI DemocraticCSIConfig `yaml:"democraticCsi"`
|
|
Delivery DeliveryConfig `yaml:"delivery"`
|
|
SecretGrants []SecretGrant `yaml:"secretGrants,omitempty"`
|
|
SOPS SOPSConfig `yaml:"sops"`
|
|
}
|
|
|
|
// SecretGrant gives one application consumer access to named application and
|
|
// shared OpenBao paths. It contains references, never values.
|
|
type SecretGrant struct {
|
|
Application string `yaml:"application"`
|
|
Consumer string `yaml:"consumer"`
|
|
Environment string `yaml:"environment,omitempty"`
|
|
Secrets []string `yaml:"secrets"`
|
|
Shared []string `yaml:"shared,omitempty"`
|
|
}
|
|
|
|
type DemocraticCSIConfig struct {
|
|
TrueNASAPIKey string `yaml:"truenasApiKey"`
|
|
TrueNASHost string `yaml:"truenasHost"`
|
|
TargetPortal string `yaml:"targetPortal"`
|
|
ShareHost string `yaml:"shareHost"`
|
|
DatasetParentNFS string `yaml:"datasetParentNfs"`
|
|
DatasetSnapshotsNFS string `yaml:"datasetSnapshotsNfs"`
|
|
AllowedNetworks string `yaml:"allowedNetworks"`
|
|
NameSuffix string `yaml:"nameSuffix"`
|
|
PortalGroup string `yaml:"portalGroup"`
|
|
InitiatorGroup string `yaml:"initiatorGroup"`
|
|
}
|
|
|
|
type DeliveryConfig struct {
|
|
AppName string `yaml:"appName"`
|
|
AppRepoURL string `yaml:"appRepoUrl"`
|
|
AppRepoRef string `yaml:"appRepoRef"`
|
|
ProductionBranch string `yaml:"productionBranch"`
|
|
ImageRepository string `yaml:"imageRepository"`
|
|
BuildOutputDirectory string `yaml:"buildOutputDirectory"`
|
|
BuildConfiguration string `yaml:"buildConfiguration"`
|
|
TektonDashboardURL string `yaml:"tektonDashboardUrl,omitempty"`
|
|
WebhookHostname string `yaml:"webhookHostname"`
|
|
WebhookPath string `yaml:"webhookPath"`
|
|
}
|
|
|
|
// Configured reports whether the app-delivery rendering contract is complete.
|
|
func (c DeliveryConfig) Configured() bool {
|
|
return c.AppName != "" && c.AppRepoURL != "" && c.AppRepoRef != "" && c.ProductionBranch != "" && c.ImageRepository != "" && c.BuildOutputDirectory != "" && c.BuildConfiguration != "" && c.WebhookHostname != "" && c.WebhookPath != ""
|
|
}
|
|
|
|
func (c DeliveryConfig) WebhookURL() string {
|
|
return (&url.URL{Scheme: "https", Host: c.WebhookHostname, Path: c.WebhookPath}).String()
|
|
}
|
|
|
|
type SOPSConfig struct {
|
|
AgeKeyPath string `yaml:"ageKeyPath"`
|
|
BootstrapSecretsPath string `yaml:"bootstrapSecretsPath,omitempty"`
|
|
OperationalSecretsPath string `yaml:"operationalSecretsPath"`
|
|
RecoveryRecipient string `yaml:"recoveryRecipient"`
|
|
RecoveryIdentityPath string `yaml:"recoveryIdentityPath"`
|
|
RecoveryBundlePath string `yaml:"recoveryBundlePath"`
|
|
}
|
|
|
|
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"`
|
|
TektonCatalogRepo string `yaml:"tektonCatalogRepo"`
|
|
}
|
|
|
|
type TemplateConfig struct {
|
|
TalosRepoURL string `yaml:"talosRepoUrl"`
|
|
TalosRepoRef string `yaml:"talosRepoRef"`
|
|
CICDRepoURL string `yaml:"cicdRepoUrl"`
|
|
CICDRepoRef string `yaml:"cicdRepoRef"`
|
|
ManifestsRepoURL string `yaml:"manifestsRepoUrl"`
|
|
ManifestsRepoRef string `yaml:"manifestsRepoRef"`
|
|
TektonCatalogRepoURL string `yaml:"tektonCatalogRepoUrl"`
|
|
TektonCatalogRepoRef string `yaml:"tektonCatalogRepoRef"`
|
|
}
|
|
|
|
type CiliumConfig struct {
|
|
TrafficInterface string `yaml:"trafficInterface"`
|
|
LoadBalancerStart string `yaml:"loadBalancerStart"`
|
|
LoadBalancerEnd string `yaml:"loadBalancerEnd"`
|
|
}
|
|
|
|
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"`
|
|
ManageNetworkBridges bool `yaml:"manageNetworkBridges"`
|
|
}
|
|
|
|
type TalosImageConfig struct {
|
|
TalosVersion string `yaml:"talosVersion"`
|
|
KubernetesVersion string `yaml:"kubernetesVersion"`
|
|
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()
|
|
}
|