Skip to content

feat(core): migrate registered resources#772

Merged
alkalescent merged 22 commits intomainfrom
DSPX-2496-migration-script
Mar 19, 2026
Merged

feat(core): migrate registered resources#772
alkalescent merged 22 commits intomainfrom
DSPX-2496-migration-script

Conversation

@alkalescent
Copy link
Copy Markdown
Contributor

@alkalescent alkalescent commented Mar 10, 2026

This PR adds a migration command and tests for legacy RRs to namespaced RRs.

@alkalescent alkalescent requested a review from a team as a code owner March 10, 2026 21:04
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a crucial migration utility to transition existing registered resources into a namespaced structure. This change enhances the organization and management of resources by assigning them to specific namespaces, aligning with modern policy management practices. The new command provides flexible execution options, allowing users to perform migrations interactively or in a batch, while also emphasizing data safety through a pre-migration backup prompt.

Highlights

  • New Migration Command: A new migrate command has been introduced to the CLI, specifically designed for managing resource migrations.
  • Registered Resources Migration: A new subcommand migrate registered-resources is available to migrate legacy registered resources that lack namespace assignments into namespaced resources.
  • Interactive and Batch Modes: The migration process supports both interactive (per-resource prompting) and batch (single namespace for all resources) modes, controlled by --interactive and --commit flags.
  • Data Integrity and Backup: The migration includes a mandatory backup confirmation step, as the process involves deleting and re-creating resources, ensuring user awareness of potential data changes.
  • Comprehensive Testing: Unit tests have been added for the migration logic, utilizing a mock handler to ensure the migration process functions as expected.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • cmd/migrate.go
    • Added new file to define the migrate command and its registered-resources subcommand.
    • Implemented logic to parse commit and interactive flags for migration execution.
  • cmd/root.go
    • Modified init function to integrate the new migrate subcommand into the root command structure.
  • migrations/registered-resources.go
    • Added new file containing the core logic for migrating registered resources to namespaces.
    • Implemented functions to build migration plans, fetch resource values, and list available namespaces.
    • Introduced runBatchRegisteredResourceMigration and runInteractiveRegisteredResourceMigration for different user experiences.
    • Developed commitRegisteredResourceMigration to handle the re-creation of resources under new namespaces and deletion of old ones.
    • Included a backupForm to prompt users for backup confirmation before proceeding with the migration.
  • migrations/registered-resources_test.go
    • Added new file containing unit tests for the registered resources migration logic.
    • Implemented MockMigrationHandler to simulate API interactions for isolated testing.
    • Provided tests for plan building, commit operations, namespace option generation, and action-attribute value conversion.
  • migrations/styles.go
    • Added new file to define lipgloss styles for consistent and visually appealing CLI output during migrations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a new migrate command to the otdfctl CLI, enabling the migration of registered resources to specific namespaces. This functionality includes identifying resources without assigned namespaces, providing interactive or batch modes for selecting target namespaces, re-creating resources and their values under the new namespace while preserving metadata and action-attribute mappings, and subsequently deleting the original resources. The implementation also features a critical backup confirmation step and comprehensive unit tests. A consistent improvement opportunity highlighted in the review comments is to enhance error handling by wrapping returned errors with fmt.Errorf("message: %w", err) across various functions within migrations/registered-resources.go to ensure better debugging context and error traceability.

Comment thread migrations/registered-resources.go Outdated
Comment thread migrations/registered-resources.go
Comment thread migrations/registered-resources.go
Comment thread migrations/registered-resources.go
Comment thread migrations/registered-resources.go
Comment thread migrations/registered-resources.go
@github-actions
Copy link
Copy Markdown

Comment thread migrations/registered-resources.go Outdated
Comment thread migrations/registered-resources.go Outdated
Comment thread migrations/registered-resources.go
Comment thread migrations/registered-resources.go Outdated
Base automatically changed from DSPX-2496-ns-rr to main March 11, 2026 16:27
@alkalescent alkalescent requested a review from a team as a code owner March 11, 2026 16:27
@github-actions
Copy link
Copy Markdown

@alkalescent
Copy link
Copy Markdown
Contributor Author

alkalescent commented Mar 11, 2026

note to self:

  • support not only fqn but also id for namespace flag for get RR cmd
  • bump protocol/go

@github-actions
Copy link
Copy Markdown

@alkalescent alkalescent marked this pull request as draft March 11, 2026 21:59
@github-actions
Copy link
Copy Markdown

X-Test Failure Report

@github-actions
Copy link
Copy Markdown

@alkalescent alkalescent marked this pull request as ready for review March 12, 2026 16:50
@github-actions
Copy link
Copy Markdown

X-Test Failure Report

@github-actions
Copy link
Copy Markdown

elizabethhealy
elizabethhealy previously approved these changes Mar 12, 2026
Copy link
Copy Markdown
Member

@elizabethhealy elizabethhealy left a comment

Choose a reason for hiding this comment

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

should this happen on the backend instead?

@alkalescent
Copy link
Copy Markdown
Contributor Author

should this happen on the backend instead?

Lmk if this answers your question: opentdf/platform#3111 (comment)

Copy link
Copy Markdown
Contributor

@c-r33d c-r33d left a comment

Choose a reason for hiding this comment

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

I think it looks good, a couple questions I have though:

1.) Is there a better way we can test the interactive mode. Before I used expect, which ended up not being great. (Super flakey tests -- prob user error).

@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

@alkalescent alkalescent merged commit 2b49a7d into main Mar 19, 2026
20 checks passed
@alkalescent alkalescent deleted the DSPX-2496-migration-script branch March 19, 2026 18:28
alkalescent pushed a commit that referenced this pull request Mar 31, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.30.0](v0.29.0...v0.30.0)
(2026-03-31)


### Features

* **core:** Add optional namespace flag for subject mappings and
condtion sets ([#779](#779))
([9e849c4](9e849c4))
* **core:** add scope support for client creds
([#752](#752))
([9ca9e43](9ca9e43))
* **core:** migrate registered resources
([#772](#772))
([2b49a7d](2b49a7d))
* **core:** optional namespace in actions commands and re-enable
actions/RR tests ([#775](#775))
([29a2eb1](29a2eb1))
* **core:** support namespaced registered resources
([#767](#767))
([4d786b5](4d786b5))


### Bug Fixes

* **ci:** Temporarily skip namespaced-actions impacted BATS cases
([#773](#773))
([633728a](633728a))
* **core:** bump toolchain to go 1.24.13
([#747](#747))
([6804b93](6804b93))
* **core:** disable RR E2E tests
([#768](#768))
([0821b8c](0821b8c))
* **core:** make namespacing registered resources optional
([#785](#785))
([8e6eb31](8e6eb31))
* **core:** refactor `ListAttributesValues` to use `Get`
([#769](#769))
([a82f7b7](a82f7b7))
* **core:** unsafe update result output values order
([#759](#759))
([baeba0f](baeba0f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
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.

3 participants