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

azurerm_managed_application - extend supported types for parameters/parameter_values/output and deprecate parameters #21541

Merged
merged 4 commits into from
Aug 9, 2023

Conversation

myc2h6o
Copy link
Contributor

@myc2h6o myc2h6o commented Apr 26, 2023

Fix #21267
Fix #13427
Fix #20016

  • Code
    • Split flatten for parameters and outputs, as outputs does not support secureString but parameters does. And moved common logic into functions.
    • while parsing secureString, use the value from local config, as it's not returned from server due to security concern.
    • fixed a bug in expandManagedApplicationParameters, previously it always read the value from parameters after parameter_values, which will cause an issue when updating parameter_values, because on the second apply, even parameter is not set in config, it's still present in the state from the first apply.
    • add ForceNew to plan, plan cannot be changed according to error returned by service Code="CannotUpdatePlan".
  • Document
    • added note in parameters, it only supports string and secureString due to the limitation of tf schema, for other types, parmeter_values could be used as it is a pure JSON string
  • Test cases
    • updated azurerm_managed_application_definition to use inline template as dependency instead of online template to ensure stability
    • remove the old updatetest, cause it's updating forceNew properties, which is a re-creation, updates of certain properties are put into their own tests
    • added tests to cover all supported types within parameters and parameter_values
  • Examples
    • added examples to use parameters and parameter_values, to show how to set parameters of different types.

Copy link
Member

@stephybun stephybun 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 this @myc2h6o - could you add a test to validate this?

@stephybun
Copy link
Member

Any updates @myc2h6o

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Jun 20, 2023

@stephybun I found some more issue while updating this pr, and I'm working on the update in a separate branch main...myc2h6o:terraform-provider-azurerm:managed_app_type_backup currently, I'll update it here once I resolved all the issues

@myc2h6o myc2h6o force-pushed the managed_app_type branch from 087cea1 to cd10cd6 Compare June 30, 2023 06:43
@myc2h6o myc2h6o changed the title azurerm_managed_application - fix parameter types azurerm_managed_application - extend supported types for parameter_values and output Jun 30, 2023
@myc2h6o myc2h6o changed the title azurerm_managed_application - extend supported types for parameter_values and output azurerm_managed_application - extend supported types for parameters/parameter_values and output Jun 30, 2023
@myc2h6o myc2h6o force-pushed the managed_app_type branch from cd10cd6 to 830e765 Compare June 30, 2023 07:13
@myc2h6o
Copy link
Contributor Author

myc2h6o commented Jun 30, 2023

Hi @stephybun sorry for the delayed update, I finally get this to work. I've updated the code and acc tests, and put the updated PR details into the pr descriptions, please take a look.

@myc2h6o myc2h6o force-pushed the managed_app_type branch from 830e765 to 2efcf60 Compare July 3, 2023 05:03
@myc2h6o
Copy link
Contributor Author

myc2h6o commented Jul 3, 2023

Updated test result
image

@katbyte
Copy link
Collaborator

katbyte commented Jul 6, 2023

#21571 should probably be merged first as it will be easier to fix conflicts in this PR then that one

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Jul 7, 2023

@katbyte sure, I'll wait for the sdk to be upgraded first

@myc2h6o myc2h6o force-pushed the managed_app_type branch 3 times, most recently from 6e03df4 to b09176c Compare July 8, 2023 04:50
@myc2h6o
Copy link
Contributor Author

myc2h6o commented Jul 8, 2023

I have resolved conflicts after the sdk upgrade, below is the updated test result:
image

Copy link
Contributor

@manicminer manicminer 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 updating and adding the tests @myc2h6o. I think this mostly looks good, just a couple of potential crashes I spotted, and given the messiness of this double implementation I wonder if we should consider deprecating parameters with a view to removing it in v4.0? Although it's an attempt at a more native implementation, it currently has to coexist with parameter_values because it's only a subset - we can avoid a lot of unnecessary gymnastics here by removing it. WDYT?

// Secure values are not returned, thus settings it with local value
v = ""
if oldValueStruct, oldValueStructOK := localParameters[k]; oldValueStructOK {
if oldValue, oldValueOK := oldValueStruct.(map[string]interface{})["value"]; oldValueOK {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'll need some type-checking here because oldValueStruct is an interface{} and no guarantee that it will be a map? If it isn't, this will panic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes make sense, have added the type check

if _, ok := value["value"]; !ok {
value["value"] = ""
if localParam, localParamOK := localParameters[k]; localParamOK {
if localParamValue, localParamValueOK := localParam.(map[string]interface{})["value"]; localParamValueOK {
Copy link
Contributor

Choose a reason for hiding this comment

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

As above, we should add more type-checking here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes make sense, have added the type check

@myc2h6o myc2h6o changed the title azurerm_managed_application - extend supported types for parameters/parameter_values and output azurerm_managed_application - extend supported types for parameters/parameter_values and output and deprecate parameters Aug 7, 2023
@myc2h6o
Copy link
Contributor Author

myc2h6o commented Aug 7, 2023

@manicminer thanks for reviewing the change! I've updated the code to deprecate parameters in 4.0 and added the type check. Please take a look.

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Aug 7, 2023

updated test result
image

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Aug 7, 2023

have rebased to main to resolve ci failure of the example issue fixed by #22839

@myc2h6o myc2h6o changed the title azurerm_managed_application - extend supported types for parameters/parameter_values and output and deprecate parameters azurerm_managed_application - extend supported types for parameters/parameter_values/output and deprecate parameters Aug 8, 2023
Copy link
Contributor

@manicminer manicminer 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 updating @myc2h6o, this LGTM 👍

@manicminer manicminer added this to the v3.69.0 milestone Aug 9, 2023
@manicminer manicminer merged commit 5a65857 into hashicorp:main Aug 9, 2023
manicminer added a commit that referenced this pull request Aug 9, 2023
@myc2h6o myc2h6o deleted the managed_app_type branch August 10, 2023 02:33
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.