From 9a2c38bf2dfa8fa719b656a6936cf7d90f3276c1 Mon Sep 17 00:00:00 2001 From: ananaysingh <54039499+ananaysingh@users.noreply.github.com> Date: Thu, 18 Aug 2022 17:24:03 +0530 Subject: [PATCH] Updated instance number check --- cmd/kill.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/kill.go b/cmd/kill.go index 0aefe8d..5f39814 100644 --- a/cmd/kill.go +++ b/cmd/kill.go @@ -94,8 +94,18 @@ func killTask(cmd *cobra.Command, args []string) { Role(*role). Name(*name) - //Convert instance from string type to int32 type, and call the killtasks function - instanceNumber, _ := strconv.Atoi(*instance) + //Check that instance number is passed + if instance == nil { + log.Fatalln("instance number not found. Please pass a valid instance number.") + } + + //Convert instance from string type to int32 type + instanceNumber, intErr := strconv.Atoi(*instance) + if intErr != nil { + log.Fatalln("Instance passed should be a number. Error: " + intErr.Error()) + } + + //Call the killtasks function _, err := client.KillInstances(task.JobKey(), (int32)(instanceNumber)) if err != nil {