Closed AndrewCsoka closed 4 years ago
I've built and tested locally. The changes work as I'd expect. Ready for review. @kaihoffman
I think @andyjeffries had some reservations about automatically setting an API key on removal. From a previous (now-closed) PR:
civo apikeys
# development <======
# production
civo apikey delete development
# Deletes development
# Has no current, so resets it to the first one, e.g. production
# But the current before was development so the user then does...
civo instance delete super-important-database
I think I'm now OK with setting a default on deletion of an API key (my mind has changed), provided we make it very clear to the user what the new default key is (colourised).
I'm even OK with doing it if you have 3 keys and delete 1, it picking the first of the remaining two, providing it communicates this to the user.
@kaihoffman how does that fit in with your other PR that was merged this morning? Complimentary/conflicting? It says conflicting above, but I mean on a business logic level.
@andyjeffries the other PR also does this behaviour. The conflict arises from a different implementation of the same logic. The other PR also extends this slightly, and informs the user of changes when a current key gets deleted etc.
Closing for now as superseded. Hope that's OK?
This is intended to fix https://github.com/civo/cli/issues/41 and also handle the inverse case: when a user deletes all but one key, the last remaining key should become the default.
An additional behaviour is possible: when the user deletes the existing default, you could randomly assign a new default, but I think that could be confusing.
I've raised this as a draft PR, since it's unbuilt and untested so far. I'm also unsure about thekeys
data structure sokeys.keys.key
here might be wrong.Feel free to comment. I've never used Ruby.