feat(fctl): use membership/_info to expose console_url#1495
Conversation
WalkthroughThe recent changes focus on dynamically setting the dashboard URL based on server information across multiple components. This ensures that users are directed to the correct URL, enhancing the overall user experience. The updates include modifications to the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Actionable comments posted: 11
Out of diff range and nitpick comments (1)
components/fctl/membershipclient/docs/ServerInfo.md (1)
Line range hint
101-104: Fix unpaired symbol and multiple consecutive blank lines.There is an unpaired symbol and multiple consecutive blank lines in the back links section. Ensure proper formatting.
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (3)
components/fctl/membership-swagger.yamlis excluded by!**/*.yamlcomponents/fctl/membershipclient/api/openapi.yamlis excluded by!**/*.yamlcomponents/fctl/membershipclient/go.sumis excluded by!**/*.sum,!**/*.sum
Files selected for processing (5)
- components/fctl/cmd/stack/create.go (1 hunks)
- components/fctl/cmd/stack/list.go (1 hunks)
- components/fctl/cmd/ui/ui.go (2 hunks)
- components/fctl/membershipclient/docs/ServerInfo.md (2 hunks)
- components/fctl/membershipclient/model_server_info.go (3 hunks)
Additional Context Used
LanguageTool (2)
components/fctl/membershipclient/docs/ServerInfo.md (2)
Near line 47: Possible missing article found.
Context: ...ing)SetVersion sets Version field to given value. ### GetCapabilitiesfunc (o ...
Near line 101: Unpaired symbol: ‘[’ seems to be missing
Context: ...ld has been set. [Back to Model list] ...
|
|
||
| if err := openUrl(c.store.UIUrl); err != nil { | ||
| c.store.FoundBrowser = true |
There was a problem hiding this comment.
Fix incorrect browser detection logic.
The FoundBrowser field is set to true only if openUrl returns an error, which is counterintuitive. It should be set to true if the URL is successfully opened.
if err := openUrl(c.store.UIUrl); err != nil {
return nil, err
}
c.store.FoundBrowser = trueCommittable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| if err := openUrl(c.store.UIUrl); err != nil { | |
| c.store.FoundBrowser = true | |
| if err := openUrl(c.store.UIUrl); err != nil { | |
| return nil, err | |
| } | |
| c.store.FoundBrowser = true |
| **Version** | **string** | | | ||
| **Capabilities** | Pointer to [**[]Capability**](Capability.md) | | [optional] | ||
| **ConsoleURL** | Pointer to **string** | | [optional] |
There was a problem hiding this comment.
Fix table formatting issues.
The table formatting is incorrect, with trailing spaces and missing data in the ConsoleURL row. Ensure the table is properly formatted.
**Version** | **string** | |
**Capabilities** | Pointer to [**[]Capability**](Capability.md) | | [optional]
**ConsoleURL** | Pointer to **string** | | [optional] Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| **Version** | **string** | | | |
| **Capabilities** | Pointer to [**[]Capability**](Capability.md) | | [optional] | |
| **ConsoleURL** | Pointer to **string** | | [optional] | |
| **Version** | **string** | | | |
| **Capabilities** | Pointer to [**[]Capability**](Capability.md) | | [optional] | |
| **ConsoleURL** | Pointer to **string** | | [optional] |
| ### GetConsoleURL | ||
|
|
||
| `func (o *ServerInfo) GetConsoleURL() string` | ||
|
|
||
| GetConsoleURL returns the ConsoleURL field if non-nil, zero value otherwise. | ||
|
|
||
| ### GetConsoleURLOk | ||
|
|
||
| `func (o *ServerInfo) GetConsoleURLOk() (*string, bool)` | ||
|
|
||
| GetConsoleURLOk returns a tuple with the ConsoleURL field if it's non-nil, zero value otherwise | ||
| and a boolean to check if the value has been set. | ||
|
|
||
| ### SetConsoleURL | ||
|
|
||
| `func (o *ServerInfo) SetConsoleURL(v string)` | ||
|
|
||
| SetConsoleURL sets ConsoleURL field to given value. | ||
|
|
||
| ### HasConsoleURL | ||
|
|
||
| `func (o *ServerInfo) HasConsoleURL() bool` | ||
|
|
||
| HasConsoleURL returns a boolean if a field has been set. | ||
|
|
There was a problem hiding this comment.
Remove unnecessary blank lines.
There are multiple unnecessary blank lines in the methods section. Removing them will improve readability.
### GetConsoleURL
`func (o *ServerInfo) GetConsoleURL() string`
GetConsoleURL returns the ConsoleURL field if non-nil, zero value otherwise.
### GetConsoleURLOk
`func (o *ServerInfo) GetConsoleURLOk() (*string, bool)`
GetConsoleURLOk returns a tuple with the ConsoleURL field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.
### SetConsoleURL
`func (o *ServerInfo) SetConsoleURL(v string)`
SetConsoleURL sets ConsoleURL field to given value.
### HasConsoleURL
`func (o *ServerInfo) HasConsoleURL() bool`
HasConsoleURL returns a boolean if a field has been set.Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| ### GetConsoleURL | |
| `func (o *ServerInfo) GetConsoleURL() string` | |
| GetConsoleURL returns the ConsoleURL field if non-nil, zero value otherwise. | |
| ### GetConsoleURLOk | |
| `func (o *ServerInfo) GetConsoleURLOk() (*string, bool)` | |
| GetConsoleURLOk returns a tuple with the ConsoleURL field if it's non-nil, zero value otherwise | |
| and a boolean to check if the value has been set. | |
| ### SetConsoleURL | |
| `func (o *ServerInfo) SetConsoleURL(v string)` | |
| SetConsoleURL sets ConsoleURL field to given value. | |
| ### HasConsoleURL | |
| `func (o *ServerInfo) HasConsoleURL() bool` | |
| HasConsoleURL returns a boolean if a field has been set. | |
| ### GetConsoleURL | |
| `func (o *ServerInfo) GetConsoleURL() string` | |
| GetConsoleURL returns the ConsoleURL field if non-nil, zero value otherwise. | |
| ### GetConsoleURLOk | |
| `func (o *ServerInfo) GetConsoleURLOk() (*string, bool)` | |
| GetConsoleURLOk returns a tuple with the ConsoleURL field if it's non-nil, zero value otherwise | |
| and a boolean to check if the value has been set. | |
| ### SetConsoleURL | |
| `func (o *ServerInfo) SetConsoleURL(v string)` | |
| SetConsoleURL sets ConsoleURL field to given value. | |
| ### HasConsoleURL | |
| `func (o *ServerInfo) HasConsoleURL() bool` | |
| HasConsoleURL returns a boolean if a field has been set. |
| Id: stack.Id, | ||
| Name: stack.Name, | ||
| Dashboard: "https://console.formance.cloud", | ||
| Dashboard: dashboard, |
There was a problem hiding this comment.
Ensure consistency in setting the Dashboard URL.
The Dashboard URL is set to the dashboard variable, which is dynamically determined. Ensure this is consistent across all usages.
Dashboard: dashboard,Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| Dashboard: dashboard, | |
| Dashboard: dashboard, |
| type ServerInfo struct { | ||
| Version string `json:"version"` | ||
| Capabilities []Capability `json:"capabilities,omitempty"` | ||
| ConsoleURL *string `json:"consoleURL,omitempty"` |
There was a problem hiding this comment.
Ensure proper JSON field naming conventions.
The ConsoleURL field should follow the JSON naming conventions. Ensure consistency with other fields.
ConsoleURL *string `json:"consoleURL,omitempty"`Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| ConsoleURL *string `json:"consoleURL,omitempty"` | |
| ConsoleURL *string `json:"consoleURL,omitempty"` |
| // GetConsoleURL returns the ConsoleURL field value if set, zero value otherwise. | ||
| func (o *ServerInfo) GetConsoleURL() string { | ||
| if o == nil || IsNil(o.ConsoleURL) { | ||
| var ret string | ||
| return ret | ||
| } | ||
| return *o.ConsoleURL | ||
| } |
There was a problem hiding this comment.
Ensure proper handling of nil values in GetConsoleURL.
The GetConsoleURL method should handle nil values properly. Consider returning an empty string or a default value if ConsoleURL is nil.
func (o *ServerInfo) GetConsoleURL() string {
if o == nil || IsNil(o.ConsoleURL) {
return ""
}
return *o.ConsoleURL
}Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| // GetConsoleURL returns the ConsoleURL field value if set, zero value otherwise. | |
| func (o *ServerInfo) GetConsoleURL() string { | |
| if o == nil || IsNil(o.ConsoleURL) { | |
| var ret string | |
| return ret | |
| } | |
| return *o.ConsoleURL | |
| } | |
| // GetConsoleURL returns the ConsoleURL field value if set, zero value otherwise. | |
| func (o *ServerInfo) GetConsoleURL() string { | |
| if o == nil || IsNil(o.ConsoleURL) { | |
| return "" | |
| } | |
| return *o.ConsoleURL | |
| } |
| dashboard := "https://console.formance.cloud" | ||
| serverInfo, err := fctl.MembershipServerInfo(cmd.Context(), store.Client()) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if v := serverInfo.ConsoleURL; v != nil { | ||
| dashboard = *v | ||
| } | ||
|
|
There was a problem hiding this comment.
Ensure proper error handling for server information retrieval.
The Run method retrieves server information and updates the dashboard URL based on the ConsoleURL. However, if serverInfo.ConsoleURL is nil, the dashboard remains unchanged. Consider adding a log or a default value to handle this case explicitly.
if v := serverInfo.ConsoleURL; v != nil {
dashboard = *v
} else {
// Log or set a default value
fmt.Println("ConsoleURL is nil, using default dashboard URL")
}Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| dashboard := "https://console.formance.cloud" | |
| serverInfo, err := fctl.MembershipServerInfo(cmd.Context(), store.Client()) | |
| if err != nil { | |
| return nil, err | |
| } | |
| if v := serverInfo.ConsoleURL; v != nil { | |
| dashboard = *v | |
| } | |
| dashboard := "https://console.formance.cloud" | |
| serverInfo, err := fctl.MembershipServerInfo(cmd.Context(), store.Client()) | |
| if err != nil { | |
| return nil, err | |
| } | |
| if v := serverInfo.ConsoleURL; v != nil { | |
| dashboard = *v | |
| } else { | |
| // Log or set a default value | |
| fmt.Println("ConsoleURL is nil, using default dashboard URL") | |
| } | |
| dashboard = *v | ||
| } | ||
|
|
||
| fctl.BasicTextCyan.WithWriter(cmd.OutOrStdout()).Println("Your dashboard will be reachable on: " + dashboard) |
There was a problem hiding this comment.
Ensure consistency in setting the dashboard URL.
The dashboard URL is set to the dashboard variable, which is dynamically determined. Ensure this is consistent across all usages.
fctl.BasicTextCyan.WithWriter(cmd.OutOrStdout()).Println("Your dashboard will be reachable on: " + dashboard)Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| fctl.BasicTextCyan.WithWriter(cmd.OutOrStdout()).Println("Your dashboard will be reachable on: " + dashboard) | |
| fctl.BasicTextCyan.WithWriter(cmd.OutOrStdout()).Println("Your dashboard will be reachable on: " + dashboard) |
No description provided.