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

update node pool workload metada config attribute #2844

Conversation

thiagocaiubi
Copy link

Hello.

First, thank you for magic-modules.

I'm trying to fix hashicorp/terraform-provider-google#4041 but I'm struggling where I should make the change and how can I test the effects.

I can see the tests for workload_metadata_config were stripped out when the field moved from google to google-beta (#1008). The beta provider doesn't has any tests?

Where can I find an example to help me with the issue?

I'd appreciate you share your comments on this. Thank you!

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@modular-magician
Copy link
Collaborator

Hello! I am a robot who works on Magic Modules PRs.

I have detected that you are a community contributor, so your PR will be assigned to someone with a commit-bit on this repo for initial review. They will authorize it to run through our CI pipeline, which will generate downstream PRs.

Thanks for your contribution! A human will be with you soon.

@danawillow, please review this PR or find an appropriate assignee.

@danawillow
Copy link
Contributor

Hi @thiagocaiubi, thanks for deciding to contribute! The tests that you pointed out actually do the reverse of what you were saying:

<% unless version.nil? || version == 'ga' -%>
func TestAccContainerNodePool_withWorkloadMetadataConfig(t *testing.T) {
t.Parallel()
cluster := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(10))
np := fmt.Sprintf("tf-test-np-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckContainerClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccContainerNodePool_withWorkloadMetadataConfig(cluster, np),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("google_container_node_pool.with_workload_metadata_config",
"node_config.0.workload_metadata_config.0.node_metadata", "SECURE"),
),
},
{
ResourceName: "google_container_node_pool.with_workload_metadata_config",
ImportState: true,
ImportStateVerify: true,
// Import always uses the v1 API, so beta features don't get imported.
ImportStateVerifyIgnore: []string{
"node_config.0.workload_metadata_config.#",
"node_config.0.workload_metadata_config.0.node_metadata",
},
},
},
})
}

That unless statement is equivalent to "if not", so what it ends up meaning is "include the following section in the beta provider only". This is what we want, since WorkloadMetadataConfig isn't available yet in the v1 GKE API (https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/NodeConfig). So I'd suggest having any changes you make be similarly guarded so that they only generate into the beta provider and not the GA one.

My guess from a first glance is that this change will be very similar to #2105, just in the node pool resource instead of the cluster one. Give it a try from here, and let me know if you have further questions!

@thiagocaiubi
Copy link
Author

Hi @danawillow thanks for clarifying.

I was looking for the tests at google instead of google-beta. Sorry, my bad.

I will take a look and give it try.

Thank you! 👍

@thiagocaiubi thiagocaiubi force-pushed the workload-metadata-config branch from 465edf9 to aeb3090 Compare January 2, 2020 18:13
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels Jan 2, 2020
@thiagocaiubi thiagocaiubi force-pushed the workload-metadata-config branch from aeb3090 to af36cf5 Compare January 2, 2020 18:27
@thiagocaiubi
Copy link
Author

Hello @danawillow.

I have followed the steps in the PR you have mentioned but I'm still struggling with tests. Could you please take a look?

@danawillow danawillow self-requested a review January 2, 2020 19:01
@danawillow
Copy link
Contributor

Can you be more specific as to what you're having trouble with?

@thiagocaiubi thiagocaiubi deleted the workload-metadata-config branch May 19, 2020 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update workload_metadata_config.node_metadata on node pools without force replacement.
4 participants