Skip to content

Database + analytics base resources#167

Open
lpatte wants to merge 11 commits intomainfrom
dev/lpatte/managed-database-mvp
Open

Database + analytics base resources#167
lpatte wants to merge 11 commits intomainfrom
dev/lpatte/managed-database-mvp

Conversation

@lpatte
Copy link
Copy Markdown

@lpatte lpatte commented Mar 31, 2026

Description

  • Renaming command name to managed-database
  • Create managed-analytics to follow existing split
  • Rework existing code
  • Add user management
  • Add role management
  • Add Certificate management
  • Add ACL management (permission + pattern)
  • Add Topics management (+ TopicALC)
  • Change OutputError to not Exit in UnitTest
  • Update reference
  • Fix filter "=="
  • Update Doc : Make doc : Add Database + Analytics and fix filter "==" in doc

Fixes #123

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (improvement of existing commands)
  • Breaking change (fix or feature that can break a current behavior)
  • Documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have commented my code
  • I ran go mod tidy
  • I have added tests that prove my fix is effective or that my feature works

@lpatte lpatte requested a review from a team as a code owner March 31, 2026 09:10
lpatte and others added 7 commits March 31, 2026 09:46
…topics

Signed-off-by: Ludwig Patte <ludwig.patte@ovhcloud.com>
Add markFlagsMutuallyExclusive and markFlagsOneRequired helper functions
that filter out unregistered flags before calling Cobra, preventing panics
when flags are conditionally excluded (e.g. in WASM builds where
addParameterFileFlags skips registering --from-file).

Migrate all call sites across 19 command files to use the safe wrappers.
Move MarkFlagsMutuallyExclusive calls outside unnecessary WASM guards in
vps.go, cloud_kube.go, and cloud_instance.go so mutual exclusivity is
correctly enforced for flags that do exist in WASM mode.

Signed-off-by: Romain Beuque <556072+rbeuque74@users.noreply.github.com>
Implement full lifecycle management for OVHcloud IP firewall (AntiDDoS/
Edge Firewall) under the `ovhcloud ip firewall` command tree:

- ip firewall list/add/get/enable/disable/delete
- ip firewall rule list/get/create/delete

Includes service layer, display templates, command registration,
tests with RFC 5737 documentation IPs, and generated doc pages.

Signed-off-by: pablotoledo <jptgjuanpablo@gmail.com>
Signed-off-by: Ludwig Patte <ludwig.patte@ovhcloud.com>
…or firewall rules

Signed-off-by: pablotoledo <jptgjuanpablo@gmail.com>
Signed-off-by: Ludwig Patte <ludwig.patte@ovhcloud.com>
Signed-off-by: Arthur Amstutz <arthur.amstutz@gmail.com>
Signed-off-by: Ludwig Patte <ludwig.patte@ovhcloud.com>
Signed-off-by: Arthur Amstutz <arthur.amstutz@gmail.com>
Signed-off-by: Ludwig Patte <ludwig.patte@ovhcloud.com>
Signed-off-by: Ludwig Patte <ludwig.patte@ovhcloud.com>
@lpatte lpatte force-pushed the dev/lpatte/managed-database-mvp branch from c61aa20 to e378d15 Compare March 31, 2026 09:50
…naged-database-mvp

Signed-off-by: Ludwig Patte <ludwig.patte@ovhcloud.com>
@lpatte lpatte requested a review from Copilot March 31, 2026 11:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces first-class Public Cloud “Managed Database” and “Managed Analytics” base resources in the CLI, splitting the previously combined database-service surface area into two product families and updating the CLI browser + documentation accordingly (Fixes #123).

Changes:

  • Add Managed Database / Managed Analytics output templates and parameter samples used by the interactive editor and object rendering.
  • Extend cloud reference with managed-database and new managed-analytics reference subcommands (plans, flavors, engines), and update the browser navigation to split the products.
  • Rework error/exit behavior to be unit-test friendly (avoid hard os.Exit by allowing override), and update docs to use the correct filter equality operator (==).

Reviewed changes

Copilot reviewed 233 out of 234 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
internal/services/cloud/templates/cloud_managed_database.tmpl Adds managed-database service “get” template output.
internal/services/cloud/templates/cloud_managed_database_user.tmpl Adds managed-database user “get” template output (roles/valkey permissions).
internal/services/cloud/templates/cloud_managed_database_database.tmpl Adds managed-database database “get” template output.
internal/services/cloud/templates/cloud_managed_database_certificate.tmpl Adds managed-database certificate “get” template output.
internal/services/cloud/templates/cloud_managed_database_backup.tmpl Adds managed-database backup “get” template output.
internal/services/cloud/templates/cloud_managed_analytics.tmpl Adds managed-analytics service “get” template output.
internal/services/cloud/templates/cloud_managed_analytics_user.tmpl Adds managed-analytics user “get” template output (roles / OpenSearch ACLs).
internal/services/cloud/templates/cloud_managed_analytics_topic.tmpl Adds managed-analytics topic “get” template output.
internal/services/cloud/templates/cloud_managed_analytics_topic_acl.tmpl Adds managed-analytics topic ACL “get” template output.
internal/services/cloud/templates/cloud_managed_analytics_pattern.tmpl Adds managed-analytics pattern “get” template output.
internal/services/cloud/templates/cloud_managed_analytics_database.tmpl Adds managed-analytics database “get” template output.
internal/services/cloud/templates/cloud_managed_analytics_certificate.tmpl Adds managed-analytics certificate “get” template output.
internal/services/cloud/templates/cloud_managed_analytics_backup.tmpl Adds managed-analytics backup “get” template output.
internal/services/cloud/parameter-samples/managed-database-user-create.json Adds managed-database user create sample for editor workflow.
internal/services/cloud/parameter-samples/managed-database-create.json Adds managed-database service create sample for editor workflow.
internal/services/cloud/parameter-samples/managed-analytics-user-create.json Adds managed-analytics user create sample for editor workflow.
internal/services/cloud/parameter-samples/managed-analytics-topic-create.json Adds managed-analytics topic create sample for editor workflow.
internal/services/cloud/parameter-samples/managed-analytics-pattern-create.json Adds managed-analytics pattern create sample for editor workflow.
internal/services/cloud/parameter-samples/managed-analytics-create.json Adds managed-analytics service create sample for editor workflow.
internal/services/cloud/parameter-samples/database-create.json Removes old database-service create sample.
internal/services/cloud/cloud_reference.go Adds managed-analytics reference listing + refines managed-database engines output formatting.
internal/services/browser/manager.go Splits “Databases” into “Managed Databases” + “Managed Analytics” in the browser nav and creation hints.
internal/services/browser/api.go Fetches database services filtered by category for /databases vs /analytics.
internal/display/display.go Introduces ExitFunc indirection to avoid hard exits in unit tests.
internal/cmd/root.go Resets stringSlice flags too; fixes filter help example to use ==.
internal/cmd/cmd_test.go Overrides display.ExitFunc in test setup.
internal/cmd/cloud_reference.go Renames reference group to managed-database and adds managed-analytics reference group.
internal/cmd/cloud_reference_test.go Updates tests to target cloud reference managed-database ....
internal/cmd/cloud_project.go Registers managed-database + managed-analytics command initializers.
internal/cmd/cloud_database.go Removes legacy database-service command implementation.
internal/cmd/cloud_database_test.go Removes legacy database-service command tests.
doc/ovhcloud_cloud.md Removes database-service entry; adds managed-database + managed-analytics entries.
doc/ovhcloud_cloud_reference.md Updates reference index to managed-database + managed-analytics.
doc/ovhcloud_cloud_reference_managed-database.md Adds managed-database reference docs index.
doc/ovhcloud_cloud_reference_managed-database_list-plans.md Adds managed-database reference list-plans docs.
doc/ovhcloud_cloud_reference_managed-database_list-node-flavors.md Adds managed-database reference list-node-flavors docs.
doc/ovhcloud_cloud_reference_managed-database_list-engines.md Adds managed-database reference list-engines docs.
doc/ovhcloud_cloud_reference_managed-analytics.md Adds managed-analytics reference docs index.
doc/ovhcloud_cloud_reference_managed-analytics_list-plans.md Adds managed-analytics reference list-plans docs.
doc/ovhcloud_cloud_reference_managed-analytics_list-node-flavors.md Adds managed-analytics reference list-node-flavors docs.
doc/ovhcloud_cloud_reference_managed-analytics_list-engines.md Adds managed-analytics reference list-engines docs.
doc/ovhcloud_cloud_managed-database.md Adds managed-database command docs index.
doc/ovhcloud_cloud_managed-database_create.md Adds managed-database create docs.
doc/ovhcloud_cloud_managed-database_edit.md Updates managed-database edit docs (renamed from database-service).
doc/ovhcloud_cloud_managed-database_delete.md Updates managed-database delete docs (renamed from database-service).
doc/ovhcloud_cloud_managed-database_list.md Updates managed-database list docs (renamed from database-service).
doc/ovhcloud_cloud_managed-database_get.md Updates managed-database get docs (renamed from database-service).
doc/ovhcloud_cloud_managed-database_database.md Updates managed-database database subcommand docs index.
doc/ovhcloud_cloud_managed-database_database_create.md Adds managed-database database create docs.
doc/ovhcloud_cloud_managed-database_database_delete.md Updates managed-database database delete docs.
doc/ovhcloud_cloud_managed-database_database_get.md Updates managed-database database get docs.
doc/ovhcloud_cloud_managed-database_database_list.md Adds managed-database database list docs.
doc/ovhcloud_cloud_managed-database_user.md Adds managed-database user docs index.
doc/ovhcloud_cloud_managed-database_user_create.md Adds managed-database user create docs.
doc/ovhcloud_cloud_managed-database_user_edit.md Adds managed-database user edit docs.
doc/ovhcloud_cloud_managed-database_user_delete.md Adds managed-database user delete docs.
doc/ovhcloud_cloud_managed-database_user_get.md Adds managed-database user get docs.
doc/ovhcloud_cloud_managed-database_user_list.md Adds managed-database user list docs.
doc/ovhcloud_cloud_managed-database_user_credentials-reset.md Adds managed-database user credentials-reset docs.
doc/ovhcloud_cloud_managed-database_role.md Adds managed-database role docs index.
doc/ovhcloud_cloud_managed-database_role_list.md Adds managed-database role list docs.
doc/ovhcloud_cloud_managed-database_certificate.md Adds managed-database certificate docs index.
doc/ovhcloud_cloud_managed-database_certificate_get.md Adds managed-database certificate get docs.
doc/ovhcloud_cloud_managed-database_backup.md Adds managed-database backup docs index.
doc/ovhcloud_cloud_managed-database_backup_list.md Adds managed-database backup list docs.
doc/ovhcloud_cloud_managed-database_backup_get.md Adds managed-database backup get docs.
doc/ovhcloud_cloud_managed-database_backup_restore.md Adds managed-database backup restore docs.
doc/ovhcloud_cloud_managed-analytics.md Adds managed-analytics command docs index.
doc/ovhcloud_cloud_managed-analytics_create.md Adds managed-analytics create docs.
doc/ovhcloud_cloud_managed-analytics_edit.md Adds managed-analytics edit docs.
doc/ovhcloud_cloud_managed-analytics_delete.md Adds managed-analytics delete docs.
doc/ovhcloud_cloud_managed-analytics_list.md Adds managed-analytics list docs.
doc/ovhcloud_cloud_managed-analytics_get.md Adds managed-analytics get docs.
doc/ovhcloud_cloud_managed-analytics_database.md Adds managed-analytics database docs index.
doc/ovhcloud_cloud_managed-analytics_database_create.md Adds managed-analytics database create docs.
doc/ovhcloud_cloud_managed-analytics_database_delete.md Adds managed-analytics database delete docs.
doc/ovhcloud_cloud_managed-analytics_database_get.md Adds managed-analytics database get docs.
doc/ovhcloud_cloud_managed-analytics_database_list.md Adds managed-analytics database list docs.
doc/ovhcloud_cloud_managed-analytics_user.md Adds managed-analytics user docs index.
doc/ovhcloud_cloud_managed-analytics_user_create.md Adds managed-analytics user create docs.
doc/ovhcloud_cloud_managed-analytics_user_edit.md Adds managed-analytics user edit docs.
doc/ovhcloud_cloud_managed-analytics_user_delete.md Adds managed-analytics user delete docs.
doc/ovhcloud_cloud_managed-analytics_user_get.md Adds managed-analytics user get docs.
doc/ovhcloud_cloud_managed-analytics_user_list.md Adds managed-analytics user list docs.
doc/ovhcloud_cloud_managed-analytics_user_credentials-reset.md Adds managed-analytics user credentials-reset docs.
doc/ovhcloud_cloud_managed-analytics_role.md Adds managed-analytics role docs index.
doc/ovhcloud_cloud_managed-analytics_role_list.md Adds managed-analytics role list docs.
doc/ovhcloud_cloud_managed-analytics_permission.md Adds managed-analytics permission docs index.
doc/ovhcloud_cloud_managed-analytics_permission_list.md Adds managed-analytics permission list docs.
doc/ovhcloud_cloud_managed-analytics_pattern.md Adds managed-analytics pattern docs index.
doc/ovhcloud_cloud_managed-analytics_pattern_create.md Adds managed-analytics pattern create docs.
doc/ovhcloud_cloud_managed-analytics_pattern_delete.md Adds managed-analytics pattern delete docs.
doc/ovhcloud_cloud_managed-analytics_pattern_get.md Adds managed-analytics pattern get docs.
doc/ovhcloud_cloud_managed-analytics_pattern_list.md Adds managed-analytics pattern list docs.
doc/ovhcloud_cloud_managed-analytics_topic.md Adds managed-analytics topic docs index.
doc/ovhcloud_cloud_managed-analytics_topic_create.md Adds managed-analytics topic create docs.
doc/ovhcloud_cloud_managed-analytics_topic_edit.md Adds managed-analytics topic edit docs.
doc/ovhcloud_cloud_managed-analytics_topic_delete.md Adds managed-analytics topic delete docs.
doc/ovhcloud_cloud_managed-analytics_topic_get.md Adds managed-analytics topic get docs.
doc/ovhcloud_cloud_managed-analytics_topic_list.md Adds managed-analytics topic list docs.
doc/ovhcloud_cloud_managed-analytics_topic-acl.md Adds managed-analytics topic-acl docs index.
doc/ovhcloud_cloud_managed-analytics_topic-acl_create.md Adds managed-analytics topic-acl create docs.
doc/ovhcloud_cloud_managed-analytics_topic-acl_delete.md Adds managed-analytics topic-acl delete docs.
doc/ovhcloud_cloud_managed-analytics_topic-acl_get.md Adds managed-analytics topic-acl get docs.
doc/ovhcloud_cloud_managed-analytics_topic-acl_list.md Adds managed-analytics topic-acl list docs.
doc/ovhcloud_cloud_managed-analytics_backup.md Adds managed-analytics backup docs index.
doc/ovhcloud_cloud_managed-analytics_backup_get.md Adds managed-analytics backup get docs.
doc/ovhcloud_cloud_managed-analytics_backup_list.md Adds managed-analytics backup list docs.
doc/ovhcloud_cloud_managed-analytics_certificate.md Adds managed-analytics certificate docs index.
doc/ovhcloud_cloud_managed-analytics_certificate_get.md Adds managed-analytics certificate get docs.
doc/ovhcloud_cloud_database-service.md Removes legacy database-service docs entry.
doc/ovhcloud_*.md (many list docs) Bulk doc regeneration updating filter example from = to == across commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 22 to 25
func (ms *MockSuite) Setup(t *td.T) error {
httpmock.Activate(t)
display.ExitFunc = func(int) {}

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

display.ExitFunc is overwritten in Setup but never restored, so it can leak into other tests (and make failures harder to diagnose if any test expects the default os.Exit). Store the previous value and restore it in PostTest (or via a cleanup hook) so each test runs with a clean global state.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ExitFunc is intentionally set once in Setup for the entire test suite — no test in this package expects the real os.Exit behavior. The no-op override is the desired state for all tests, so there's nothing to restore. Saving/restoring it in PostTest would just be unnecessary code.

Signed-off-by: Ludwig Patte <ludwig.patte@ovhcloud.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 233 out of 234 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Ludwig Patte <ludwig.patte@ovhcloud.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 233 out of 234 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 621 to 625
// First, get the list of database service IDs (the API returns an array of strings)
var serviceIDs []string
endpoint := fmt.Sprintf("/v1/cloud/project/%s/database/service", m.cloudProject)
endpoint := fmt.Sprintf("/v1/cloud/project/%s/database/service?category=%s", m.cloudProject, category)
err := httpLib.Client.Get(endpoint, &serviceIDs)
if err != nil {
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

category is interpolated directly into the query string. Even if current call sites pass constants, this helper accepts arbitrary strings, so a value containing &/? would break the request (or unintentionally add extra query params). Build the URL using url.Values (or at least url.QueryEscape(category)) to ensure correct escaping.

Copilot uses AI. Check for mistakes.
Signed-off-by: Ludwig Patte <ludwig.patte@ovhcloud.com>
@lpatte lpatte requested a review from Copilot March 31, 2026 14:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 233 out of 234 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

func ListDatabasesPlans(_ *cobra.Command, _ []string) {
func ListManagedDatabasesPlans(_ *cobra.Command, _ []string) {
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The function name ListManagedDatabasesPlans is inconsistent with the other managed database reference helpers (ListManagedDatabaseNodeFlavors, ListManagedDatabaseEngines). Consider renaming it to ListManagedDatabasePlans (singular) for consistency and discoverability, and update the corresponding cobra command wiring.

Copilot uses AI. Check for mistakes.
Comment on lines +289 to +295
func ListManagedAnalyticsPlans(_ *cobra.Command, _ []string) {
projectID, err := getConfiguredCloudProject()
if err != nil {
display.OutputError(&flags.OutputFormatConfig, "%s", err)
return
}

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

ListManagedAnalyticsPlans, ListManagedAnalyticsNodeFlavors, and ListManagedAnalyticsEngines largely duplicate the managed-database equivalents (same endpoint, same parsing/formatting, only filter criteria differ). To reduce drift and simplify future changes, consider extracting shared helpers (e.g., a generic capabilities fetch + per-section formatter/filter).

Copilot uses AI. Check for mistakes.
Comment on lines +679 to +681
if !slices.Contains(ManagedDatabaseRoleValidEngines, databaseService["engine"].(string)) {
display.OutputError(&flags.OutputFormatConfig, "invalid engine %s, valid values: %s", databaseService["engine"].(string), strings.Join(ManagedDatabaseValidEngines, ", "))
return
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

This branch validates against ManagedDatabaseRoleValidEngines, but the error message lists ManagedDatabaseValidEngines. That will advertise engines (e.g. mysql/valkey) that are not actually supported for roles. Use ManagedDatabaseRoleValidEngines in the message to keep it accurate.

Copilot uses AI. Check for mistakes.
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.

[Feature]: Databases & Analytics: create, delete, edit, list, and get a service

5 participants