Support read_action fallback for list-only properties (GH-1167)#1170
Open
jaredfholgate wants to merge 2 commits into
Open
Support read_action fallback for list-only properties (GH-1167)#1170jaredfholgate wants to merge 2 commits into
jaredfholgate wants to merge 2 commits into
Conversation
Add optional read_action, read_action_method, and read_action_response_path
arguments to azapi_resource and azapi_update_resource. When a plain GET returns
configured properties empty (e.g. Microsoft.Web/sites/config app settings), the
provider now automatically falls back to a POST {resource_id}/list read when the
GET covers none of the configured body leaves and a list function exists in the
embedded schema metadata. Fixes perpetual drift reported in AzureGH-1167.
Also fixes a value-vs-pointer type assertion in LoadFunctionTypeDefinition that
prevented resource function definitions from ever resolving.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b1f328bb-6609-499c-aae2-519bbda83bfc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds optional
read_action,read_action_method, andread_action_response_patharguments toazapi_resourceandazapi_update_resource, so property values can be read from a list-style action when a plainGETreturns them empty.Why
Fixes #1167. A
GETonMicrosoft.Web/sites/config/appsettingsreturnsproperties: {}— the real values are only exposed viaPOST .../config/appsettings/list. azapi's read-merge is config-body-driven, so an emptyGETdrops every configured key and reports perpetual drift (notably for Flex Consumption function apps).Behaviour
GETcovers none of the configured body leaves and alistfunction exists in the embedded schema for the type + api-version, fall back toPOST {resource_id}/listand merge that response. After the POST it re-checks overlap and warns + falls back to theGETresponse if the POST also covers nothing."none"— force the currentGET-only behaviour."list") — forcePOST {resource_id}/{value}.read_action_methodoverrides the verb;read_action_response_path(JMESPath) lifts a sub-object before the merge.The merge stays config-body-driven, so a mismatched response is a harmless no-op.
This also fixes a value-vs-pointer type assertion in
LoadFunctionTypeDefinitionthat prevented resource function definitions from ever resolving.Testing
go build ./...,go vet,gofmt -s: cleangolangci-lint run(v2.11.4): 0 issuesTest_countCoveredLeaves,Test_applyResponsePathMicrosoft.Web/sites/configapp settings — both the automatic fallback and an explicitread_action = "list"):Changelog & docs
CHANGELOG.md: entry underv2.11.0ENHANCEMENTS.docs/resources/resource.mdanddocs/resources/update_resource.mdupdated for the new arguments.