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 Managed Folder Resource #10670

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

Conversation

hassannmoussaa
Copy link

Adding GCS Managed Folder support in terraform provider

Related Issue : hashicorp/terraform-provider-google#18053

`google_storage_managed_folder`

Terraform configuration

resource "google_storage_managed_folder" "managed_folder" {
    bucket = "bucket here"
    name   = "folder_name"
}

@github-actions github-actions bot requested a review from melinath May 11, 2024 22:08
Copy link

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

@melinath, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician modular-magician added awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests service/storage and removed awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests labels May 11, 2024
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 535 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 4 files changed, 535 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 79 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 111 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 94
Passed tests: 87
Skipped tests: 6
Affected tests: 1

Click here to see the affected service packages
  • storage

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccStorageManagedFolder_googleStorageManagedFolderExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccStorageManagedFolder_googleStorageManagedFolderExample[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

@kautikdk
Copy link
Member

kautikdk commented May 14, 2024

It would be good to add IAM support as well because that's what basic use case of managed folder is.
I don't see couple of read-only fields like metageneration, createTime, updateTime,etc. That fields might not be required for the resource's primary operations but good to add right away in this PR.

Also Managed Folders can not be modified so immutable: true should be added to the resource definition and bucket field is not being passed to the API request body so url_param_only: true can be added to the field definition.

@hassannmoussaa
Copy link
Author

Thank u for your suggestion all, im working on them now to solve them and a push will be added today

@github-actions github-actions bot requested a review from melinath May 14, 2024 20:49
@hassannmoussaa
Copy link
Author

Iam Support is added using

iam_policy: !ruby/object:Api::Resource::IamPolicy
  parent_resource_attribute: 'managedFolders'
  method_name_separator: ':'
  base_url: 'b/{{bucket}}/managedFolders/{{managedFolder}}'
  set_iam_policy_method: 'iam'
  set_iam_policy_verb: :PUT
  fetch_iam_policy_method: 'iam'
  fetch_iam_policy_verb: :POST
  wrapped_policy_obj: false

@modular-magician modular-magician added the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label May 14, 2024
@hassannmoussaa
Copy link
Author

Kindly for the review and support

@modular-magician modular-magician removed the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label May 15, 2024
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 8 files changed, 1109 insertions(+), 3 deletions(-))
google-beta provider: Diff ( 8 files changed, 1109 insertions(+), 3 deletions(-))
terraform-google-conversion: Diff ( 4 files changed, 400 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 112 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_storage_managed_folder_iam_binding (2 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_storage_managed_folder_iam_binding" "primary" {
  condition {
    description = # value needed
    expression  = # value needed
    title       = # value needed
  }
  managed_folder = # value needed
}

Resource: google_storage_managed_folder_iam_member (1 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_storage_managed_folder_iam_member" "primary" {
  condition {
    description = # value needed
    expression  = # value needed
    title       = # value needed
  }
  managed_folder = # value needed
}

Resource: google_storage_managed_folder_iam_policy (2 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_storage_managed_folder_iam_policy" "primary" {
  managed_folder = # value needed
}

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 97
Passed tests: 87
Skipped tests: 6
Affected tests: 4

Click here to see the affected service packages
  • storage

Action taken

Found 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccStorageManagedFolderIamBindingGenerated|TestAccStorageManagedFolderIamMemberGenerated|TestAccStorageManagedFolderIamPolicyGenerated|TestAccStorageManagedFolder_googleStorageManagedFolderExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccStorageManagedFolderIamBindingGenerated[Error message] [Debug log]
TestAccStorageManagedFolderIamMemberGenerated[Error message] [Debug log]
TestAccStorageManagedFolderIamPolicyGenerated[Error message] [Debug log]
TestAccStorageManagedFolder_googleStorageManagedFolderExample[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

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

Some changes below - also, please add the remaining output-only fields (createTime, etc.)

mmv1/products/storage/ManagedFolder.yaml Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Outdated Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Outdated Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Outdated Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Outdated Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Outdated Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Outdated Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Show resolved Hide resolved
@github-actions github-actions bot requested a review from melinath May 16, 2024 21:20
@modular-magician modular-magician added the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label May 16, 2024
@hassannmoussaa
Copy link
Author

All Changes requested are done in last commit
Tests runned locally and passed
Kindly for your review @melinath

Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

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

Thanks! Could you also add the remaining output-only fields (createTime, etc.)

@hassannmoussaa
Copy link
Author

CreateTime and UpdateTime are added !
Tests Runned locally and passed @melinath

@modular-magician modular-magician removed the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label May 17, 2024
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 8 files changed, 1132 insertions(+), 3 deletions(-))
google-beta provider: Diff ( 8 files changed, 1132 insertions(+), 3 deletions(-))
terraform-google-conversion: Diff ( 4 files changed, 401 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 112 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_storage_managed_folder_iam_binding (2 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_storage_managed_folder_iam_binding" "primary" {
  condition {
    description = # value needed
    expression  = # value needed
    title       = # value needed
  }
}

Resource: google_storage_managed_folder_iam_member (1 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_storage_managed_folder_iam_member" "primary" {
  condition {
    description = # value needed
    expression  = # value needed
    title       = # value needed
  }
}

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 97
Passed tests: 87
Skipped tests: 6
Affected tests: 4

Click here to see the affected service packages
  • storage

Action taken

Found 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccStorageManagedFolderIamBindingGenerated|TestAccStorageManagedFolderIamMemberGenerated|TestAccStorageManagedFolderIamPolicyGenerated|TestAccStorageManagedFolder_googleStorageManagedFolderExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccStorageManagedFolderIamBindingGenerated[Error message] [Debug log]
TestAccStorageManagedFolderIamMemberGenerated[Error message] [Debug log]
TestAccStorageManagedFolderIamPolicyGenerated[Error message] [Debug log]
TestAccStorageManagedFolder_googleStorageManagedFolderExample[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

mmv1/products/storage/ManagedFolder.yaml Outdated Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Outdated Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Show resolved Hide resolved
@github-actions github-actions bot requested a review from melinath May 18, 2024 20:49
@modular-magician modular-magician added the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label May 18, 2024
@hassannmoussaa
Copy link
Author

Changes Fixed

@hassannmoussaa
Copy link
Author

For your review @melinath

Copy link

This PR has been waiting for review for 2 days. Please take a look! Use the label disable-review-reminders to disable these notifications.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 8 files changed, 1160 insertions(+), 3 deletions(-))
google-beta provider: Diff ( 8 files changed, 1160 insertions(+), 3 deletions(-))
terraform-google-conversion: Diff ( 4 files changed, 401 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 112 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_storage_managed_folder_iam_binding (2 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_storage_managed_folder_iam_binding" "primary" {
  condition {
    description = # value needed
    expression  = # value needed
    title       = # value needed
  }
}

Resource: google_storage_managed_folder_iam_member (1 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_storage_managed_folder_iam_member" "primary" {
  condition {
    description = # value needed
    expression  = # value needed
    title       = # value needed
  }
}

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 97
Passed tests: 87
Skipped tests: 6
Affected tests: 4

Click here to see the affected service packages
  • storage

Action taken

Found 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccStorageManagedFolderIamBindingGenerated|TestAccStorageManagedFolderIamMemberGenerated|TestAccStorageManagedFolderIamPolicyGenerated|TestAccStorageManagedFolder_googleStorageManagedFolderExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccStorageManagedFolderIamBindingGenerated[Error message] [Debug log]
TestAccStorageManagedFolderIamMemberGenerated[Error message] [Debug log]
TestAccStorageManagedFolderIamPolicyGenerated[Error message] [Debug log]
TestAccStorageManagedFolder_googleStorageManagedFolderExample[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

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

It looks like the API appends a / to the name field. That means you'll need a custom_flatten function for the name field to remove the /.

---[ REQUEST ]---------------------------------------
POST /storage/v1/b/tf-test-bucket-namezinmsqu9ld/managedFolders?alt=json HTTP/1.1
Host: storage.googleapis.com
User-Agent: Terraform/1.2.5 (+https://www.terraform.io) Terraform-Plugin-SDK/2.33.0 terraform-provider-google-beta/acc
Content-Length: 49
Content-Type: application/json
Accept-Encoding: gzip

{
 "name": "tf-test-managed-folder-namezinmsqu9ld"
}

-----------------------------------------------------
2024/05/20 16:42:29 [DEBUG] Google API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 200 OK
Content-Length: 471
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json; charset=UTF-8
Date: Mon, 20 May 2024 16:42:29 GMT
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Pragma: no-cache
Server: UploadServer
Vary: Origin
Vary: X-Origin
X-Guploader-Uploadid: ABPtcPqoHmybpEkhK-LfvTFWBJNLdFeOEnOJrZheDTJhxoZggSeExSP68mfuuMMZlHdttA12NTg

{
  "kind": "storage#managedFolder",
  "name": "tf-test-managed-folder-namezinmsqu9ld/",
  "bucket": "tf-test-bucket-namezinmsqu9ld",
  "id": "tf-test-bucket-namezinmsqu9ld/tf-test-managed-folder-namezinmsqu9ld/",
  "selfLink": "https://www.googleapis.com/storage/v1/b/tf-test-bucket-namezinmsqu9ld/managedFolders/tf-test-managed-folder-namezinmsqu9ld%2F",
  "metageneration": "1",
  "createTime": "2024-05-20T16:42:29.768Z",
  "updateTime": "2024-05-20T16:42:29.768Z"
}

Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

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

@hassannmoussaa it looks like a new PR was opened that also covers this resource: #10786

Since your implementation is pretty close to done I'd be inclined to continue with it if you're interested, but if you'd prefer to defer to the other PR that's fine too.

mmv1/products/storage/ManagedFolder.yaml Outdated Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Outdated Show resolved Hide resolved
mmv1/products/storage/ManagedFolder.yaml Show resolved Hide resolved
@hassannmoussaa
Copy link
Author

Sorry for being inactive just had some vacation, ill continue contributing to the following PR

@github-actions github-actions bot requested a review from melinath May 26, 2024 19:20
@modular-magician modular-magician added the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label May 26, 2024
@hassannmoussaa
Copy link
Author

@melinath Please for your review and validation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests service/storage
Projects
None yet
4 participants