Makefile: how to assign object to variable and iterate on object of array

Viewed 30

Makefile:

QUERY := "securityresources | where type == 'microsoft.security/assessments' | summarize by assessmentKey=name | join kind=inner ( securityresources | where type == 'microsoft.security/assessments/subassessments' | extend assessmentKey = extract('.*assessments/(.+?)/.*',1, id) ) on assessmentKey | where properties.additionalData.assessedResourceType == 'ContainerRegistryVulnerability' | extend status = properties.status.code | extend severity = properties.status.severity"

.ONESHELL:
check:
    # az graph query -q ${QUERY}
    results="`az graph query -q ${QUERY}`"
    @for result in $$results.data;
    do
        echo "$${result.status}"
    done

Output of az graph query -q ${QUERY} looks like:

{ "count": 10,
  "data" : [{"status":"healthy", "abc":"123"},
            {"status":"unhealthy", "abc":"322"},
            {"status":"healthy", "abc":"432"}
           ]
}

Error:

/bin/bash: line 4: ${result.status}: bad substitution make: ***

[Makefile:23: check] Error 1

How to assign command output to a variable and iterate on that object and access keys, values of those objects?

0 Answers
Related