Skip to content

Inventory Enhancements (Resource and Data Source) #62

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

Merged
merged 14 commits into from
May 14, 2025

Conversation

lranjbar
Copy link
Contributor

@lranjbar lranjbar commented May 6, 2025

Part of AAP-44426

User Story
As a user of Terraform and AAP, I want the terraform-provider-aap to implement data sources for the Job Template and Inventory objects in AAP so that I can look up existing objects when creating AAP jobs from Terraform.

@lranjbar lranjbar force-pushed the update-inventory-data-source branch 2 times, most recently from 4285a4b to 2ac0f8e Compare May 6, 2025 22:56
@AaronH88
Copy link
Collaborator

AaronH88 commented May 7, 2025

Overall this is looking good,
I have a common question around checking contexts throughout the provider, is this a pattern in providers, to ignore contexts? Or is this just a small bit of tec debt from the first implementation?

Also, some of the functions seem like their arguments could be replaced with interfaces, only if, terraform dosent try to use reflection when calling these functions. 😄

Copy link
Contributor Author

@lranjbar lranjbar left a comment

Choose a reason for hiding this comment

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

I'll look into this and update in tomorrow's collab call. 😄

@lranjbar lranjbar force-pushed the update-inventory-data-source branch 2 times, most recently from c157b16 to 87673a9 Compare May 7, 2025 23:32
@lranjbar lranjbar changed the title Inventory Enhancements Inventory Enhancements (Resource and Data Source) May 7, 2025
@lranjbar lranjbar force-pushed the update-inventory-data-source branch 2 times, most recently from bdfc4a2 to 1f15818 Compare May 8, 2025 19:08
Copy link
Collaborator

@dleehr dleehr left a comment

Choose a reason for hiding this comment

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

Really excited to see the rapid progress here and impressed at the turnaround.

I had some questions about the named_url, but more importantly I think we need to add acceptance tests for this functionality.

@lranjbar lranjbar force-pushed the update-inventory-data-source branch from 1f15818 to a971941 Compare May 12, 2025 22:21
@lranjbar lranjbar force-pushed the update-inventory-data-source branch from a971941 to 212f852 Compare May 12, 2025 23:04
@lranjbar
Copy link
Contributor Author

Acceptance tests output

==> Running acceptance tests...
TF_ACC=1 AAP_HOST="http://localhost:9080" AAP_INSECURE_SKIP_VERIFY=true go test -count=1 -v ./...
?   	github.com/ansible/terraform-provider-aap	[no test files]
=== RUN   TestComputeURLPath
=== RUN   TestComputeURLPath/case_1
=== RUN   TestComputeURLPath/case_2
=== RUN   TestComputeURLPath/case_3
=== RUN   TestComputeURLPath/case_4
--- PASS: TestComputeURLPath (0.00s)
    --- PASS: TestComputeURLPath/case_1 (0.00s)
    --- PASS: TestComputeURLPath/case_2 (0.00s)
    --- PASS: TestComputeURLPath/case_3 (0.00s)
    --- PASS: TestComputeURLPath/case_4 (0.00s)
=== RUN   TestReadApiEndpoint
=== RUN   TestReadApiEndpoint/AAP_2.4
=== RUN   TestReadApiEndpoint/AAP_2.5+
--- PASS: TestReadApiEndpoint (0.00s)
    --- PASS: TestReadApiEndpoint/AAP_2.4 (0.00s)
    --- PASS: TestReadApiEndpoint/AAP_2.5+ (0.00s)
=== RUN   TestGroupResourceSchema
=== PAUSE TestGroupResourceSchema
=== RUN   TestGroupResourceCreateRequestBody
=== RUN   TestGroupResourceCreateRequestBody/test_with_unknown_values
=== RUN   TestGroupResourceCreateRequestBody/test_with_null_values
=== RUN   TestGroupResourceCreateRequestBody/test_with_some_values
=== RUN   TestGroupResourceCreateRequestBody/test_with_all_values
--- PASS: TestGroupResourceCreateRequestBody (0.00s)
    --- PASS: TestGroupResourceCreateRequestBody/test_with_unknown_values (0.00s)
    --- PASS: TestGroupResourceCreateRequestBody/test_with_null_values (0.00s)
    --- PASS: TestGroupResourceCreateRequestBody/test_with_some_values (0.00s)
    --- PASS: TestGroupResourceCreateRequestBody/test_with_all_values (0.00s)
=== RUN   TestGroupResourceParseHttpResponse
=== RUN   TestGroupResourceParseHttpResponse/test_with_JSON_error
=== RUN   TestGroupResourceParseHttpResponse/test_with_missing_values
=== RUN   TestGroupResourceParseHttpResponse/test_with_all_values
--- PASS: TestGroupResourceParseHttpResponse (0.00s)
    --- PASS: TestGroupResourceParseHttpResponse/test_with_JSON_error (0.00s)
    --- PASS: TestGroupResourceParseHttpResponse/test_with_missing_values (0.00s)
    --- PASS: TestGroupResourceParseHttpResponse/test_with_all_values (0.00s)
=== RUN   TestAccGroupResource
--- PASS: TestAccGroupResource (10.09s)
=== RUN   TestSliceDifference
--- PASS: TestSliceDifference (0.00s)
=== RUN   TestExtractIDs
--- PASS: TestExtractIDs (0.00s)
=== RUN   TestHostResourceSchema
=== PAUSE TestHostResourceSchema
=== RUN   TestHostResourceCreateRequestBody
=== RUN   TestHostResourceCreateRequestBody/test_with_unknown_values
=== RUN   TestHostResourceCreateRequestBody/test_with_null_values
=== RUN   TestHostResourceCreateRequestBody/test_with_some_values
=== RUN   TestHostResourceCreateRequestBody/test_with_all_values
--- PASS: TestHostResourceCreateRequestBody (0.00s)
    --- PASS: TestHostResourceCreateRequestBody/test_with_unknown_values (0.00s)
    --- PASS: TestHostResourceCreateRequestBody/test_with_null_values (0.00s)
    --- PASS: TestHostResourceCreateRequestBody/test_with_some_values (0.00s)
    --- PASS: TestHostResourceCreateRequestBody/test_with_all_values (0.00s)
=== RUN   TestHostResourceParseHttpResponse
=== RUN   TestHostResourceParseHttpResponse/test_with_JSON_error
=== RUN   TestHostResourceParseHttpResponse/test_with_missing_values
=== RUN   TestHostResourceParseHttpResponse/test_with_all_values
--- PASS: TestHostResourceParseHttpResponse (0.00s)
    --- PASS: TestHostResourceParseHttpResponse/test_with_JSON_error (0.00s)
    --- PASS: TestHostResourceParseHttpResponse/test_with_missing_values (0.00s)
    --- PASS: TestHostResourceParseHttpResponse/test_with_all_values (0.00s)
=== RUN   TestAccHostResource
--- PASS: TestAccHostResource (11.94s)
=== RUN   TestInventoryDataSourceSchema
=== PAUSE TestInventoryDataSourceSchema
=== RUN   TestInventoryDataSourceParseHttpResponse
=== RUN   TestInventoryDataSourceParseHttpResponse/JSON_error
=== RUN   TestInventoryDataSourceParseHttpResponse/missing_values
=== RUN   TestInventoryDataSourceParseHttpResponse/all_values
--- PASS: TestInventoryDataSourceParseHttpResponse (0.00s)
    --- PASS: TestInventoryDataSourceParseHttpResponse/JSON_error (0.00s)
    --- PASS: TestInventoryDataSourceParseHttpResponse/missing_values (0.00s)
    --- PASS: TestInventoryDataSourceParseHttpResponse/all_values (0.00s)
=== RUN   TestAccInventoryDataSource
--- PASS: TestAccInventoryDataSource (4.25s)
=== RUN   TestInventoryResourceSchema
=== PAUSE TestInventoryResourceSchema
=== RUN   TestInventoryResourceGenerateRequestBody
=== RUN   TestInventoryResourceGenerateRequestBody/unknown_values
=== RUN   TestInventoryResourceGenerateRequestBody/null_values
=== RUN   TestInventoryResourceGenerateRequestBody/provided_values
--- PASS: TestInventoryResourceGenerateRequestBody (0.00s)
    --- PASS: TestInventoryResourceGenerateRequestBody/unknown_values (0.00s)
    --- PASS: TestInventoryResourceGenerateRequestBody/null_values (0.00s)
    --- PASS: TestInventoryResourceGenerateRequestBody/provided_values (0.00s)
=== RUN   TestInventoryResourceParseHttpResponse
=== RUN   TestInventoryResourceParseHttpResponse/JSON_error
=== RUN   TestInventoryResourceParseHttpResponse/missing_values
=== RUN   TestInventoryResourceParseHttpResponse/all_values
--- PASS: TestInventoryResourceParseHttpResponse (0.00s)
    --- PASS: TestInventoryResourceParseHttpResponse/JSON_error (0.00s)
    --- PASS: TestInventoryResourceParseHttpResponse/missing_values (0.00s)
    --- PASS: TestInventoryResourceParseHttpResponse/all_values (0.00s)
=== RUN   TestAccInventoryResource
--- PASS: TestAccInventoryResource (8.43s)
=== RUN   TestJobResourceSchema
=== PAUSE TestJobResourceSchema
=== RUN   TestJobResourceCreateRequestBody
=== RUN   TestJobResourceCreateRequestBody/unknown_values
=== RUN   TestJobResourceCreateRequestBody/null_values
=== RUN   TestJobResourceCreateRequestBody/extra_vars_only
=== RUN   TestJobResourceCreateRequestBody/inventory_vars_only
=== RUN   TestJobResourceCreateRequestBody/combined
=== RUN   TestJobResourceCreateRequestBody/manual_triggers
--- PASS: TestJobResourceCreateRequestBody (0.00s)
    --- PASS: TestJobResourceCreateRequestBody/unknown_values (0.00s)
    --- PASS: TestJobResourceCreateRequestBody/null_values (0.00s)
    --- PASS: TestJobResourceCreateRequestBody/extra_vars_only (0.00s)
    --- PASS: TestJobResourceCreateRequestBody/inventory_vars_only (0.00s)
    --- PASS: TestJobResourceCreateRequestBody/combined (0.00s)
    --- PASS: TestJobResourceCreateRequestBody/manual_triggers (0.00s)
=== RUN   TestJobResourceParseHttpResponse
=== RUN   TestJobResourceParseHttpResponse/JSON_error
=== RUN   TestJobResourceParseHttpResponse/no_ignored_fields
=== RUN   TestJobResourceParseHttpResponse/ignored_fields
--- PASS: TestJobResourceParseHttpResponse (0.00s)
    --- PASS: TestJobResourceParseHttpResponse/JSON_error (0.00s)
    --- PASS: TestJobResourceParseHttpResponse/no_ignored_fields (0.00s)
    --- PASS: TestJobResourceParseHttpResponse/ignored_fields (0.00s)
=== RUN   TestAccAAPJob_basic
--- PASS: TestAccAAPJob_basic (4.22s)
=== RUN   TestAccAAPJob_UpdateWithSameParameters
--- PASS: TestAccAAPJob_UpdateWithSameParameters (6.11s)
=== RUN   TestAccAAPJob_UpdateWithNewInventoryId
    job_resource_test.go:320: Test seems to always create new job in the default inventory after adding inventory data source.
--- SKIP: TestAccAAPJob_UpdateWithNewInventoryId (0.00s)
=== RUN   TestAccAAPJob_UpdateWithTrigger
--- PASS: TestAccAAPJob_UpdateWithTrigger (6.36s)
=== RUN   TestAccAAPJob_disappears
--- PASS: TestAccAAPJob_disappears (65.60s)
=== RUN   TestReadValues
=== RUN   TestReadValues/No_defined_values
=== RUN   TestReadValues/Using_env_variables_only
=== RUN   TestReadValues/Using_both_configuration_and_envs_value
=== RUN   TestReadValues/Using_configuration_value
=== RUN   TestReadValues/Bad_value_for_env_variable
=== RUN   TestReadValues/Using_null_values_in_configuration
--- PASS: TestReadValues (0.00s)
    --- PASS: TestReadValues/No_defined_values (0.00s)
    --- PASS: TestReadValues/Using_env_variables_only (0.00s)
    --- PASS: TestReadValues/Using_both_configuration_and_envs_value (0.00s)
    --- PASS: TestReadValues/Using_configuration_value (0.00s)
    --- PASS: TestReadValues/Bad_value_for_env_variable (0.00s)
    --- PASS: TestReadValues/Using_null_values_in_configuration (0.00s)
=== RUN   TestReturnAAPNamedURL
=== RUN   TestReturnAAPNamedURL/test_test
=== RUN   TestReturnAAPNamedURL/test_test#01
=== RUN   TestReturnAAPNamedURL/test_test#02
=== RUN   TestReturnAAPNamedURL/test_test#03
=== RUN   TestReturnAAPNamedURL/test_test#04
=== RUN   TestReturnAAPNamedURL/test_test#05
=== RUN   TestReturnAAPNamedURL/test_test#06
=== RUN   TestReturnAAPNamedURL/test_test#07
=== RUN   TestReturnAAPNamedURL/test_test#08
=== RUN   TestReturnAAPNamedURL/test_test#09
--- PASS: TestReturnAAPNamedURL (0.00s)
    --- PASS: TestReturnAAPNamedURL/test_test (0.00s)
    --- PASS: TestReturnAAPNamedURL/test_test#01 (0.00s)
    --- PASS: TestReturnAAPNamedURL/test_test#02 (0.00s)
    --- PASS: TestReturnAAPNamedURL/test_test#03 (0.00s)
    --- PASS: TestReturnAAPNamedURL/test_test#04 (0.00s)
    --- PASS: TestReturnAAPNamedURL/test_test#05 (0.00s)
    --- PASS: TestReturnAAPNamedURL/test_test#06 (0.00s)
    --- PASS: TestReturnAAPNamedURL/test_test#07 (0.00s)
    --- PASS: TestReturnAAPNamedURL/test_test#08 (0.00s)
    --- PASS: TestReturnAAPNamedURL/test_test#09 (0.00s)
=== RUN   TestGetURL
=== RUN   TestGetURL/https://example.com
=== RUN   TestGetURL/https://example.com/
=== RUN   TestGetURL/https://example.com#01
=== RUN   TestGetURL/invalid-url
--- PASS: TestGetURL (0.00s)
    --- PASS: TestGetURL/https://example.com (0.00s)
    --- PASS: TestGetURL/https://example.com/ (0.00s)
    --- PASS: TestGetURL/https://example.com#01 (0.00s)
    --- PASS: TestGetURL/invalid-url (0.00s)
=== RUN   TestParseStringValue
=== RUN   TestParseStringValue/Test_non-empty_string
=== RUN   TestParseStringValue/Test_empty_string
--- PASS: TestParseStringValue (0.00s)
    --- PASS: TestParseStringValue/Test_non-empty_string (0.00s)
    --- PASS: TestParseStringValue/Test_empty_string (0.00s)
=== RUN   TestParseNormalizedValue
=== RUN   TestParseNormalizedValue/Test_non-empty_string
=== RUN   TestParseNormalizedValue/Test_empty_string
--- PASS: TestParseNormalizedValue (0.00s)
    --- PASS: TestParseNormalizedValue/Test_non-empty_string (0.00s)
    --- PASS: TestParseNormalizedValue/Test_empty_string (0.00s)
=== CONT  TestGroupResourceSchema
=== CONT  TestInventoryResourceSchema
--- PASS: TestGroupResourceSchema (0.00s)
=== CONT  TestInventoryDataSourceSchema
--- PASS: TestInventoryResourceSchema (0.00s)
=== CONT  TestJobResourceSchema
--- PASS: TestInventoryDataSourceSchema (0.00s)
=== CONT  TestHostResourceSchema
--- PASS: TestHostResourceSchema (0.00s)
--- PASS: TestJobResourceSchema (0.00s)
PASS
ok  	github.com/ansible/terraform-provider-aap/internal/provider	117.000s
=== RUN   TestAAPCustomStringTypeValidate
=== PAUSE TestAAPCustomStringTypeValidate
=== RUN   TestAAPCustomStringTypeValueFromTerraform
=== PAUSE TestAAPCustomStringTypeValueFromTerraform
=== RUN   TestAAPCustomStringStringSemanticEquals
=== PAUSE TestAAPCustomStringStringSemanticEquals
=== CONT  TestAAPCustomStringTypeValidate
=== RUN   TestAAPCustomStringTypeValidate/empty-struct
=== PAUSE TestAAPCustomStringTypeValidate/empty-struct
=== RUN   TestAAPCustomStringTypeValidate/null
=== PAUSE TestAAPCustomStringTypeValidate/null
=== RUN   TestAAPCustomStringTypeValidate/unknown
=== PAUSE TestAAPCustomStringTypeValidate/unknown
=== RUN   TestAAPCustomStringTypeValidate/json_object
=== CONT  TestAAPCustomStringStringSemanticEquals
=== PAUSE TestAAPCustomStringTypeValidate/json_object
=== RUN   TestAAPCustomStringTypeValidate/json_string
=== CONT  TestAAPCustomStringTypeValueFromTerraform
=== RUN   TestAAPCustomStringStringSemanticEquals/semantically_equal_-_object_whitespace_difference
=== RUN   TestAAPCustomStringTypeValueFromTerraform/wrongType
=== PAUSE TestAAPCustomStringStringSemanticEquals/semantically_equal_-_object_whitespace_difference
=== PAUSE TestAAPCustomStringTypeValueFromTerraform/wrongType
=== PAUSE TestAAPCustomStringTypeValidate/json_string
=== RUN   TestAAPCustomStringStringSemanticEquals/semantically_equal_-_yaml_no_difference
=== PAUSE TestAAPCustomStringStringSemanticEquals/semantically_equal_-_yaml_no_difference
=== RUN   TestAAPCustomStringTypeValidate/yaml_string
=== RUN   TestAAPCustomStringStringSemanticEquals/semantically_equal_-_yaml_no_difference_with_newline
=== PAUSE TestAAPCustomStringTypeValidate/yaml_string
=== PAUSE TestAAPCustomStringStringSemanticEquals/semantically_equal_-_yaml_no_difference_with_newline
=== RUN   TestAAPCustomStringTypeValidate/yaml_string_no_newline
=== PAUSE TestAAPCustomStringTypeValidate/yaml_string_no_newline
=== RUN   TestAAPCustomStringTypeValidate/wrong-value-type
=== PAUSE TestAAPCustomStringTypeValidate/wrong-value-type
=== CONT  TestAAPCustomStringTypeValidate/empty-struct
=== CONT  TestAAPCustomStringTypeValidate/yaml_string
=== CONT  TestAAPCustomStringTypeValidate/json_string
=== CONT  TestAAPCustomStringTypeValidate/json_object
=== CONT  TestAAPCustomStringTypeValidate/unknown
=== CONT  TestAAPCustomStringTypeValidate/null
=== RUN   TestAAPCustomStringStringSemanticEquals/not_equal_-_mismatched_field_values
=== PAUSE TestAAPCustomStringStringSemanticEquals/not_equal_-_mismatched_field_values
=== RUN   TestAAPCustomStringTypeValueFromTerraform/yaml_string_no_newline
=== PAUSE TestAAPCustomStringTypeValueFromTerraform/yaml_string_no_newline
=== RUN   TestAAPCustomStringTypeValueFromTerraform/true
=== PAUSE TestAAPCustomStringTypeValueFromTerraform/true
=== CONT  TestAAPCustomStringTypeValidate/wrong-value-type
=== RUN   TestAAPCustomStringTypeValueFromTerraform/unknown
=== PAUSE TestAAPCustomStringTypeValueFromTerraform/unknown
=== CONT  TestAAPCustomStringTypeValidate/yaml_string_no_newline
=== RUN   TestAAPCustomStringStringSemanticEquals/not_equal_-_mismatched_field_names
=== PAUSE TestAAPCustomStringStringSemanticEquals/not_equal_-_mismatched_field_names
=== RUN   TestAAPCustomStringTypeValueFromTerraform/null
=== RUN   TestAAPCustomStringStringSemanticEquals/not_equal_-_additional_field
=== PAUSE TestAAPCustomStringStringSemanticEquals/not_equal_-_additional_field
=== RUN   TestAAPCustomStringStringSemanticEquals/not_equal_-_array_item_order_difference
=== PAUSE TestAAPCustomStringStringSemanticEquals/not_equal_-_array_item_order_difference
=== PAUSE TestAAPCustomStringTypeValueFromTerraform/null
=== RUN   TestAAPCustomStringStringSemanticEquals/semantically_equal_-_object_byte-for-byte_match
=== CONT  TestAAPCustomStringTypeValueFromTerraform/yaml_string_no_newline
--- PASS: TestAAPCustomStringTypeValidate (0.00s)
    --- PASS: TestAAPCustomStringTypeValidate/yaml_string (0.00s)
    --- PASS: TestAAPCustomStringTypeValidate/empty-struct (0.00s)
    --- PASS: TestAAPCustomStringTypeValidate/wrong-value-type (0.00s)
    --- PASS: TestAAPCustomStringTypeValidate/yaml_string_no_newline (0.00s)
    --- PASS: TestAAPCustomStringTypeValidate/json_object (0.00s)
    --- PASS: TestAAPCustomStringTypeValidate/json_string (0.00s)
    --- PASS: TestAAPCustomStringTypeValidate/unknown (0.00s)
    --- PASS: TestAAPCustomStringTypeValidate/null (0.00s)
=== CONT  TestAAPCustomStringTypeValueFromTerraform/wrongType
=== CONT  TestAAPCustomStringTypeValueFromTerraform/null
=== CONT  TestAAPCustomStringTypeValueFromTerraform/unknown
=== CONT  TestAAPCustomStringTypeValueFromTerraform/true
--- PASS: TestAAPCustomStringTypeValueFromTerraform (0.00s)
    --- PASS: TestAAPCustomStringTypeValueFromTerraform/yaml_string_no_newline (0.00s)
    --- PASS: TestAAPCustomStringTypeValueFromTerraform/wrongType (0.00s)
    --- PASS: TestAAPCustomStringTypeValueFromTerraform/null (0.00s)
    --- PASS: TestAAPCustomStringTypeValueFromTerraform/unknown (0.00s)
    --- PASS: TestAAPCustomStringTypeValueFromTerraform/true (0.00s)
=== PAUSE TestAAPCustomStringStringSemanticEquals/semantically_equal_-_object_byte-for-byte_match
=== CONT  TestAAPCustomStringStringSemanticEquals/semantically_equal_-_object_whitespace_difference
=== CONT  TestAAPCustomStringStringSemanticEquals/not_equal_-_mismatched_field_names
=== CONT  TestAAPCustomStringStringSemanticEquals/semantically_equal_-_yaml_no_difference_with_newline
=== CONT  TestAAPCustomStringStringSemanticEquals/not_equal_-_mismatched_field_values
=== CONT  TestAAPCustomStringStringSemanticEquals/semantically_equal_-_yaml_no_difference
=== CONT  TestAAPCustomStringStringSemanticEquals/semantically_equal_-_object_byte-for-byte_match
=== CONT  TestAAPCustomStringStringSemanticEquals/not_equal_-_additional_field
=== CONT  TestAAPCustomStringStringSemanticEquals/not_equal_-_array_item_order_difference
--- PASS: TestAAPCustomStringStringSemanticEquals (0.00s)
    --- PASS: TestAAPCustomStringStringSemanticEquals/semantically_equal_-_yaml_no_difference_with_newline (0.00s)
    --- PASS: TestAAPCustomStringStringSemanticEquals/not_equal_-_mismatched_field_names (0.00s)
    --- PASS: TestAAPCustomStringStringSemanticEquals/semantically_equal_-_object_whitespace_difference (0.00s)
    --- PASS: TestAAPCustomStringStringSemanticEquals/semantically_equal_-_object_byte-for-byte_match (0.00s)
    --- PASS: TestAAPCustomStringStringSemanticEquals/not_equal_-_mismatched_field_values (0.00s)
    --- PASS: TestAAPCustomStringStringSemanticEquals/semantically_equal_-_yaml_no_difference (0.00s)
    --- PASS: TestAAPCustomStringStringSemanticEquals/not_equal_-_additional_field (0.00s)
    --- PASS: TestAAPCustomStringStringSemanticEquals/not_equal_-_array_item_order_difference (0.00s)
PASS
ok  	github.com/ansible/terraform-provider-aap/internal/provider/customtypes	0.002s

Copy link
Collaborator

@dleehr dleehr left a comment

Choose a reason for hiding this comment

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

Thanks for running the tests and posting the output. Excited to see these enhancements coming 😄. Overall I think this looks really good!

After my last review we had some good discussion around some docs suggestions (required->optional, reference fornamed_url). I thought we had a good direction from the discussion with some small changes. I see the comments are now resolved but there were no code changes. I don't want this to get lost, is there a plan to address it?

My other feedback was around the acceptance tests. I see one has been updated to verify the new attributes are present, so that's great 👍. However, one that was active is now being skipped (which seems like a regression). Most importantly, the use case we're aiming to support (being able to use a data.aap_inventory to look up an inventory by name) is not covered by an acceptance test at all. Is that a test we can write?

Co-authored-by: Dan Leehr <[email protected]>
@lranjbar
Copy link
Contributor Author

lranjbar commented May 13, 2025

@dleehr

With the Job template set to prompt on launch we are still passing the test case for inventoryid. 🎉

The output of JobResource tests below:

==> Running acceptance tests...
TF_ACC=1 AAP_HOST="http://localhost:9080" AAP_INSECURE_SKIP_VERIFY=true go test -count=1 -v ./...
? github.com/ansible/terraform-provider-aap [no test files]
=== RUN TestJobResourceSchema
=== PAUSE TestJobResourceSchema
=== RUN TestJobResourceCreateRequestBody
=== RUN TestJobResourceCreateRequestBody/unknown_values
=== RUN TestJobResourceCreateRequestBody/null_values
=== RUN TestJobResourceCreateRequestBody/extra_vars_only
=== RUN TestJobResourceCreateRequestBody/inventory_vars_only
=== RUN TestJobResourceCreateRequestBody/combined
=== RUN TestJobResourceCreateRequestBody/manual_triggers
--- PASS: TestJobResourceCreateRequestBody (0.00s)
--- PASS: TestJobResourceCreateRequestBody/unknown_values (0.00s)
--- PASS: TestJobResourceCreateRequestBody/null_values (0.00s)
--- PASS: TestJobResourceCreateRequestBody/extra_vars_only (0.00s)
--- PASS: TestJobResourceCreateRequestBody/inventory_vars_only (0.00s)
--- PASS: TestJobResourceCreateRequestBody/combined (0.00s)
--- PASS: TestJobResourceCreateRequestBody/manual_triggers (0.00s)
=== RUN TestJobResourceParseHttpResponse
=== RUN TestJobResourceParseHttpResponse/JSON_error
=== RUN TestJobResourceParseHttpResponse/no_ignored_fields
=== RUN TestJobResourceParseHttpResponse/ignored_fields
--- PASS: TestJobResourceParseHttpResponse (0.00s)
--- PASS: TestJobResourceParseHttpResponse/JSON_error (0.00s)
--- PASS: TestJobResourceParseHttpResponse/no_ignored_fields (0.00s)
--- PASS: TestJobResourceParseHttpResponse/ignored_fields (0.00s)
=== RUN TestAccAAPJob_basic
--- PASS: TestAccAAPJob_basic (5.13s)
=== RUN TestAccAAPJob_UpdateWithSameParameters
--- PASS: TestAccAAPJob_UpdateWithSameParameters (7.14s)
=== RUN TestAccAAPJob_UpdateWithNewInventoryIdPromptOnLaunch
--- PASS: TestAccAAPJob_UpdateWithNewInventoryIdPromptOnLaunch (43.22s)

=== RUN TestAccAAPJob_UpdateWithTrigger
--- PASS: TestAccAAPJob_UpdateWithTrigger (6.41s)
=== RUN TestAccAAPJob_disappears
--- PASS: TestAccAAPJob_disappears (60.30s)
PASS

Copy link
Collaborator

@matoval matoval left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Collaborator

@dleehr dleehr left a comment

Choose a reason for hiding this comment

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

Thanks for the clarification on that acceptance test that needs the prompt on launch. I don't think my other comments have been addressed, but let me know if I can clarify anything.

@lranjbar
Copy link
Contributor Author

Thanks for the clarification on that acceptance test that needs the prompt on launch. I don't think my other comments have been addressed, but let me know if I can clarify anything.

Acceptance tests were updated, and now docs updated so that should cover everything that has been discussed.

@dleehr
Copy link
Collaborator

dleehr commented May 14, 2025

Acceptance tests were updated, and now docs updated so that should cover everything that has been discussed.

OK I see that an acceptance test for the inventory resource was updated to check for the new attributes, but I do not see any new acceptance tests around the new functionality described in the story:

As a user of Terraform and AAP, I want the terraform-provider-aap to implement data sources for the Job Template and Inventory objects in AAP so that I can look up existing objects when creating AAP jobs from Terraform.

It's good that we're testing these changes (no regressions 🎉) but we need new acceptance tests that follow the user story - show that we can look up an inventory by name and not just id:

more importantly I think we need to add acceptance tests for this functionality

Most importantly, the use case we're aiming to support (being able to use a data.aap_inventory to look up an inventory by name) is not covered by an acceptance test at all. Is that a test we can write?

The Jira has a pretty basic terraform config we should be able to use in an acceptance test to confirm. Maybe we need organization name too, but generally we'd use something like this, right?

data "aap_inventory" "my_inventory" {
  name = "my_inventory" # no id
}

(P.S. can we check if we're really addressing #52 with these changes? I'm not sure this PR closes that issue. 👀 )

Copy link
Collaborator

@dleehr dleehr left a comment

Choose a reason for hiding this comment

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

Discussed and agree that acceptance tests are needed for the story to be complete but not to hold up this PR.

@PabloHiro PabloHiro self-requested a review May 14, 2025 16:34
Copy link
Contributor

@PabloHiro PabloHiro left a comment

Choose a reason for hiding this comment

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

Let's get this in and follow up on #64

@lranjbar lranjbar merged commit aa32f41 into ansible:main May 14, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants