Closed mwasilew2 closed 1 year ago
We have this function called getStackID
which is called every time you do anything with a command which interacts with stacks: https://github.com/spacelift-io/spacectl/blob/main/internal/cmd/stack/stack_selector.go#L19
Because this is called every time we parse the provided --id
I was thinking maybe we could actually just look up and check if the provided stack actually exists in spacelift instead of just returning the provided name?
if cliCtx.IsSet(flagStackID.Name) {
return cliCtx.String(flagStackID.Name), nil
}
Would you mind look in to that and seeing if that actually works?
We have this function called
getStackID
which is called every time you do anything with a command which interacts with stacks: https://github.com/spacelift-io/spacectl/blob/main/internal/cmd/stack/stack_selector.go#L19Because this is called every time we parse the provided
--id
I was thinking maybe we could actually just look up and check if the provided stack actually exists in spacelift instead of just returning the provided name?if cliCtx.IsSet(flagStackID.Name) { return cliCtx.String(flagStackID.Name), nil }
Would you mind look in to that and seeing if that actually works?
You're right, it makes more sense to check for stack presence when we're extracting the stack id. The additional benefit of this is that this function is used in other places so we get nice error handling in those places as well.
@tomasmik let me know what you think of this approach
closes: https://app.clickup.com/t/862k09kgc
Includes in the error message a hint about how to list available stacks.
Note: The GraphQL API doesn't return errors that can be typed. The string parsing is a dirty hack, if anyone knows of a better way to approach it let me know.