salt icon indicating copy to clipboard operation
salt copied to clipboard

use api recursion, json output. simplify code.

Open jonbenning opened this issue 3 years ago • 1 comments

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.

  • [ ] Docs
  • [ ] Changelog - https://docs.saltproject.io/en/master/topics/development/changelog.html
  • [ ] Tests written/updated

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 avatar Jul 26 '22 18:07 jonbenning

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 [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

welcome[bot] avatar Jul 26 '22 18:07 welcome[bot]

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?

jonbenning avatar Oct 12 '22 19:10 jonbenning

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.

whytewolf avatar Oct 12 '22 21:10 whytewolf

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

jonbenning avatar Oct 13 '22 15:10 jonbenning

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 https://github.com/saltstack/salt/commit/ef50ded44324efb531cafd3b0e95d733c08be410 https://github.com/saltstack/salt/commit/b676e6338a7c094cb3335d11f851ac0e12222017).

lkubb avatar Oct 13 '22 16:10 lkubb

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.

whytewolf avatar Oct 13 '22 16:10 whytewolf

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 avatar Oct 14 '22 18:10 jonbenning

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

twangboy avatar Oct 20 '22 14:10 twangboy

@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!

jonbenning avatar Oct 24 '22 13:10 jonbenning

Congratulations on your first PR being merged! :tada:

welcome[bot] avatar Oct 27 '22 19:10 welcome[bot]