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

Credentials class refactor #848

Merged

Conversation

simon-contreras-deel
Copy link
Contributor

@simon-contreras-deel simon-contreras-deel commented Jul 17, 2019

Refactor of the Credentials class

The first step of #661

In order to avoid a huge PR review like the last one, I am going to create several like this one. The objective is to allow you to check the structure or the idea since the tests are not going to be green. Then, in the main PR (using feature/credentials-refactor) we will see all together.

If you see a better way, please let me know

test/auth/test_credentials.py Outdated Show resolved Hide resolved
test/auth/test_credentials.py Outdated Show resolved Hide resolved
test/auth/test_credentials.py Outdated Show resolved Hide resolved
test/auth/test_credentials.py Outdated Show resolved Hide resolved
@simon-contreras-deel simon-contreras-deel changed the title Credentials refactor Credentials classs refactor Jul 17, 2019
@simon-contreras-deel simon-contreras-deel changed the title Credentials classs refactor Credentials class refactor Jul 17, 2019
test/auth/test_credentials.py Outdated Show resolved Hide resolved
cartoframes/auth/credentials.py Outdated Show resolved Hide resolved
Copy link
Contributor

@andy-esch andy-esch left a comment

Choose a reason for hiding this comment

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

❤️
So much better than what was there before!!

@simon-contreras-deel
Copy link
Contributor Author

@andy-esch Your work was and is awesome! This is the easy part

@simon-contreras-deel simon-contreras-deel merged commit 68d81f8 into feature/credentials-refactor Jul 18, 2019
@simon-contreras-deel simon-contreras-deel deleted the credentials-refactor branch July 18, 2019 08:21
Copy link
Contributor

@alrocar alrocar left a comment

Choose a reason for hiding this comment

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

Late to the party

Just a suggestion, we have some code in carto-python to get the username from the base_url it might be useful

if isinstance(credentials, Credentials):
return cls(credentials.api_key, credentials.username, credentials.base_url, credentials.session)

raise ValueError('`credentials` must a Credentials class instance')
Copy link
Contributor

Choose a reason for hiding this comment

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

typo -> must be 👼

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in #850

with open(config_file or _DEFAULT_PATH, 'r') as f:
credentials = json.load(f)

return cls(credentials.get('api_key'), credentials.get('username'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Also this makes the saved credentials not to work in on-premises environments, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, it is a bug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in #850

Copy link
Contributor

Choose a reason for hiding this comment

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

Great catch!!

@simon-contreras-deel
Copy link
Contributor Author

It is not late! We can do the stuff in the "main PR"

This was referenced Jul 18, 2019
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.

4 participants