Skip to content

Commit

Permalink
check typecasts of k0sConfig.spec.api.port
Browse files Browse the repository at this point in the history
for proper handling of nil values

Signed-off-by: erdii <me@erdii.engineering>
  • Loading branch information
erdii committed Aug 10, 2021
1 parent 5421b2f commit 105df2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions phase/install_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ func (p *InstallControllers) Run() error {
}

func (p *InstallControllers) waitJoined(h *cluster.Host) error {
port := p.Config.Spec.K0s.Config.Dig("spec", "api", "port").(int)
if port == 0 {
port = 6443
port := 6443
if p, ok := p.Config.Spec.K0s.Config.Dig("spec", "api", "port").(int); ok {
port = p
}

log.Infof("%s: waiting for kubernetes api to respond", h)
return h.WaitKubeAPIReady(port)
}
6 changes: 3 additions & 3 deletions phase/upgrade_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ func (p *UpgradeControllers) Run() error {
if err := h.WaitK0sServiceRunning(); err != nil {
return err
}
port := p.Config.Spec.K0s.Config.Dig("spec", "api", "port").(int)
if port == 0 {
port = 6443
port := 6443
if p, ok := p.Config.Spec.K0s.Config.Dig("spec", "api", "port").(int); ok {
port = p
}
if err := h.WaitKubeAPIReady(port); err != nil {
return err
Expand Down

0 comments on commit 105df2e

Please sign in to comment.