Skip to content
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

Add LogicalName to import system #14745

Merged
merged 1 commit into from Dec 16, 2023
Merged

Add LogicalName to import system #14745

merged 1 commit into from Dec 16, 2023

Conversation

Frassle
Copy link
Member

@Frassle Frassle commented Dec 5, 2023

Description

Fixes #14618.

This adds a new field to the import file "logicalName", which if set is used as the logical name (https://www.pulumi.com/docs/concepts/resources/names/#logicalname) of the resource. The original "name" field is then used just for codegen purposes (i.e. the source name).

If either field is not set then the other field is used to fill it in. If neither field is set it's an error.

Further the import system no longer renames resources to try and make unique names, but it also no longer errors just because two resources of different types have the same name. The rules for uniqueness now match what's valid when writing a Pulumi program, but it is the users responsibility to make names unique and the import system will error if you try to import two resources that would end up with the same URN.

Checklist

  • I have run make tidy to update any new dependencies
  • I have run make lint to verify my code passes the lint check
    • I have formatted my code using gofumpt
  • I have added tests that prove my fix is effective or that my feature works
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version

@pulumi-bot
Copy link
Contributor

pulumi-bot commented Dec 5, 2023

Changelog

[uncommitted] (2023-12-11)

Features

  • [cli/import] Import can now distinguish between logical names and source names.
    #14745

@Frassle Frassle force-pushed the fraser/logicalName branch 3 times, most recently from 3001d7a to 98d6107 Compare December 6, 2023 10:37
@@ -92,7 +146,7 @@ func buildImportFile(events <-chan engine.Event) *promise.Promise[importFile] {
var parent string
if new.Parent != "" {
// If the parent is just the root stack then skip it as we don't need to import that.
if new.Parent.Type() != resource.RootStackType {
if new.Parent.QualifiedType() != resource.RootStackType {
Copy link
Member Author

Choose a reason for hiding this comment

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

Substacks means this should check qualified type not just type. Missed that when adding this.

@Frassle Frassle marked this pull request as ready for review December 11, 2023 16:23
Copy link
Member

@justinvp justinvp left a comment

Choose a reason for hiding this comment

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

The PR needs a description. At a minimum, it would be good to describe how to use logicalName.

Aside from that, looks reasonable.

@Frassle Frassle added this pull request to the merge queue Dec 16, 2023
Merged via the queue into master with commit 810367c Dec 16, 2023
45 checks passed
@Frassle Frassle deleted the fraser/logicalName branch December 16, 2023 11:37
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.

Import: The system is overly strict about unique names, more so than what URNs actually need
3 participants