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

[any-tf-provider] Switch args parsing to cobra #2742

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

iwahbe
Copy link
Member

@iwahbe iwahbe commented Dec 13, 2024

Simplify args parsing by using cobra.

My hope is that this will make the implementation of #2717 much easier.

@iwahbe iwahbe self-assigned this Dec 13, 2024
@iwahbe iwahbe force-pushed the iwahbe/dynamic-switch-to-cobra branch from 316be51 to c61588b Compare December 13, 2024 12:00
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 69.62%. Comparing base (f94f380) to head (04fb870).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
pkg/bridgetest/logging.go 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2742      +/-   ##
==========================================
- Coverage   69.64%   69.62%   -0.02%     
==========================================
  Files         301      302       +1     
  Lines       38726    38736      +10     
==========================================
  Hits        26969    26969              
- Misses      10240    10250      +10     
  Partials     1517     1517              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iwahbe iwahbe requested a review from a team December 13, 2024 14:10
Copy link
Contributor

@guineveresaenger guineveresaenger left a comment

Choose a reason for hiding this comment

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

Approving because of time zone differences.

I really like keeping test utils in their own module, for the record, because it makes them much more discoverable. But I also ideally want that to be part of a concerted effort to consolidate and centralize such utilities. I worry that adding them in this way would not facilitate that.

cmd.Flags().StringVar(&upstreamRepoPath, "upstreamRepoPath", "",
"Specify a local file path to the root of the Git repository of the provider being dynamically bridged")

// We hide docs flags since they are not intended for end users, and they may not be stable.
Copy link
Contributor

Choose a reason for hiding this comment

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

How are we going to make these flags discoverable for maintainers? I've gotten burned by this before and would like an alternative.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure, but I'm open to suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Two options, really:

  1. do not hide the flags and clarify in the help text to not use them
  2. put the documentation in a discoverable place for maintainers (possibly the README for this module, though discoverability is always difficult to predict)

if out.Len() == 0 {
return
}
tfbridge.GetLogger(ctx).Info(out.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the CLI hides raw stdout unless the provider panics. This ensures that output (like help text) is printed.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like it would be worth adding a comment to that effect.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, interesting. This is the pulumi cli?

pkg/bridgetest/README.md Outdated Show resolved Hide resolved
This allows modules outside of the bridge to test code that uses
`tfbridge.GetLogger`. This will be used by `dynamic`. It may also be used by AWS, which
currently has test code which uses the now moved-to-internal logging.InitContext.
This gets us out of the business of writing flag parsing. This does change the format of
options. Before, they looked like:

```console
$ pulumi package get-schema registry.opentofu.org/owner/provider version fullDocs=true
```

They now look like:

```console
$ pulumi package get-schema -- registry.opentofu.org/owner/provider version --fullDocs
```
@iwahbe iwahbe force-pushed the iwahbe/dynamic-switch-to-cobra branch from c61588b to 04fb870 Compare December 13, 2024 19:05
@iwahbe iwahbe enabled auto-merge (rebase) December 13, 2024 19:05
@@ -0,0 +1,7 @@
# bridgetest
Copy link
Member

Choose a reason for hiding this comment

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

do you have plans to use this outside of the dynamic module? I do agree with @guineveresaenger that it's a little surprising to make a new top level package to hold this in the context of this PR.

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.

3 participants