Merge pull request #122762 from yxxhero/check-initData-and-joinData-safely

Fix type assertion error in init and join commands for kubeadm
This commit is contained in:
Kubernetes Prow Robot 2024-01-17 04:37:05 +01:00 committed by GitHub
commit d399535b01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -118,7 +118,11 @@ func newCmdInit(out io.Writer, initOptions *initOptions) *cobra.Command {
return err
}
data := c.(*initData)
data, ok := c.(*initData)
if !ok {
return errors.New("invalid data struct")
}
fmt.Printf("[init] Using Kubernetes version: %s\n", data.cfg.KubernetesVersion)
return initRunner.Run(args)

View File

@ -175,7 +175,10 @@ func newCmdJoin(out io.Writer, joinOptions *joinOptions) *cobra.Command {
return err
}
data := c.(*joinData)
data, ok := c.(*joinData)
if !ok {
return errors.New("invalid data struct")
}
if err := joinRunner.Run(args); err != nil {
return err