Skip to content

Commit

Permalink
fix: add wrapper scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
matsest committed Mar 12, 2024
1 parent 39bef65 commit 627c981
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
12 changes: 1 addition & 11 deletions scripts/resource-graph-query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ if [[ ! -f "${FILE}" ]]; then
exit 1
fi

# check that jq is installed
if ! command -v jq &> /dev/null; then
echo "jq is not installed. Please install jq before running this script."
exit 1
fi

QUERY=$(cat "${FILE}")

# hack using jq to format output
# shellcheck disable=SC2312
az graph query -q "${QUERY}" -o json \
| jq --raw-output '.data | [.[]| with_entries( .key |= ascii_downcase ) ] | (.[0] |keys_unsorted | @tsv), (.[]|.|map(.) |@tsv)' \
| column -t
az graph query -q "${QUERY}" -o table
18 changes: 18 additions & 0 deletions scripts/resource-graph.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#requires -Module Az.ResourceGraph
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[ValidateScript({
if (Test-Path -PathType Leaf $_) {
$true
} else {
throw "File path `$_` does not exist."
}
})]
[string]
$Path
)

$query = Get-Content -Path $Path -Raw

Search-AzGraph -Query $query

0 comments on commit 627c981

Please sign in to comment.