Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Support organizations/unknown#778

Merged
melinath merged 7 commits into
GoogleCloudPlatform:mainfrom
iyabchen:org-unknown
Jun 30, 2022
Merged

Support organizations/unknown#778
melinath merged 7 commits into
GoogleCloudPlatform:mainfrom
iyabchen:org-unknown

Conversation

@iyabchen

@iyabchen iyabchen commented Jun 22, 2022

Copy link
Copy Markdown
Contributor

DO_NOT_MERGE
This is just a draft, and requires magic modules change as well.

@iyabchen iyabchen marked this pull request as ready for review June 22, 2022 14:31
@iyabchen iyabchen requested review from a team and melinath and removed request for a team June 22, 2022 14:31

@melinath melinath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

overall looking good, have a few questions & change requests.

Comment thread converters/google/resources/project.go Outdated
name, err := assetName(d, config, linkTmpl)
if err != nil {
return []Asset{}, err
name = fmt.Sprintf("//cloudresourcemanager.googleapis.com/projects/placeholder-%s", randString(8))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could this be handled in assetName instead of in this file? That would allow it to be centralized for all project-level resources

@melinath melinath Jun 22, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the long run, this might need to be fixed at a higher level - the project and billing info both get created from the same resource data, which means that they should technically have the same project ID. But in practice, it probably doesn't matter since they're separate asset types and (presumably) haven't been created yet.

For now - fixing this in assetName should be fine (and much simpler)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I handled this in transport.go, after trying all kinds of getting project failed, it returns a placeholder-project string, while terraform data's project id is still an empty string. In ancestry manager, if terraform data project id is empty, then trigger the org/unknown handling.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That probably would work - but unfortunately, we can't make that change in transport.go because it's shared with the Terraform provider. Could it happen in assetName instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a workaround there to temporarily set the config's project, and unset it later, else need to copy the build template function over?

Comment thread ancestrymanager/ancestrymanager.go Outdated
Comment thread ancestrymanager/ancestrymanager_test.go Outdated
Comment thread testdata/templates/example_project_create_empty_project_id.json Outdated
@melinath melinath self-requested a review June 24, 2022 20:47
Comment thread converters/google/resources/project.go Outdated
name, err := assetName(d, config, linkTmpl)
if err != nil {
return []Asset{}, err
name = fmt.Sprintf("//cloudresourcemanager.googleapis.com/projects/placeholder-%s", randString(8))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That probably would work - but unfortunately, we can't make that change in transport.go because it's shared with the Terraform provider. Could it happen in assetName instead?

Comment thread testdata/templates/example_project_create_empty_project_id.json Outdated

@melinath melinath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM - one potential change

Comment thread converters/google/resources/cai.go Outdated
@melinath

Copy link
Copy Markdown
Member

/gcbrun - the test failures look unrelated and maybe flakey?

@melinath melinath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants