mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Fix double stack retrieval while removing stack
This commit is contained in:
@ -46,7 +46,6 @@ var stackRemoveCmd = &cobra.Command{
|
|||||||
"swarm": endpointSwarmClusterId,
|
"swarm": endpointSwarmClusterId,
|
||||||
}).Debug("Getting stack")
|
}).Debug("Getting stack")
|
||||||
stack, stackRetrievalErr = common.GetStackByName(stackName, endpointSwarmClusterId, uint32(endpointId))
|
stack, stackRetrievalErr = common.GetStackByName(stackName, endpointSwarmClusterId, uint32(endpointId))
|
||||||
common.CheckError(stackRetrievalErr)
|
|
||||||
case *common.StackClusterNotFoundError:
|
case *common.StackClusterNotFoundError:
|
||||||
// It's not a swarm cluster
|
// It's not a swarm cluster
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
@ -54,17 +53,12 @@ var stackRemoveCmd = &cobra.Command{
|
|||||||
"endpoint": endpointId,
|
"endpoint": endpointId,
|
||||||
}).Debug("Getting stack")
|
}).Debug("Getting stack")
|
||||||
stack, stackRetrievalErr = common.GetStackByName(stackName, "", uint32(endpointId))
|
stack, stackRetrievalErr = common.GetStackByName(stackName, "", uint32(endpointId))
|
||||||
common.CheckError(stackRetrievalErr)
|
|
||||||
default:
|
default:
|
||||||
// Something else happened
|
// Something else happened
|
||||||
common.CheckError(selectionErr)
|
common.CheckError(selectionErr)
|
||||||
}
|
}
|
||||||
logrus.WithFields(logrus.Fields{
|
|
||||||
"stack": stackName,
|
|
||||||
}).Debug("Getting stack")
|
|
||||||
stack, err := common.GetStackByName(stackName, "", 0)
|
|
||||||
|
|
||||||
switch err.(type) {
|
switch stackRetrievalErr.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
// The stack exists
|
// The stack exists
|
||||||
stackId := stack.Id
|
stackId := stack.Id
|
||||||
@ -72,7 +66,7 @@ var stackRemoveCmd = &cobra.Command{
|
|||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"stack": stackName,
|
"stack": stackName,
|
||||||
}).Info("Removing stack")
|
}).Info("Removing stack")
|
||||||
err = portainerClient.DeleteStack(stackId)
|
err := portainerClient.DeleteStack(stackId)
|
||||||
common.CheckError(err)
|
common.CheckError(err)
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"stack": stack.Name,
|
"stack": stack.Name,
|
||||||
@ -90,7 +84,7 @@ var stackRemoveCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// Something else happened
|
// Something else happened
|
||||||
common.CheckError(err)
|
common.CheckError(stackRetrievalErr)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user