refactor(kubeadm): remove deprecated command alpha kubeconfig

Signed-off-by: Jian Zeng <zengjian.zj@bytedance.com>
This commit is contained in:
Jian Zeng 2021-05-12 22:04:03 +08:00
parent 9aa6f0bc47
commit 41c4cccc26
No known key found for this signature in database
GPG Key ID: 1040B69865E7D86C
4 changed files with 8 additions and 24 deletions

View File

@ -29,19 +29,5 @@ func NewCmdAlpha(in io.Reader, out io.Writer) *cobra.Command {
Short: "Kubeadm experimental sub-commands",
}
kubeconfigCmd := NewCmdKubeConfigUtility(out)
deprecateCommand(`please use the same command under "kubeadm kubeconfig"`, kubeconfigCmd)
cmd.AddCommand(kubeconfigCmd)
return cmd
}
func deprecateCommand(msg string, cmds ...*cobra.Command) {
for _, cmd := range cmds {
cmd.Deprecated = msg
childCmds := cmd.Commands()
if len(childCmds) > 0 {
deprecateCommand(msg, childCmds...)
}
}
}

View File

@ -93,9 +93,7 @@ func NewKubeadmCommand(in io.Reader, out, err io.Writer) *cobra.Command {
cmds.AddCommand(upgrade.NewCmdUpgrade(out))
cmds.AddCommand(alpha.NewCmdAlpha(in, out))
options.AddKubeadmOtherFlags(cmds.PersistentFlags(), &rootfsPath)
// TODO: remove "kubeconfig" from "alpha"
// https://github.com/kubernetes/kubeadm/issues/2292
cmds.AddCommand(alpha.NewCmdKubeConfigUtility(out))
cmds.AddCommand(newCmdKubeConfigUtility(out))
return cmds
}

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package alpha
package cmd
import (
"io"
@ -34,20 +34,20 @@ import (
var (
kubeconfigLongDesc = cmdutil.LongDesc(`
Kubeconfig file utilities.
` + cmdutil.AlphaDisclaimer)
`)
userKubeconfigLongDesc = cmdutil.LongDesc(`
Output a kubeconfig file for an additional user.
` + cmdutil.AlphaDisclaimer)
`)
userKubeconfigExample = cmdutil.Examples(`
# Output a kubeconfig file for an additional user named foo using a kubeadm config file bar
kubeadm alpha kubeconfig user --client-name=foo --config=bar
kubeadm kubeconfig user --client-name=foo --config=bar
`)
)
// NewCmdKubeConfigUtility returns main command for kubeconfig phase
func NewCmdKubeConfigUtility(out io.Writer) *cobra.Command {
// newCmdKubeConfigUtility returns main command for kubeconfig phase
func newCmdKubeConfigUtility(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "kubeconfig",
Short: "Kubeconfig file utilities",

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package alpha
package cmd
import (
"bytes"