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

Merged
merged 1 commit into from
Dec 16, 2024

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 (4128d15) to head (bab1834).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
unstable/testutil/logging.go 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2742      +/-   ##
==========================================
- Coverage   69.64%   69.62%   -0.03%     
==========================================
  Files         301      302       +1     
  Lines       38726    38736      +10     
==========================================
- Hits        26971    26969       -2     
- Misses      10237    10250      +13     
+ Partials     1518     1517       -1     

☔ 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.

dynamic/parameterize/args.go Show resolved Hide resolved
dynamic/parameterize/args.go Show resolved Hide resolved
pkg/bridgetest/README.md Outdated Show resolved Hide resolved
@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
pkg/bridgetest/README.md Outdated Show resolved Hide resolved
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 14e4ec1 to bab1834 Compare December 16, 2024 11:21
Copy link
Member

@mjeffryes mjeffryes left a comment

Choose a reason for hiding this comment

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

Thanks for the extra docs!

@@ -243,6 +243,28 @@ func ReadResourceRequest(i *tfprotov6.ReadResourceRequest) *tfplugin6.ReadResour
}
}
```

### `package parameterize`
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for documenting! Docs are very good to have.

We're still figuring out what's our style for docs - so happy to discuss alternatives. One pattern I've used before in this repo is package.go with doc comment describing what each package does. This seems to be some support for this in e.g. https://tip.golang.org/doc/comment#package - this also gets copied into auto-generated Go docs.

The README is also very important. There's "how do I use this" and "what can it do" concerns that go in a README. Not sure what's the right balance for us is here but my 2c so you're aware of the package.go option for the package-level detail.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a good call-out. The bridge also has 1 doc.go, and I've seen more in the wild.

For this PR, I'm going to keep using the README.md, since that's what the module already does. It might be worth standardizing at some point.

Autogenerated Go docs also include the README: https://pkg.go.dev/github.com/pulumi/pulumi-terraform-bridge/dynamic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Step One: Have docs ✅
Step Two: Have docs be discoverable 👓
Step Three: Profit Standardization 🎉

We'll get there, especially as we continue thinking about this.

@guineveresaenger guineveresaenger merged commit edecf55 into master Dec 16, 2024
17 checks passed
@guineveresaenger guineveresaenger deleted the iwahbe/dynamic-switch-to-cobra branch December 16, 2024 18:10
guineveresaenger added a commit that referenced this pull request Dec 18, 2024
Update: Rebased against
#2742 which adds
Cobra. Blocked until that merges.

This pull request adds a `registryDocs` Generator to the initialSetup
call for a dynamic provider.

Adjustments to accommodate this change:

- Because the generation instructions will necessarily include the
string `terraform`, the section needs to be added after the edit rules
are applied.
- The logic to determine which installation instruction to generate is
hinged on `info.Repository`, which is the source repo of the provider.
If it doesn't contain "pulumi" then we're dealing with an Any TF
provider.
- `_index.md` is written to a user-specified (via flag)
`--indexDocOutDir`. This allows us to write to any location in a file
system. Leaving this blank prompts the file to only get written to the
virtual filesystem in the bridge.
- An integration test is added that verifies generation and translation
of the `_index.md` file` from hashicorp/random.

---------

Co-authored-by: Ian Wahbe <me@iwahbe.com>
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v3.99.0.

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.

5 participants