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

Set spec.owner on root resource of import #4611

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

theunrepentantgeek
Copy link
Member

What this PR does

Sets the spec.owner of each root resource specified when importing existing Azure resources, using the ARM ID of the parent resource.

Closes #4564

Example: If you import a Storage Account:

/subscriptions/<subscriptionid>/resourceGroups/<resourcegroup>/providers/Microsoft.Storage/storageAccounts/storageacct

The owner will be set to the resource group

  owner:
    armId: /subscriptions/<subscriptionid>/resourceGroups/<resourcegroup>

How does this PR make you feel?

gif

Choose a reason for hiding this comment

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

PR Overview

This PR sets the spec.owner for root resources during Azure resource imports by determining the owner from the ARM ID of the parent resource. Key changes include:

  • Introducing the createOwnerFor method in the resource importer to extract a parent ARM ID.
  • Adding helper methods (AsArbitraryOwnerReference and AsKnownResourceReference) in the ResourceReference type.
  • Updating resource importer and importable ARM resource logic to use the new owner reference extraction methods.

Reviewed Changes

File Description
v2/cmd/asoctl/pkg/importresources/resource_importer.go Adds owner extraction logic and proper error wrapping when creating an importer using a parent resource’s ARM ID.
v2/pkg/genruntime/resource_reference.go Introduces and/or updates helper functions to convert a ResourceReference to owner reference types.
v2/cmd/asoctl/pkg/importresources/importable_arm_resource.go Refactors inline owner reference synthesis to use the new helper functions in ResourceReference.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Bug: asoctl-imported AKS resource has no spec.owner field
1 participant