Skip to content

feat(fctl): use membership/_info to expose console_url#1495

Merged
Dav-14 merged 1 commit intomainfrom
feat/eng-827-featmembership-use-_info-link-to-dashboard
May 15, 2024
Merged

feat(fctl): use membership/_info to expose console_url#1495
Dav-14 merged 1 commit intomainfrom
feat/eng-827-featmembership-use-_info-link-to-dashboard

Conversation

@Dav-14
Copy link
Copy Markdown
Contributor

@Dav-14 Dav-14 commented May 15, 2024

No description provided.

@Dav-14 Dav-14 requested a review from a team as a code owner May 15, 2024 10:04
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2024

Walkthrough

The 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 StackCreateController, Stack struct, and UiController, along with enhancements to the ServerInfo struct to support the new ConsoleURL field and associated methods.

Changes

Files & Paths Change Summary
components/fctl/cmd/stack/create.go Updated logic to determine the dashboard URL based on server info.
components/fctl/cmd/stack/list.go Dynamically set Dashboard URL for each Stack based on ConsoleURL from serverInfo.
components/fctl/cmd/ui/ui.go Updated UiController to retrieve server info and update UI URL based on ConsoleURL.
components/fctl/membershipclient/docs/ServerInfo.md Added ConsoleURL field and associated methods in ServerInfo struct.
components/fctl/membershipclient/model_server_info.go Enhanced ServerInfo struct with ConsoleURL field and methods to get, set, and check its value.

In code, we found a path so bright,
URLs now set just right,
With ConsoleURL in our sight,
Dashboards glow in the user's light.
🐇✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

Commits Files that changed from the base of the PR and between 02ac064 and 00e36ac.
Files ignored due to path filters (3)
  • components/fctl/membership-swagger.yaml is excluded by !**/*.yaml
  • components/fctl/membershipclient/api/openapi.yaml is excluded by !**/*.yaml
  • components/fctl/membershipclient/go.sum is 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. ### GetCapabilities func (o ...


Near line 101: Unpaired symbol: ‘[’ seems to be missing
Context: ...ld has been set. [Back to Model list] ...

Comment thread components/fctl/cmd/ui/ui.go
Comment on lines +68 to 70

if err := openUrl(c.store.UIUrl); err != nil {
c.store.FoundBrowser = true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 = true

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.

Suggested change
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

Comment thread components/fctl/cmd/ui/ui.go
Comment on lines 7 to +9
**Version** | **string** | |
**Capabilities** | Pointer to [**[]Capability**](Capability.md) | | [optional]
**ConsoleURL** | Pointer to **string** | | [optional]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Suggested change
**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]

Comment on lines +75 to +99
### 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Suggested change
### 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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Suggested change
Dashboard: dashboard,
Dashboard: dashboard,

type ServerInfo struct {
Version string `json:"version"`
Capabilities []Capability `json:"capabilities,omitempty"`
ConsoleURL *string `json:"consoleURL,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Suggested change
ConsoleURL *string `json:"consoleURL,omitempty"`
ConsoleURL *string `json:"consoleURL,omitempty"`

Comment on lines +101 to +108
// 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
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Suggested change
// 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
}

Comment on lines +180 to +188
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
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Suggested change
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Suggested change
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)

@Dav-14 Dav-14 enabled auto-merge May 15, 2024 10:16
@Dav-14 Dav-14 added this pull request to the merge queue May 15, 2024
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 15, 2024
@Dav-14 Dav-14 added this pull request to the merge queue May 15, 2024
Merged via the queue into main with commit 2a8d9de May 15, 2024
@Dav-14 Dav-14 deleted the feat/eng-827-featmembership-use-_info-link-to-dashboard branch May 15, 2024 11:18
@Dav-14 Dav-14 restored the feat/eng-827-featmembership-use-_info-link-to-dashboard branch May 22, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants