Skip to content

Conversation

@antazoey
Copy link
Contributor

@antazoey antazoey commented Dec 9, 2020

  • Adds a missing test

  • Safer delete profile method

@antazoey antazoey requested a review from timabrmsn December 9, 2020 17:05
@github-actions
Copy link

github-actions bot commented Dec 9, 2020

CLA Assistant Lite bot All contributors have signed the CLA ✍️


def delete_profile(profile_name):
profile = _get_profile(profile_name)
profile_name = profile.name
Copy link
Contributor

Choose a reason for hiding this comment

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

How would these get out of sync?

Copy link
Contributor Author

@antazoey antazoey Dec 9, 2020

Choose a reason for hiding this comment

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

If you call _get_profile() with None it uses the default profile, and as a hacker, I actually use this individual module in other non-CLI related scripts (creating SDKs from CLI profiles for py42 related stuff).

I don't see anything bad that would happen because of this change in the CLI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes sense from the command perspective to not be allowed to delete the default profile, but from this module's perspective, if you are grabbing the profile from the name, you should use the name of the profile object because that is the real profile name you are working with

Copy link
Contributor Author

@antazoey antazoey Dec 9, 2020

Choose a reason for hiding this comment

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

If you look at other methods in this module, that is what happens too, so this is consistent with that

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok cool, I was just wondering if you had uncovered a bug caused by this, to get a sense of what the change did.

I do see that if you just call code42 profile delete without a profile name, it errors out. This change allows it to delete the default, but then it prints the name wrong since we're just printing the argument passed:

 # code42 profile delete

Deleting this profile will also delete any stored passwords and checkpoints. Are you sure? (y/n): y
Profile 'None' has been deleted.

It also doesn't print the "<profile_name> is currently the default profile!" message in the warning..

A simple fix would be to just make the profile_name arg required on just the delete command.. Thoughts?

Copy link
Contributor Author

@antazoey antazoey Dec 10, 2020

Choose a reason for hiding this comment

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

Oh ok, yes I had thought that it was required. If you are not allowed to delete the default profile, it really should be required. Are you sure that it is this change allows this error? What happens on master branch? There might actually be a bug related to this. Awesome that this was uncovered. I am going to look tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I verified that this bug is indeed already on Master, so I will fix it as an adittion to this PR

@antazoey antazoey changed the title safer delete + tests make profile name required for delete Dec 10, 2020
@antazoey antazoey changed the title make profile name required for delete Bugfix: make profile name required for delete Dec 11, 2020
@antazoey antazoey merged commit 52eb67a into master Dec 11, 2020
@antazoey antazoey deleted the safer-delete branch December 11, 2020 21:04
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants