diff --git a/NOTICE b/NOTICE index 641c2d98..6c61de7f 100644 --- a/NOTICE +++ b/NOTICE @@ -95,9 +95,9 @@ License URL: https://github.com/clipperhouse/uax29/blob/v2.4.0/LICENSE ---------- Module: github.com/codesphere-cloud/cs-go/pkg/io -Version: v0.16.2 +Version: v0.16.4 License: Apache-2.0 -License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.16.2/LICENSE +License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.16.4/LICENSE ---------- Module: github.com/codesphere-cloud/oms/internal/tmpl diff --git a/cli/cmd/init_install_config.go b/cli/cmd/init_install_config.go index a0c36d49..2d9a002f 100644 --- a/cli/cmd/init_install_config.go +++ b/cli/cmd/init_install_config.go @@ -5,6 +5,7 @@ package cmd import ( "fmt" + "log" "strings" csio "github.com/codesphere-cloud/cs-go/pkg/io" @@ -189,34 +190,34 @@ func (c *InitInstallConfigCmd) InitInstallConfig(icg installer.InstallConfigMana } func (c *InitInstallConfigCmd) printWelcomeMessage() { - fmt.Println("Welcome to OMS!") - fmt.Println("This wizard will help you create config.yaml and prod.vault.yaml for Codesphere installation.") - fmt.Println() + log.Println("Welcome to OMS!") + log.Println("This wizard will help you create config.yaml and prod.vault.yaml for Codesphere installation.") + log.Println() } func (c *InitInstallConfigCmd) printSuccessMessage() { - fmt.Println("\n" + strings.Repeat("=", 70)) - fmt.Println("Configuration files successfully generated!") - fmt.Println(strings.Repeat("=", 70)) - - fmt.Println("\nIMPORTANT: Keys and certificates have been generated and embedded in the vault file.") - fmt.Println(" Keep the vault file secure and encrypt it with SOPS before storing.") - - fmt.Println("\nNext steps:") - fmt.Println("1. Review the generated config.yaml and prod.vault.yaml") - fmt.Println("2. Install SOPS and Age: brew install sops age") - fmt.Println("3. Generate an Age keypair: age-keygen -o age_key.txt") - fmt.Println("4. Encrypt the vault file:") - fmt.Printf(" age-keygen -y age_key.txt # Get public key\n") - fmt.Printf(" sops --encrypt --age --in-place %s\n", c.Opts.VaultFile) - fmt.Println("5. Run the Codesphere installer with these configuration files") - fmt.Println() + log.Println("\n" + strings.Repeat("=", 70)) + log.Println("Configuration files successfully generated!") + log.Println(strings.Repeat("=", 70)) + + log.Println("\nIMPORTANT: Keys and certificates have been generated and embedded in the vault file.") + log.Println(" Keep the vault file secure and encrypt it with SOPS before storing.") + + log.Println("\nNext steps:") + log.Println("1. Review the generated config.yaml and prod.vault.yaml") + log.Println("2. Install SOPS and Age: brew install sops age") + log.Println("3. Generate an Age keypair: age-keygen -o age_key.txt") + log.Println("4. Encrypt the vault file:") + log.Printf(" age-keygen -y age_key.txt # Get public key\n") + log.Printf(" sops --encrypt --age --in-place %s\n", c.Opts.VaultFile) + log.Println("5. Run the Codesphere installer with these configuration files") + log.Println() } func (c *InitInstallConfigCmd) validateOnly(icg installer.InstallConfigManager) error { - fmt.Printf("Validating configuration files...\n") + log.Printf("Validating configuration files...\n") - fmt.Printf("Reading install config file: %s\n", c.Opts.ConfigFile) + log.Printf("Reading install config file: %s\n", c.Opts.ConfigFile) err := icg.LoadInstallConfigFromFile(c.Opts.ConfigFile) if err != nil { return fmt.Errorf("failed to load config file: %w", err) @@ -228,7 +229,7 @@ func (c *InitInstallConfigCmd) validateOnly(icg installer.InstallConfigManager) } if c.Opts.VaultFile != "" { - fmt.Printf("Reading vault file: %s\n", c.Opts.VaultFile) + log.Printf("Reading vault file: %s\n", c.Opts.VaultFile) err := icg.LoadVaultFromFile(c.Opts.VaultFile) if err != nil { return fmt.Errorf("failed to load vault file: %w", err) @@ -240,7 +241,7 @@ func (c *InitInstallConfigCmd) validateOnly(icg installer.InstallConfigManager) } } - fmt.Println("Configuration is valid!") + log.Println("Configuration is valid!") return nil } diff --git a/cli/cmd/register.go b/cli/cmd/register.go index 85774104..a04dedb1 100644 --- a/cli/cmd/register.go +++ b/cli/cmd/register.go @@ -5,6 +5,7 @@ package cmd import ( "fmt" + "log" "time" "github.com/codesphere-cloud/cs-go/pkg/io" @@ -39,7 +40,7 @@ func (c *RegisterCmd) RunE(_ *cobra.Command, args []string) error { } if newKey != nil { - fmt.Printf("API key registered successfully!\nOwner: %s\nOrganisation: %s\nKey: %s\n", newKey.Owner, newKey.Organization, newKey.ApiKey) + log.Printf("API key registered successfully!\nOwner: %s\nOrganisation: %s\nKey: %s\n", newKey.Owner, newKey.Organization, newKey.ApiKey) } return nil diff --git a/cli/cmd/root.go b/cli/cmd/root.go index 43d08c3a..641f19b6 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -4,7 +4,6 @@ package cmd import ( - "fmt" "log" "os" @@ -31,27 +30,27 @@ func GetRootCmd() *cobra.Command { apiKey := os.Getenv("OMS_PORTAL_API_KEY") if len(apiKey) == 25 { - fmt.Fprintf(os.Stderr, "Warning: You used an old API key format.\n") - fmt.Fprintf(os.Stderr, "Attempting to upgrade to the new format...\n\n") + log.Println("Warning: You used an old API key format.") + log.Println("Attempting to upgrade to the new format...") portalClient := portal.NewPortalClient() keyId, err := portalClient.GetApiKeyId(apiKey) if err != nil { - fmt.Fprintf(os.Stderr, "Error: Failed to upgrade old API key: %v\n", err) + log.Printf("Error: Failed to upgrade old API key: %v\n", err) return } newApiKey := keyId + apiKey if err := os.Setenv("OMS_PORTAL_API_KEY", newApiKey); err != nil { - fmt.Fprintf(os.Stderr, "Error: Failed to set environment variable: %v\n", err) + log.Printf("Error: Failed to set environment variable: %v\n", err) return } opts.OmsPortalApiKey = newApiKey - fmt.Fprintf(os.Stderr, "Please update your environment variable:\n\n") - fmt.Fprintf(os.Stderr, " export OMS_PORTAL_API_KEY='%s'\n\n", newApiKey) + log.Println("Please update your environment variable:") + log.Printf(" export OMS_PORTAL_API_KEY='%s'\n\n", newApiKey) } }, } diff --git a/cli/cmd/update_install_config.go b/cli/cmd/update_install_config.go index 95f427c7..f21c86c2 100644 --- a/cli/cmd/update_install_config.go +++ b/cli/cmd/update_install_config.go @@ -125,19 +125,19 @@ func AddUpdateInstallConfigCmd(update *cobra.Command, opts *GlobalOptions) { } func (c *UpdateInstallConfigCmd) UpdateInstallConfig(icg installer.InstallConfigManager) error { - fmt.Printf("Loading existing configuration from: %s\n", c.Opts.ConfigFile) + log.Printf("Loading existing configuration from: %s\n", c.Opts.ConfigFile) err := icg.LoadInstallConfigFromFile(c.Opts.ConfigFile) if err != nil { return fmt.Errorf("failed to load config file: %w", err) } - fmt.Printf("Loading existing vault from: %s\n", c.Opts.VaultFile) + log.Printf("Loading existing vault from: %s\n", c.Opts.VaultFile) err = icg.LoadVaultFromFile(c.Opts.VaultFile) if err != nil { return fmt.Errorf("failed to load vault file: %w", err) } - fmt.Println("Merging vault secrets into configuration...") + log.Println("Merging vault secrets into configuration...") err = icg.MergeVaultIntoConfig() if err != nil { return fmt.Errorf("failed to merge vault into config: %w", err) @@ -154,12 +154,12 @@ func (c *UpdateInstallConfigCmd) UpdateInstallConfig(icg installer.InstallConfig } if tracker.HasChanges() { - fmt.Println("\nRegenerating affected secrets and certificates...") + log.Println("\nRegenerating affected secrets and certificates...") if err := c.regenerateSecrets(config, tracker); err != nil { return fmt.Errorf("failed to regenerate secrets: %w", err) } } else { - fmt.Println("\nNo changes detected that require secret regeneration.") + log.Println("\nNo changes detected that require secret regeneration.") } if err := icg.WriteInstallConfig(c.Opts.ConfigFile, c.Opts.WithComments); err != nil { @@ -180,12 +180,12 @@ func (c *UpdateInstallConfigCmd) applyUpdates(config *files.RootConfig, tracker if c.Opts.PostgresPrimaryIP != "" || c.Opts.PostgresPrimaryHostname != "" { if config.Postgres.Primary != nil { if c.Opts.PostgresPrimaryIP != "" && config.Postgres.Primary.IP != c.Opts.PostgresPrimaryIP { - fmt.Printf("Updating PostgreSQL primary IP: %s -> %s\n", config.Postgres.Primary.IP, c.Opts.PostgresPrimaryIP) + log.Printf("Updating PostgreSQL primary IP: %s -> %s\n", config.Postgres.Primary.IP, c.Opts.PostgresPrimaryIP) config.Postgres.Primary.IP = c.Opts.PostgresPrimaryIP tracker.MarkPostgresPrimaryCertNeedsRegen() } if c.Opts.PostgresPrimaryHostname != "" && config.Postgres.Primary.Hostname != c.Opts.PostgresPrimaryHostname { - fmt.Printf("Updating PostgreSQL primary hostname: %s -> %s\n", config.Postgres.Primary.Hostname, c.Opts.PostgresPrimaryHostname) + log.Printf("Updating PostgreSQL primary hostname: %s -> %s\n", config.Postgres.Primary.Hostname, c.Opts.PostgresPrimaryHostname) config.Postgres.Primary.Hostname = c.Opts.PostgresPrimaryHostname tracker.MarkPostgresPrimaryCertNeedsRegen() } @@ -195,12 +195,12 @@ func (c *UpdateInstallConfigCmd) applyUpdates(config *files.RootConfig, tracker if c.Opts.PostgresReplicaIP != "" || c.Opts.PostgresReplicaName != "" { if config.Postgres.Replica != nil { if c.Opts.PostgresReplicaIP != "" && config.Postgres.Replica.IP != c.Opts.PostgresReplicaIP { - fmt.Printf("Updating PostgreSQL replica IP: %s -> %s\n", config.Postgres.Replica.IP, c.Opts.PostgresReplicaIP) + log.Printf("Updating PostgreSQL replica IP: %s -> %s\n", config.Postgres.Replica.IP, c.Opts.PostgresReplicaIP) config.Postgres.Replica.IP = c.Opts.PostgresReplicaIP tracker.MarkPostgresReplicaCertNeedsRegen() } if c.Opts.PostgresReplicaName != "" && config.Postgres.Replica.Name != c.Opts.PostgresReplicaName { - fmt.Printf("Updating PostgreSQL replica name: %s -> %s\n", config.Postgres.Replica.Name, c.Opts.PostgresReplicaName) + log.Printf("Updating PostgreSQL replica name: %s -> %s\n", config.Postgres.Replica.Name, c.Opts.PostgresReplicaName) config.Postgres.Replica.Name = c.Opts.PostgresReplicaName tracker.MarkPostgresReplicaCertNeedsRegen() } @@ -208,76 +208,76 @@ func (c *UpdateInstallConfigCmd) applyUpdates(config *files.RootConfig, tracker } if c.Opts.PostgresServerAddress != "" && config.Postgres.ServerAddress != c.Opts.PostgresServerAddress { - fmt.Printf("Updating PostgreSQL server address: %s -> %s\n", config.Postgres.ServerAddress, c.Opts.PostgresServerAddress) + log.Printf("Updating PostgreSQL server address: %s -> %s\n", config.Postgres.ServerAddress, c.Opts.PostgresServerAddress) config.Postgres.ServerAddress = c.Opts.PostgresServerAddress } // Ceph updates if c.Opts.CephNodesSubnet != "" && config.Ceph.NodesSubnet != c.Opts.CephNodesSubnet { - fmt.Printf("Updating Ceph nodes subnet: %s -> %s\n", config.Ceph.NodesSubnet, c.Opts.CephNodesSubnet) + log.Printf("Updating Ceph nodes subnet: %s -> %s\n", config.Ceph.NodesSubnet, c.Opts.CephNodesSubnet) config.Ceph.NodesSubnet = c.Opts.CephNodesSubnet } // Kubernetes updates if c.Opts.KubernetesAPIServerHost != "" && config.Kubernetes.APIServerHost != c.Opts.KubernetesAPIServerHost { - fmt.Printf("Updating Kubernetes API server host: %s -> %s\n", config.Kubernetes.APIServerHost, c.Opts.KubernetesAPIServerHost) + log.Printf("Updating Kubernetes API server host: %s -> %s\n", config.Kubernetes.APIServerHost, c.Opts.KubernetesAPIServerHost) config.Kubernetes.APIServerHost = c.Opts.KubernetesAPIServerHost } if c.Opts.KubernetesPodCIDR != "" && config.Kubernetes.PodCIDR != c.Opts.KubernetesPodCIDR { - fmt.Printf("Updating Kubernetes Pod CIDR: %s -> %s\n", config.Kubernetes.PodCIDR, c.Opts.KubernetesPodCIDR) + log.Printf("Updating Kubernetes Pod CIDR: %s -> %s\n", config.Kubernetes.PodCIDR, c.Opts.KubernetesPodCIDR) config.Kubernetes.PodCIDR = c.Opts.KubernetesPodCIDR } if c.Opts.KubernetesServiceCIDR != "" && config.Kubernetes.ServiceCIDR != c.Opts.KubernetesServiceCIDR { - fmt.Printf("Updating Kubernetes Service CIDR: %s -> %s\n", config.Kubernetes.ServiceCIDR, c.Opts.KubernetesServiceCIDR) + log.Printf("Updating Kubernetes Service CIDR: %s -> %s\n", config.Kubernetes.ServiceCIDR, c.Opts.KubernetesServiceCIDR) config.Kubernetes.ServiceCIDR = c.Opts.KubernetesServiceCIDR } // Cluster Gateway updates if c.Opts.ClusterGatewayServiceType != "" && config.Cluster.Gateway.ServiceType != c.Opts.ClusterGatewayServiceType { - fmt.Printf("Updating cluster gateway service type: %s -> %s\n", config.Cluster.Gateway.ServiceType, c.Opts.ClusterGatewayServiceType) + log.Printf("Updating cluster gateway service type: %s -> %s\n", config.Cluster.Gateway.ServiceType, c.Opts.ClusterGatewayServiceType) config.Cluster.Gateway.ServiceType = c.Opts.ClusterGatewayServiceType } if len(c.Opts.ClusterGatewayIPAddresses) > 0 { - fmt.Printf("Updating cluster gateway IP addresses\n") + log.Printf("Updating cluster gateway IP addresses\n") config.Cluster.Gateway.IPAddresses = c.Opts.ClusterGatewayIPAddresses } if c.Opts.ClusterPublicGatewayServiceType != "" && config.Cluster.PublicGateway.ServiceType != c.Opts.ClusterPublicGatewayServiceType { - fmt.Printf("Updating cluster public gateway service type: %s -> %s\n", config.Cluster.PublicGateway.ServiceType, c.Opts.ClusterPublicGatewayServiceType) + log.Printf("Updating cluster public gateway service type: %s -> %s\n", config.Cluster.PublicGateway.ServiceType, c.Opts.ClusterPublicGatewayServiceType) config.Cluster.PublicGateway.ServiceType = c.Opts.ClusterPublicGatewayServiceType } if len(c.Opts.ClusterPublicGatewayIPAddresses) > 0 { - fmt.Printf("Updating cluster public gateway IP addresses\n") + log.Printf("Updating cluster public gateway IP addresses\n") config.Cluster.PublicGateway.IPAddresses = c.Opts.ClusterPublicGatewayIPAddresses } // Codesphere updates if c.Opts.CodesphereDomain != "" && config.Codesphere.Domain != c.Opts.CodesphereDomain { - fmt.Printf("Updating Codesphere domain: %s -> %s\n", config.Codesphere.Domain, c.Opts.CodesphereDomain) + log.Printf("Updating Codesphere domain: %s -> %s\n", config.Codesphere.Domain, c.Opts.CodesphereDomain) config.Codesphere.Domain = c.Opts.CodesphereDomain } if c.Opts.CodespherePublicIP != "" && config.Codesphere.PublicIP != c.Opts.CodespherePublicIP { - fmt.Printf("Updating Codesphere public IP: %s -> %s\n", config.Codesphere.PublicIP, c.Opts.CodespherePublicIP) + log.Printf("Updating Codesphere public IP: %s -> %s\n", config.Codesphere.PublicIP, c.Opts.CodespherePublicIP) config.Codesphere.PublicIP = c.Opts.CodespherePublicIP } if c.Opts.CodesphereWorkspaceHostingBaseDomain != "" && config.Codesphere.WorkspaceHostingBaseDomain != c.Opts.CodesphereWorkspaceHostingBaseDomain { - fmt.Printf("Updating workspace hosting base domain: %s -> %s\n", config.Codesphere.WorkspaceHostingBaseDomain, c.Opts.CodesphereWorkspaceHostingBaseDomain) + log.Printf("Updating workspace hosting base domain: %s -> %s\n", config.Codesphere.WorkspaceHostingBaseDomain, c.Opts.CodesphereWorkspaceHostingBaseDomain) config.Codesphere.WorkspaceHostingBaseDomain = c.Opts.CodesphereWorkspaceHostingBaseDomain } if c.Opts.CodesphereCustomDomainsCNameBaseDomain != "" && config.Codesphere.CustomDomains.CNameBaseDomain != c.Opts.CodesphereCustomDomainsCNameBaseDomain { - fmt.Printf("Updating custom domains CNAME base domain: %s -> %s\n", config.Codesphere.CustomDomains.CNameBaseDomain, c.Opts.CodesphereCustomDomainsCNameBaseDomain) + log.Printf("Updating custom domains CNAME base domain: %s -> %s\n", config.Codesphere.CustomDomains.CNameBaseDomain, c.Opts.CodesphereCustomDomainsCNameBaseDomain) config.Codesphere.CustomDomains.CNameBaseDomain = c.Opts.CodesphereCustomDomainsCNameBaseDomain } if len(c.Opts.CodesphereDNSServers) > 0 { - fmt.Printf("Updating DNS servers\n") + log.Printf("Updating DNS servers\n") config.Codesphere.DNSServers = c.Opts.CodesphereDNSServers } } @@ -317,23 +317,23 @@ func (c *UpdateInstallConfigCmd) regenerateSecrets(config *files.RootConfig, tra } func (c *UpdateInstallConfigCmd) printSuccessMessage(tracker *SecretDependencyTracker) { - fmt.Println("\n" + strings.Repeat("=", 70)) - fmt.Println("Configuration successfully updated!") - fmt.Println(strings.Repeat("=", 70)) + log.Println("\n" + strings.Repeat("=", 70)) + log.Println("Configuration successfully updated!") + log.Println(strings.Repeat("=", 70)) if tracker.HasChanges() { - fmt.Println("\nRegenerated secrets:") + log.Println("\nRegenerated secrets:") if tracker.NeedsPostgresPrimaryCertRegen() { - fmt.Println(" ✓ PostgreSQL primary server certificate") + log.Println(" ✓ PostgreSQL primary server certificate") } if tracker.NeedsPostgresReplicaCertRegen() { - fmt.Println(" ✓ PostgreSQL replica server certificate") + log.Println(" ✓ PostgreSQL replica server certificate") } } - fmt.Println("\nIMPORTANT: The vault file has been updated with new secrets.") - fmt.Println(" Remember to re-encrypt it with SOPS before storing.") - fmt.Println() + log.Println("\nIMPORTANT: The vault file has been updated with new secrets.") + log.Println(" Remember to re-encrypt it with SOPS before storing.") + log.Println() } type SecretDependencyTracker struct { diff --git a/internal/bootstrap/bootstrap_stepper.go b/internal/bootstrap/bootstrap_stepper.go index 2e53802a..7e05ec61 100644 --- a/internal/bootstrap/bootstrap_stepper.go +++ b/internal/bootstrap/bootstrap_stepper.go @@ -3,6 +3,8 @@ package bootstrap +// Note: In this file we need to use fmt.Print for the line reset. +// Line resets don't work with log.Print as expected. import ( "fmt" ) diff --git a/internal/installer/config_generator_collector.go b/internal/installer/config_generator_collector.go index 74dfc6de..bacab128 100644 --- a/internal/installer/config_generator_collector.go +++ b/internal/installer/config_generator_collector.go @@ -5,6 +5,7 @@ package installer import ( "fmt" + "log" "github.com/codesphere-cloud/oms/internal/installer/files" ) @@ -57,7 +58,7 @@ func stringSliceToK8sNodes(ips []string) []files.K8sNode { } func (g *InstallConfig) collectDatacenterConfig(prompter *Prompter) { - fmt.Println("=== Datacenter Configuration ===") + log.Println("=== Datacenter Configuration ===") g.Config.Datacenter.ID = g.collectInt(prompter, "Datacenter ID", g.Config.Datacenter.ID) g.Config.Datacenter.Name = g.collectString(prompter, "Datacenter name", g.Config.Datacenter.Name) g.Config.Datacenter.City = g.collectString(prompter, "Datacenter city", g.Config.Datacenter.City) @@ -66,7 +67,7 @@ func (g *InstallConfig) collectDatacenterConfig(prompter *Prompter) { } func (g *InstallConfig) collectRegistryConfig(prompter *Prompter) { - fmt.Println("\n=== Container Registry Configuration ===") + log.Println("\n=== Container Registry Configuration ===") g.Config.Registry.Server = g.collectString(prompter, "Container registry server (e.g., ghcr.io, leave empty to skip)", "") if g.Config.Registry.Server != "" { g.Config.Registry.ReplaceImagesInBom = prompter.Bool("Replace images in BOM", g.Config.Registry.ReplaceImagesInBom) @@ -75,7 +76,7 @@ func (g *InstallConfig) collectRegistryConfig(prompter *Prompter) { } func (g *InstallConfig) collectPostgresConfig(prompter *Prompter) { - fmt.Println("\n=== PostgreSQL Configuration ===") + log.Println("\n=== PostgreSQL Configuration ===") g.Config.Postgres.Mode = g.collectChoice(prompter, "PostgreSQL setup", []string{"install", "external"}, "install") if g.Config.Postgres.Mode == "install" { @@ -109,14 +110,14 @@ func (g *InstallConfig) collectPostgresConfig(prompter *Prompter) { } func (g *InstallConfig) collectCephConfig(prompter *Prompter) { - fmt.Println("\n=== Ceph Configuration ===") + log.Println("\n=== Ceph Configuration ===") g.Config.Ceph.NodesSubnet = g.collectString(prompter, "Ceph nodes subnet (CIDR)", "10.53.101.0/24") if len(g.Config.Ceph.Hosts) == 0 { numHosts := prompter.Int("Number of Ceph hosts", 3) g.Config.Ceph.Hosts = make([]files.CephHost, numHosts) for i := 0; i < numHosts; i++ { - fmt.Printf("\nCeph Host %d:\n", i+1) + log.Printf("\nCeph Host %d:\n", i+1) g.Config.Ceph.Hosts[i].Hostname = prompter.String(" Hostname (as shown by 'hostname' command)", fmt.Sprintf("ceph-node-%d", i)) g.Config.Ceph.Hosts[i].IPAddress = prompter.String(" IP address", fmt.Sprintf("10.53.101.%d", i+2)) g.Config.Ceph.Hosts[i].IsMaster = (i == 0) @@ -131,7 +132,7 @@ func (g *InstallConfig) collectCephConfig(prompter *Prompter) { } func (g *InstallConfig) collectK8sConfig(prompter *Prompter) { - fmt.Println("\n=== Kubernetes Configuration ===") + log.Println("\n=== Kubernetes Configuration ===") g.Config.Kubernetes.ManagedByCodesphere = prompter.Bool("Use Codesphere-managed Kubernetes (k0s)", g.Config.Kubernetes.ManagedByCodesphere) if g.Config.Kubernetes.ManagedByCodesphere { @@ -157,12 +158,12 @@ func (g *InstallConfig) collectK8sConfig(prompter *Prompter) { g.Config.Kubernetes.PodCIDR = g.collectString(prompter, "Pod CIDR of external cluster", "100.96.0.0/11") g.Config.Kubernetes.ServiceCIDR = g.collectString(prompter, "Service CIDR of external cluster", "100.64.0.0/13") g.Config.Kubernetes.NeedsKubeConfig = true - fmt.Println("Note: You'll need to provide kubeconfig in the vault file for external Kubernetes") + log.Println("Note: You'll need to provide kubeconfig in the vault file for external Kubernetes") } } func (g *InstallConfig) collectGatewayConfig(prompter *Prompter) { - fmt.Println("\n=== Cluster Gateway Configuration ===") + log.Println("\n=== Cluster Gateway Configuration ===") g.Config.Cluster.Gateway.ServiceType = g.collectChoice(prompter, "Gateway service type", []string{"LoadBalancer", "ExternalIP"}, "LoadBalancer") if g.Config.Cluster.Gateway.ServiceType == "ExternalIP" { g.Config.Cluster.Gateway.IPAddresses = g.collectStringSlice(prompter, "Gateway IP addresses (comma-separated)", []string{"10.51.0.2", "10.51.0.3"}) @@ -175,7 +176,7 @@ func (g *InstallConfig) collectGatewayConfig(prompter *Prompter) { } func (g *InstallConfig) collectMetalLBConfig(prompter *Prompter) { - fmt.Println("\n=== MetalLB Configuration (Optional) ===") + log.Println("\n=== MetalLB Configuration (Optional) ===") g.Config.MetalLB.Enabled = prompter.Bool("Enable MetalLB", g.Config.MetalLB.Enabled) @@ -188,7 +189,7 @@ func (g *InstallConfig) collectMetalLBConfig(prompter *Prompter) { g.Config.MetalLB.Pools = make([]files.MetalLBPoolDef, numPools) for i := 0; i < numPools; i++ { - fmt.Printf("\nMetalLB Pool %d:\n", i+1) + log.Printf("\nMetalLB Pool %d:\n", i+1) defaultName := fmt.Sprintf("pool-%d", i+1) var defaultIPs []string @@ -211,7 +212,7 @@ func (g *InstallConfig) collectMetalLBConfig(prompter *Prompter) { } func (g *InstallConfig) collectCodesphereConfig(prompter *Prompter) { - fmt.Println("\n=== Codesphere Application Configuration ===") + log.Println("\n=== Codesphere Application Configuration ===") defaultDomain := g.Config.Codesphere.Domain if defaultDomain == "" { defaultDomain = "codesphere.yourcompany.com" @@ -234,7 +235,7 @@ func (g *InstallConfig) collectCodesphereConfig(prompter *Prompter) { g.Config.Codesphere.CustomDomains.CNameBaseDomain = g.collectString(prompter, "Custom domain CNAME base", defaultCustomDomain) g.Config.Codesphere.DNSServers = g.collectStringSlice(prompter, "DNS servers (comma-separated)", defaultDNSServers) - fmt.Println("\n=== Workspace Plans Configuration ===") + log.Println("\n=== Workspace Plans Configuration ===") if g.Config.Codesphere.WorkspaceImages == nil { g.Config.Codesphere.WorkspaceImages = &files.WorkspaceImagesConfig{} diff --git a/internal/installer/prompt.go b/internal/installer/prompt.go index 91d44103..31d360d1 100644 --- a/internal/installer/prompt.go +++ b/internal/installer/prompt.go @@ -5,7 +5,7 @@ package installer import ( "bufio" - "fmt" + "log" "os" "strconv" "strings" @@ -29,9 +29,9 @@ func (p *Prompter) String(prompt, defaultValue string) string { } if defaultValue != "" { - fmt.Printf("%s (default: %s): ", prompt, defaultValue) + log.Printf("%s (default: %s): ", prompt, defaultValue) } else { - fmt.Printf("%s: ", prompt) + log.Printf("%s: ", prompt) } input, _ := p.reader.ReadString('\n') @@ -48,7 +48,7 @@ func (p *Prompter) Int(prompt string, defaultValue int) int { return defaultValue } - fmt.Printf("%s (default: %d): ", prompt, defaultValue) + log.Printf("%s (default: %d): ", prompt, defaultValue) input, _ := p.reader.ReadString('\n') input = strings.TrimSpace(input) @@ -59,7 +59,7 @@ func (p *Prompter) Int(prompt string, defaultValue int) int { value, err := strconv.Atoi(input) if err != nil { - fmt.Printf("Invalid number, using default: %d\n", defaultValue) + log.Printf("Invalid number, using default: %d\n", defaultValue) return defaultValue } return value @@ -72,9 +72,9 @@ func (p *Prompter) StringSlice(prompt string, defaultValue []string) []string { defaultStr := strings.Join(defaultValue, ", ") if defaultStr != "" { - fmt.Printf("%s (default: %s): ", prompt, defaultStr) + log.Printf("%s (default: %s): ", prompt, defaultStr) } else { - fmt.Printf("%s: ", prompt) + log.Printf("%s: ", prompt) } input, _ := p.reader.ReadString('\n') @@ -108,7 +108,7 @@ func (p *Prompter) Bool(prompt string, defaultValue bool) bool { if defaultValue { defaultStr = "y" } - fmt.Printf("%s (y/n, default: %s): ", prompt, defaultStr) + log.Printf("%s (y/n, default: %s): ", prompt, defaultStr) input, _ := p.reader.ReadString('\n') input = strings.TrimSpace(strings.ToLower(input)) @@ -125,7 +125,7 @@ func (p *Prompter) Choice(prompt string, choices []string, defaultValue string) return defaultValue } - fmt.Printf("%s [%s] (default: %s): ", prompt, strings.Join(choices, "/"), defaultValue) + log.Printf("%s [%s] (default: %s): ", prompt, strings.Join(choices, "/"), defaultValue) input, _ := p.reader.ReadString('\n') input = strings.TrimSpace(strings.ToLower(input)) @@ -140,6 +140,6 @@ func (p *Prompter) Choice(prompt string, choices []string, defaultValue string) } } - fmt.Printf("Invalid choice, using default: %s\n", defaultValue) + log.Printf("Invalid choice, using default: %s\n", defaultValue) return defaultValue } diff --git a/internal/portal/portal_test.go b/internal/portal/portal_test.go index 7788b763..bff31b84 100644 --- a/internal/portal/portal_test.go +++ b/internal/portal/portal_test.go @@ -11,6 +11,7 @@ import ( "errors" "fmt" "io" + "log" "net/http" "net/url" "os" @@ -280,7 +281,7 @@ var _ = Describe("PortalClient", func() { }, } - fmt.Printf("%s", testfile.Name()) + log.Printf("%s", testfile.Name()) // Close the file before using it for verification err := testfile.Close() diff --git a/internal/tmpl/NOTICE b/internal/tmpl/NOTICE index 641c2d98..6c61de7f 100644 --- a/internal/tmpl/NOTICE +++ b/internal/tmpl/NOTICE @@ -95,9 +95,9 @@ License URL: https://github.com/clipperhouse/uax29/blob/v2.4.0/LICENSE ---------- Module: github.com/codesphere-cloud/cs-go/pkg/io -Version: v0.16.2 +Version: v0.16.4 License: Apache-2.0 -License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.16.2/LICENSE +License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.16.4/LICENSE ---------- Module: github.com/codesphere-cloud/oms/internal/tmpl