Skip to content

Commit

Permalink
feat: add servers public ips
Browse files Browse the repository at this point in the history
Signed-off-by: DrummyFloyd <[email protected]>
  • Loading branch information
DrummyFloyd committed Jan 24, 2024
1 parent aa08327 commit dbc061f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/k3s/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
clusterNameFlag string
clusterTypeFlag string
k3sServersPrivateIpsFlag []string
k3sServersPublicIpsFlag []string
k3sSshUserflag string
k3sSshPrivateKeyflag string
K3sServersArgsFlags []string
Expand Down Expand Up @@ -87,6 +88,7 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&clusterTypeFlag, "cluster-type", "mgmt", "the type of cluster to create (i.e. mgmt|workload)")
createCmd.Flags().StringSliceVar(&k3sServersPrivateIpsFlag, "servers-private-ips", []string{}, "the list of k3s (servers) private ip x.x.x.x,y.y.y.y comma separated (required)")
createCmd.MarkFlagRequired("servers-private-ips")
createCmd.Flags().StringSliceVar(&k3sServersPublicIpsFlag, "servers-public-ips", []string{}, "the list of k3s (servers) public ip x.x.x.x,y.y.y.y comma separated (required)")
createCmd.Flags().StringSliceVar(&K3sServersArgsFlags, "servers-args", []string{"--disable traefik", "--write-kubeconfig-mode 644"}, "list of k3s extras flags to add to the k3s server installation,comma separated in between quote")
createCmd.Flags().StringVar(&k3sSshUserflag, "ssh-user", "root", "the user used to log into servers with ssh connection")
createCmd.Flags().StringVar(&k3sSshPrivateKeyflag, "ssh-privatekey", "", "the private key used to log into servers with ssh connection")
Expand Down
1 change: 1 addition & 0 deletions internal/types/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ type CliFlags struct {
K3sSshUser string
K3sSshPrivateKey string
K3sServersPrivateIps []string
K3sServersPublicIps []string
K3sServersArgs []string
}
8 changes: 8 additions & 0 deletions internal/utilities/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ func GetFlags(cmd *cobra.Command, cloudProvider string) (types.CliFlags, error)
}
cliFlags.K3sServersPrivateIps = k3sServersPrivateIps

k3sServersPublicIps, err := cmd.Flags().GetStringSlice("servers-public-ips")
if err != nil {
progress.Error(err.Error())
return cliFlags, err
}
cliFlags.K3sServersPublicIps = k3sServersPublicIps

k3sSshUserFlag, err := cmd.Flags().GetString("ssh-user")
if err != nil {
progress.Error(err.Error())
Expand Down Expand Up @@ -181,6 +188,7 @@ func GetFlags(cmd *cobra.Command, cloudProvider string) (types.CliFlags, error)
viper.Set("kubefirst.cloud-provider", cloudProvider)
if cloudProvider == "k3s" {
viper.Set("flags.servers-private-ips", cliFlags.K3sServersPrivateIps)
viper.Set("flags.servers-public-ips", cliFlags.K3sServersPublicIps)
viper.Set("flags.ssh-user", cliFlags.K3sSshUser)
viper.Set("flags.ssh-privatekey", cliFlags.K3sSshPrivateKey)
viper.Set("flags.servers-args", cliFlags.K3sServersArgs)
Expand Down
1 change: 1 addition & 0 deletions internal/utilities/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func CreateClusterDefinitionRecordFromRaw(gitAuth apiTypes.GitAuth, cliFlags typ
cl.VultrAuth.Token = os.Getenv("VULTR_API_KEY")
case "k3s":
cl.K3sAuth.K3sServersPrivateIps = viper.GetStringSlice("flags.servers-private-ips")
cl.K3sAuth.K3sServersPublicIps = viper.GetStringSlice("flags.servers-public-ips")
cl.K3sAuth.K3sSshUser = viper.GetString("flags.ssh-user")
cl.K3sAuth.K3sSshPrivateKey = viper.GetString("flags.ssh-privatekey")
cl.K3sAuth.K3sServersArgs = viper.GetStringSlice("flags.servers-args")
Expand Down

0 comments on commit dbc061f

Please sign in to comment.