mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
kubeadm/certs/renew:remove deprecated flags csrOnly and csrPath
This commit is contained in:
parent
c98b388a84
commit
bc4bbd88b2
@ -22,7 +22,6 @@ import (
|
|||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/lithammer/dedent"
|
"github.com/lithammer/dedent"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
@ -215,8 +214,6 @@ type renewFlags struct {
|
|||||||
cfgPath string
|
cfgPath string
|
||||||
kubeconfigPath string
|
kubeconfigPath string
|
||||||
cfg kubeadmapiv1.ClusterConfiguration
|
cfg kubeadmapiv1.ClusterConfiguration
|
||||||
csrOnly bool
|
|
||||||
csrPath string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRenewSubCommands(out io.Writer, kdir string) []*cobra.Command {
|
func getRenewSubCommands(out io.Writer, kdir string) []*cobra.Command {
|
||||||
@ -255,7 +252,7 @@ func getRenewSubCommands(out io.Writer, kdir string) []*cobra.Command {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return renewCert(flags, kdir, internalcfg, handler)
|
return renewCert(kdir, internalcfg, handler)
|
||||||
}
|
}
|
||||||
}(handler)
|
}(handler)
|
||||||
// install the implementation into the command
|
// install the implementation into the command
|
||||||
@ -282,7 +279,7 @@ func getRenewSubCommands(out io.Writer, kdir string) []*cobra.Command {
|
|||||||
|
|
||||||
// Renew certificates
|
// Renew certificates
|
||||||
for _, handler := range rm.Certificates() {
|
for _, handler := range rm.Certificates() {
|
||||||
if err := renewCert(flags, kdir, internalcfg, handler); err != nil {
|
if err := renewCert(kdir, internalcfg, handler); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,7 +300,7 @@ func addRenewFlags(cmd *cobra.Command, flags *renewFlags) {
|
|||||||
options.AddKubeConfigFlag(cmd.Flags(), &flags.kubeconfigPath)
|
options.AddKubeConfigFlag(cmd.Flags(), &flags.kubeconfigPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func renewCert(flags *renewFlags, kdir string, internalcfg *kubeadmapi.InitConfiguration, handler *renewal.CertificateRenewHandler) error {
|
func renewCert(kdir string, internalcfg *kubeadmapi.InitConfiguration, handler *renewal.CertificateRenewHandler) error {
|
||||||
// Get a renewal manager for the given cluster configuration
|
// Get a renewal manager for the given cluster configuration
|
||||||
rm, err := renewal.NewManager(&internalcfg.ClusterConfiguration, kdir)
|
rm, err := renewal.NewManager(&internalcfg.ClusterConfiguration, kdir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -315,17 +312,6 @@ func renewCert(flags *renewFlags, kdir string, internalcfg *kubeadmapi.InitConfi
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the renewal operation is set to generate CSR request only
|
|
||||||
if flags.csrOnly {
|
|
||||||
// checks a path for storing CSR request is given
|
|
||||||
if flags.csrPath == "" {
|
|
||||||
return errors.New("please provide a path where CSR request should be stored")
|
|
||||||
}
|
|
||||||
return rm.CreateRenewCSR(handler.Name, flags.csrPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise, the renewal operation has to actually renew a certificate
|
|
||||||
|
|
||||||
// renew using local certificate authorities.
|
// renew using local certificate authorities.
|
||||||
// this operation can't complete in case the certificate key is not provided (external CA)
|
// this operation can't complete in case the certificate key is not provided (external CA)
|
||||||
renewed, err := rm.RenewUsingLocalCA(handler.Name)
|
renewed, err := rm.RenewUsingLocalCA(handler.Name)
|
||||||
|
@ -22,13 +22,3 @@ import "github.com/spf13/pflag"
|
|||||||
func AddCertificateDirFlag(fs *pflag.FlagSet, certsDir *string) {
|
func AddCertificateDirFlag(fs *pflag.FlagSet, certsDir *string) {
|
||||||
fs.StringVar(certsDir, CertificatesDir, *certsDir, "The path where to save the certificates")
|
fs.StringVar(certsDir, CertificatesDir, *certsDir, "The path where to save the certificates")
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddCSRFlag adds the --csr-only flag to the given flagset
|
|
||||||
func AddCSRFlag(fs *pflag.FlagSet, csr *bool) {
|
|
||||||
fs.BoolVar(csr, CSROnly, *csr, "Create CSRs instead of generating certificates")
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddCSRDirFlag adds the --csr-dir flag to the given flagset
|
|
||||||
func AddCSRDirFlag(fs *pflag.FlagSet, csrDir *string) {
|
|
||||||
fs.StringVar(csrDir, CSRDir, *csrDir, "The path to output the CSRs and private keys to")
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user