Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

cmd,pkg: fix nil dereference when running kubeless install #41

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ func newControllerConfig(masterHost, ns string) controller.Config {
if err != nil {
fmt.Errorf("Can not get kubernetes config: %s", err)
}
masterHost = k8sConfig.Host
if k8sConfig == nil {
fmt.Errorf("Got nil k8sConfig, please check if k8s cluster is available.")
} else {
masterHost = k8sConfig.Host
}
}
cfg := controller.Config{
Namespace: ns,
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ func (c *Controller) Run() error {
}

func (c *Controller) initResource() error {
if c.Config.MasterHost == "" {
return fmt.Errorf("MasterHost is empty. Please check if k8s cluster is available.")
}
err := c.createTPR()
if err != nil {
if !utils.IsKubernetesResourceAlreadyExistError(err) {
Expand Down