-
Notifications
You must be signed in to change notification settings - Fork 90
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
app/obolapi: create cluster launchpad URL #2518
Conversation
Add the `LaunchpadURLForLock` method, which generates a Launchpad cluster dashboard URL for a given cluster lock. Reference this method in `dkg` and `create cluster` commands so that at the end of this processes, if the user has specified `--publish`, the Launchpad dashboard URL will be printed on the console.
# Conflicts: # cmd/createcluster.go
Solving merge conflicts rn. |
Done, ready for review. Needs input from @f1lander / @HananINouman / @OisinKyne for URL format (see Slack) and general UX. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #2518 +/- ##
==========================================
+ Coverage 53.70% 53.74% +0.03%
==========================================
Files 199 199
Lines 26908 26938 +30
==========================================
+ Hits 14451 14477 +26
- Misses 10659 10661 +2
- Partials 1798 1800 +2
☔ View full report in Codecov by Sentry. |
For reference, this is how it appears to users when a DKG with /cc @Battenfield |
app/obolapi/api.go
Outdated
if err != nil { | ||
return errors.Wrap(err, "invalid endpoint") | ||
} | ||
addr := *c.baseURL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep baseURL a string since this pointer trick is easy to miss when adding more functions which can result in bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about this? Validate url in New()
, and provide a url()
method that returns it as *url.URL
, panic-ing if parsing fails: since validation happens in New()
, if it fails later it's a very weird situation:
// New returns a new Client.
func New(urlStr string) (Client, error) {
_, err := url.ParseRequestURI(urlStr) // check that urlStr is valid
if err != nil {
return Client{}, errors.Wrap(err, "could not parse Obol API URL")
}
return Client{
baseURL: urlStr,
}, nil
}
// Client is the REST client for obol-api requests.
type Client struct {
baseURL string // Base obol-api URL
}
func (c Client) url() *url.URL {
baseURL, err := url.ParseRequestURI(c.baseURL)
if err != nil {
panic(errors.Wrap(err, "could not parse Obol API URL, this should never happen"))
}
return baseURL
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, could also just return the error from url()
, don't think the effort to omit errors is super valuable.
Add the `LaunchpadURLForLock` method, which generates a Launchpad cluster dashboard URL for a given cluster lock. Reference this method in `dkg` and `create cluster` commands so that at the end of those processes, if the user has specified `--publish`, the Launchpad dashboard URL will be printed on the console. category: feature ticket: #2423 Closes #2423.
Add the `LaunchpadURLForLock` method, which generates a Launchpad cluster dashboard URL for a given cluster lock. Reference this method in `dkg` and `create cluster` commands so that at the end of those processes, if the user has specified `--publish`, the Launchpad dashboard URL will be printed on the console. category: feature ticket: #2423 Closes #2423.
Add the
LaunchpadURLForLock
method, which generates a Launchpad cluster dashboard URL for a given cluster lock.Reference this method in
dkg
andcreate cluster
commands so that at the end of those processes, if the user has specified--publish
, the Launchpad dashboard URL will be printed on the console.category: feature
ticket: #2423
Closes #2423.