Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add error handling for creating and locked clusters #33

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

ccapurso
Copy link
Contributor

Overview

The options provided in the Choose a cluster prompt are not filtered and thus a user may be provided options where the clusters are still being created or are API locked. A user will be presented with an error cluster is not running if they choose a cluster in any state other than running.

This PR introduces error handling for the CREATING, LOCKING, and LOCKED cluster states.

Related Issues/Pull Requests

This will be incorporated with a Vault PR once approved and merged

@ccapurso ccapurso requested a review from biazmoreira January 17, 2024 15:17
@ccapurso ccapurso requested a review from a team as a code owner January 17, 2024 15:17
connect.go Outdated
Comment on lines 339 to 343
if *cluster.State == hcpvsm.HashicorpCloudVault20201125ClusterStateLOCKED || *cluster.State == hcpvsm.HashicorpCloudVault20201125ClusterStateLOCKING {
return "", errors.New("cluster is locked")
} else if *cluster.State == hcpvsm.HashicorpCloudVault20201125ClusterStateCREATING {
return "", errors.New("cluster is still being created")
} else if *cluster.State != hcpvsm.HashicorpCloudVault20201125ClusterStateRUNNING {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we replace it with a switch case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted to refactor this from if/else if to a switch/case. Unfortunately, it looks roughly the same since we cannot switch based on the value of *cluster.State. I can create a variable for the state though to prevent multiple dereferences.

@ccapurso ccapurso merged commit 5cd0bf9 into main Jan 22, 2024
2 checks passed
@ccapurso ccapurso deleted the hvt-4974-cluster-state-errors branch January 22, 2024 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants