Skip to content

use api recursion, json output. simplify code. #62384

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

Merged
merged 16 commits into from
Oct 27, 2022

Conversation

jonbenning
Copy link
Contributor

What does this PR do?

This PR replaces the metadata_gce.py grain. That code was inspired by the EC2 grain, and utilized recursion, and other complex data checking to build the output dictionary. This code leverages the Google metadata service api's ability to output json natively, as well as its built in recurse parameter, resulting in vastly simpler code. It also automatically skips any potentially sensitive values like ssh keys, SA tokens, etc.

What issues does this PR fix or reference?

Fixes:

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes/No: No

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@jonbenning jonbenning requested a review from a team as a code owner July 26, 2022 18:16
@jonbenning jonbenning requested review from twangboy and removed request for a team July 26, 2022 18:16
@welcome
Copy link

welcome bot commented Jul 26, 2022

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

whytewolf
whytewolf previously approved these changes Oct 5, 2022
Copy link
Contributor

@twangboy twangboy left a comment

Choose a reason for hiding this comment

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

This looks great. It needs a changelog though. Could you please add one?

@jonbenning
Copy link
Contributor Author

This looks great. It needs a changelog though. Could you please add one?

I am a total noobie in the saltproject space - is it as simple as just adding a file in the changelog directory? I dont have an existing issue to reference, should i create one first?

@whytewolf
Copy link
Collaborator

whytewolf commented Oct 12, 2022

This looks great. It needs a changelog though. Could you please add one?

I am a total noobie in the saltproject space - is it as simple as just adding a file in the changelog directory? I dont have an existing issue to reference, should i create one first?

yep, create an issue that you can reference then add a file to the changelog directory. you can see the documentation for the process at https://docs.saltproject.io/en/latest/topics/development/changelog.html#changelog

looks like you might have to fix some pre-commit and lint issues as well. nothing major though.

@jonbenning
Copy link
Contributor Author

I am unsure what the problem is with all the failed tests. Are they actual valid failures?

@lkubb
Copy link
Contributor

lkubb commented Oct 13, 2022

test_extension_discovery_without_reload_with_importlib_metadata_installed is failing because of an unrelated dependency upgrade, you will be fine if you merge the latest changes from master though (specifically ef50ded b676e63).

@whytewolf
Copy link
Collaborator

I am unsure what the problem is with all the failed tests. Are they actual valid failures?

so. looks like at least one change needed. metadata needs a docstring. doesn't have to be complex just describe the function.

@jonbenning
Copy link
Contributor Author

I am unsure what the problem is with all the failed tests. Are they actual valid failures?

so. looks like at least one change needed. metadata needs a docstring. doesn't have to be complex just describe the function.

I think we're all good, except a couple checks that require approval. Thanks!

@jonbenning jonbenning requested a review from twangboy October 18, 2022 21:02
@twangboy
Copy link
Contributor

@jonbenning Looks like pre-commit is failing. No single-quotes... only double-quotes for strings. That includes doc strings.

@jonbenning
Copy link
Contributor Author

@jonbenning Looks like pre-commit is failing. No single-quotes... only double-quotes for strings. That includes doc strings.

Have pushed the requested changes. Thanks!

@garethgreenaway garethgreenaway merged commit 71463a5 into saltstack:master Oct 27, 2022
@welcome
Copy link

welcome bot commented Oct 27, 2022

Congratulations on your first PR being merged! 🎉

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.

6 participants