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

Add command to open a resource in the browser #1846

Merged
merged 8 commits into from
Oct 24, 2024
Merged

Add command to open a resource in the browser #1846

merged 8 commits into from
Oct 24, 2024

Conversation

pietern
Copy link
Contributor

@pietern pietern commented Oct 21, 2024

Changes

This builds on the functionality added in #1731 that produces a URL for every resource.

Adds bundle/resources package to deal with resource lookups and command completion. The new functionality is similar to the lookup and command completion functionality located in bundle/run. It differs in that it doesn't gracefully deal with ambiguous references to resources, now that we explicitly validate this doesn't occur in the bundle configuration. It still allows resources to be looked up with their fully qualified key, <plural type>.<key>.

Tests

  • Added unit tests for resource lookup and completion
  • Manually confirmed that bundle open prompts, accepts a key argument, and opens a browser


// First try to find the resource by key alone.
if res, ok := keyOnly[key]; ok {
if len(res) == 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we add the case if len > 1 then we return the error that the resource is ambiguous?

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.

I looked through the commit history and found that we added validation of uniqueness early last year. This makes the probability of seeing ambiguous keys very low (I think it's still possible if a resource with a duplicate key is defined in the target overrides). Relevant PRs: #1614 and #332.

@pietern pietern changed the title Add command to open the web UI for a resource Add command to open a resource in the browser Oct 23, 2024
@pietern pietern marked this pull request as ready for review October 23, 2024 15:01
@pietern pietern requested a review from andrewnester October 23, 2024 15:01
@pietern pietern added this pull request to the merge queue Oct 24, 2024
Merged via the queue into main with commit 89ee7d8 Oct 24, 2024
5 checks passed
@pietern pietern deleted the bundle-open branch October 24, 2024 12:28
github-merge-queue bot pushed a commit that referenced this pull request Oct 24, 2024
## Changes

As of #1846 we have a generalized package for doing resource lookups and
completion.

This change updates the run command to use this instead of more specific
code under `bundle/run`.

## Tests

* Unit tests pass
* Manually confirmed that completion and prompting works
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.

2 participants