From 378dff85b1a367b7ce190f3e5efa485f407e61ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Fern=C3=A1ndez?= Date: Fri, 22 Dec 2023 11:45:56 -0500 Subject: [PATCH] feat: subdomain flag for cloudflare (#1976) --- cmd/aws/command.go | 2 ++ cmd/civo/command.go | 2 ++ cmd/digitalocean/command.go | 2 ++ cmd/google/command.go | 2 ++ cmd/vultr/command.go | 2 ++ internal/launch/constants.go | 2 +- internal/types/flags.go | 1 + internal/utilities/flags.go | 7 +++++++ internal/utilities/utilities.go | 1 + 9 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cmd/aws/command.go b/cmd/aws/command.go index f3fb6b092..0ecad9d26 100644 --- a/cmd/aws/command.go +++ b/cmd/aws/command.go @@ -30,6 +30,7 @@ var ( gitopsTemplateURLFlag string gitopsTemplateBranchFlag string domainNameFlag string + subdomainNameFlag string useTelemetryFlag bool ecrFlag bool nodeTypeFlag string @@ -88,6 +89,7 @@ func Create() *cobra.Command { createCmd.Flags().StringVar(&nodeCountFlag, "node-count", awsDefaults.NodeCount, "the node count for the cluster") createCmd.Flags().StringVar(&nodeTypeFlag, "node-type", awsDefaults.InstanceSize, "the instance size of the cluster to create") createCmd.Flags().StringVar(&dnsProviderFlag, "dns-provider", "aws", fmt.Sprintf("the dns provider - one of: %s", supportedDNSProviders)) + createCmd.Flags().StringVar(&subdomainNameFlag, "subdomain", "", "the subdomain to use for DNS records (Cloudflare)") createCmd.Flags().StringVar(&domainNameFlag, "domain-name", "", "the Route53/Cloudflare hosted zone name to use for DNS records (i.e. your-domain.com|subdomain.your-domain.com) (required)") createCmd.MarkFlagRequired("domain-name") createCmd.Flags().StringVar(&gitProviderFlag, "git-provider", "github", fmt.Sprintf("the git provider - one of: %s", supportedGitProviders)) diff --git a/cmd/civo/command.go b/cmd/civo/command.go index e463e6899..572977e26 100644 --- a/cmd/civo/command.go +++ b/cmd/civo/command.go @@ -23,6 +23,7 @@ var ( clusterNameFlag string clusterTypeFlag string dnsProviderFlag string + subdomainNameFlag string domainNameFlag string githubOrgFlag string gitlabGroupFlag string @@ -99,6 +100,7 @@ func Create() *cobra.Command { createCmd.Flags().StringVar(&nodeCountFlag, "node-count", civoDefaults.NodeCount, "the node count for the cluster") createCmd.Flags().StringVar(&nodeTypeFlag, "node-type", civoDefaults.InstanceSize, "the instance size of the cluster to create") createCmd.Flags().StringVar(&dnsProviderFlag, "dns-provider", "civo", fmt.Sprintf("the dns provider - one of: %s", supportedDNSProviders)) + createCmd.Flags().StringVar(&subdomainNameFlag, "subdomain", "", "the subdomain to use for DNS records (Cloudflare)") createCmd.Flags().StringVar(&domainNameFlag, "domain-name", "", "the Civo DNS Name to use for DNS records (i.e. your-domain.com|subdomain.your-domain.com) (required)") createCmd.MarkFlagRequired("domain-name") createCmd.Flags().StringVar(&gitProviderFlag, "git-provider", "github", fmt.Sprintf("the git provider - one of: %s", supportedGitProviders)) diff --git a/cmd/digitalocean/command.go b/cmd/digitalocean/command.go index 9fba7e829..239cb30bd 100644 --- a/cmd/digitalocean/command.go +++ b/cmd/digitalocean/command.go @@ -25,6 +25,7 @@ var ( clusterTypeFlag string dnsProviderFlag string domainNameFlag string + subdomainNameFlag string githubOrgFlag string gitlabGroupFlag string gitProviderFlag string @@ -92,6 +93,7 @@ func Create() *cobra.Command { createCmd.Flags().StringVar(&nodeCountFlag, "node-count", doDefaults.NodeCount, "the node count for the cluster") createCmd.Flags().StringVar(&nodeTypeFlag, "node-type", doDefaults.InstanceSize, "the instance size of the cluster to create") createCmd.Flags().StringVar(&dnsProviderFlag, "dns-provider", "digitalocean", fmt.Sprintf("the dns provider - one of: %s", supportedDNSProviders)) + createCmd.Flags().StringVar(&subdomainNameFlag, "subdomain", "", "the subdomain to use for DNS records (Cloudflare)") createCmd.Flags().StringVar(&domainNameFlag, "domain-name", "", "the DigitalOcean DNS Name to use for DNS records (i.e. your-domain.com|subdomain.your-domain.com) (required)") createCmd.MarkFlagRequired("domain-name") createCmd.Flags().StringVar(&gitProviderFlag, "git-provider", "github", fmt.Sprintf("the git provider - one of: %s", supportedGitProviders)) diff --git a/cmd/google/command.go b/cmd/google/command.go index 2021e05fd..3135ded17 100644 --- a/cmd/google/command.go +++ b/cmd/google/command.go @@ -24,6 +24,7 @@ var ( clusterTypeFlag string dnsProviderFlag string domainNameFlag string + subdomainNameFlag string googleProjectFlag string githubOrgFlag string gitlabGroupFlag string @@ -94,6 +95,7 @@ func Create() *cobra.Command { createCmd.Flags().StringVar(&nodeCountFlag, "node-count", googleDefaults.NodeCount, "the node count for the cluster") createCmd.Flags().StringVar(&nodeTypeFlag, "node-type", googleDefaults.InstanceSize, "the instance size of the cluster to create") createCmd.Flags().StringVar(&dnsProviderFlag, "dns-provider", "google", fmt.Sprintf("the dns provider - one of: %s", supportedDNSProviders)) + createCmd.Flags().StringVar(&subdomainNameFlag, "subdomain", "", "the subdomain to use for DNS records (Cloudflare)") createCmd.Flags().StringVar(&domainNameFlag, "domain-name", "", "the GCP DNS Name to use for DNS records (i.e. your-domain.com|subdomain.your-domain.com) (required)") createCmd.MarkFlagRequired("domain-name") createCmd.Flags().StringVar(&googleProjectFlag, "google-project", "", "google project id (required)") diff --git a/cmd/vultr/command.go b/cmd/vultr/command.go index 656b89fca..a0227d9bc 100644 --- a/cmd/vultr/command.go +++ b/cmd/vultr/command.go @@ -24,6 +24,7 @@ var ( clusterTypeFlag string dnsProviderFlag string domainNameFlag string + subdomainNameFlag string githubOrgFlag string gitlabGroupFlag string gitProviderFlag string @@ -92,6 +93,7 @@ func Create() *cobra.Command { createCmd.Flags().StringVar(&nodeCountFlag, "node-count", vultrDefaults.NodeCount, "the node count for the cluster") createCmd.Flags().StringVar(&nodeTypeFlag, "node-type", vultrDefaults.InstanceSize, "the instance size of the cluster to create") createCmd.Flags().StringVar(&dnsProviderFlag, "dns-provider", "vultr", fmt.Sprintf("the dns provider - one of: %s", supportedDNSProviders)) + createCmd.Flags().StringVar(&subdomainNameFlag, "subdomain", "", "the subdomain to use for DNS records (Cloudflare)") createCmd.Flags().StringVar(&domainNameFlag, "domain-name", "", "the Vultr DNS Name to use for DNS records (i.e. your-domain.com|subdomain.your-domain.com) (required)") createCmd.MarkFlagRequired("domain-name") createCmd.Flags().StringVar(&gitProviderFlag, "git-provider", "github", fmt.Sprintf("the git provider - one of: %s", supportedGitProviders)) diff --git a/internal/launch/constants.go b/internal/launch/constants.go index 27bfb9143..b119f5cc8 100644 --- a/internal/launch/constants.go +++ b/internal/launch/constants.go @@ -11,7 +11,7 @@ const ( helmChartName = "kubefirst" helmChartRepoName = "kubefirst" helmChartRepoURL = "https://charts.kubefirst.com" - helmChartVersion = "2.3.7" + helmChartVersion = "2.3.8-rc16" namespace = "kubefirst" secretName = "kubefirst-initial-secrets" ) diff --git a/internal/types/flags.go b/internal/types/flags.go index edcd5214d..c5516c7f9 100644 --- a/internal/types/flags.go +++ b/internal/types/flags.go @@ -15,6 +15,7 @@ type CliFlags struct { ClusterType string DnsProvider string DomainName string + SubDomainName string GitProvider string GitProtocol string GithubOrg string diff --git a/internal/utilities/flags.go b/internal/utilities/flags.go index 7951038e2..8b4439dae 100644 --- a/internal/utilities/flags.go +++ b/internal/utilities/flags.go @@ -42,6 +42,12 @@ func GetFlags(cmd *cobra.Command, cloudProvider string) (types.CliFlags, error) return cliFlags, err } + subdomainFlag, err := cmd.Flags().GetString("subdomain") + if err != nil { + progress.Error(err.Error()) + return cliFlags, err + } + domainNameFlag, err := cmd.Flags().GetString("domain-name") if err != nil { progress.Error(err.Error()) @@ -128,6 +134,7 @@ func GetFlags(cmd *cobra.Command, cloudProvider string) (types.CliFlags, error) cliFlags.CloudRegion = cloudRegionFlag cliFlags.ClusterName = clusterNameFlag cliFlags.DnsProvider = dnsProviderFlag + cliFlags.SubDomainName = subdomainFlag cliFlags.DomainName = domainNameFlag cliFlags.GitProtocol = gitProtocolFlag cliFlags.GitProvider = gitProviderFlag diff --git a/internal/utilities/utilities.go b/internal/utilities/utilities.go index 410a7abc6..b0023be3d 100644 --- a/internal/utilities/utilities.go +++ b/internal/utilities/utilities.go @@ -145,6 +145,7 @@ func CreateClusterDefinitionRecordFromRaw(gitAuth apiTypes.GitAuth, cliFlags typ CloudProvider: cloudProvider, CloudRegion: viper.GetString("flags.cloud-region"), DomainName: domainName, + SubdomainName: cliFlags.SubDomainName, Type: "mgmt", NodeType: cliFlags.NodeType, NodeCount: stringToIntNodeCount,