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

fix: listing ref #3387

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions apis/bigqueryanalyticshub/v1alpha1/listing_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ func NewBigQueryAnalyticsHubListingRef(ctx context.Context, reader client.Reader
return nil, fmt.Errorf("cannot parse dataExchangeRef for listing ref: %w", err)
}

id.parent = &BigQueryAnalyticsHubListingParent{ProjectID: projectID, Location: location, DataExchangeID: dataExchangeID.ID()}
deID := dataExchangeID.ID()
id.parent = &BigQueryAnalyticsHubListingParent{ProjectID: projectID, Location: location, DataExchangeID: deID}

// Get desired ID
resourceID := valueOf(obj.Spec.ResourceID)
Expand All @@ -127,6 +128,9 @@ func NewBigQueryAnalyticsHubListingRef(ctx context.Context, reader client.Reader
if resourceID == "" {
return nil, fmt.Errorf("cannot resolve resource ID")
}
if deID == "" {
return nil, fmt.Errorf("cannot resolve dataExchange ID")
}

// Use approved External
externalRef := valueOf(obj.Status.ExternalRef)
Expand All @@ -150,8 +154,12 @@ func NewBigQueryAnalyticsHubListingRef(ctx context.Context, reader client.Reader
return nil, fmt.Errorf("cannot reset `metadata.name` or `spec.resourceID` to %s, since it has already assigned to %s",
resourceID, actualResourceID)
}
if actualParent.DataExchangeID != deID {
return nil, fmt.Errorf("spec.dataExchangeRef changed, expect %s, got %s", actualParent.DataExchangeID, deID)
}

id.External = externalRef
id.parent = &BigQueryAnalyticsHubListingParent{ProjectID: projectID, Location: location}
id.parent = &BigQueryAnalyticsHubListingParent{ProjectID: projectID, Location: location, DataExchangeID: deID}
return id, nil
}

Expand Down
Loading