Skip to content

Commit

Permalink
createNode: fix log output generating nil pointer...
Browse files Browse the repository at this point in the history
... dereference in addNodeToCluster when cluster does not exist.
Fixes #277
  • Loading branch information
iwilltry42 committed Jun 12, 2020
1 parent e7ffd18 commit 2d0ec0a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/create/createNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewCmdCreateNode() *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
nodes, cluster := parseCreateNodeCmd(cmd, args)
if err := k3dc.AddNodesToCluster(cmd.Context(), runtimes.SelectedRuntime, nodes, cluster, createNodeOpts); err != nil {
log.Errorf("Failed to add nodes '%+v' to cluster '%s'", nodes, cluster.Name)
log.Errorf("Failed to add nodes to cluster '%s'", nodes, cluster.Name)
log.Errorln(err)
}
},
Expand Down
3 changes: 2 additions & 1 deletion pkg/cluster/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ import (

// AddNodeToCluster adds a node to an existing cluster
func AddNodeToCluster(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, cluster *k3d.Cluster, createNodeOpts k3d.CreateNodeOpts) error {
targetClusterName := cluster.Name
cluster, err := GetCluster(ctx, runtime, cluster)
if err != nil {
log.Errorf("Failed to find specified cluster '%s'", cluster.Name)
log.Errorf("Failed to find specified cluster '%s'", targetClusterName)
return err
}

Expand Down

0 comments on commit 2d0ec0a

Please sign in to comment.