in src/PSRule.Rules.Azure/JsonExtensions.cs [378:423]
internal static void SetTargetInfo(this JObject resource, string templateFile, string parameterFile, string path = null)
{
// Get line information.
var lineInfo = resource.TryLineInfo();
// Populate target info.
resource.UseProperty(TARGETINFO_KEY, out JObject targetInfo);
// Path.
path ??= resource.GetResourcePath();
targetInfo.Add(TARGETINFO_PATH, path);
var sources = new JArray();
// Template file.
if (!string.IsNullOrEmpty(templateFile))
{
var source = new JObject
{
[TARGETINFO_FILE] = templateFile,
[TARGETINFO_TYPE] = TARGETINFO_TYPE_TEMPLATE
};
if (lineInfo.HasLineInfo())
{
source[TARGETINFO_LINE] = lineInfo.LineNumber;
source[TARGETINFO_POSITION] = lineInfo.LinePosition;
}
sources.Add(source);
}
// Parameter file.
if (!string.IsNullOrEmpty(parameterFile))
{
var source = new JObject
{
[TARGETINFO_FILE] = parameterFile,
[TARGETINFO_TYPE] = TARGETINFO_TYPE_PARAMETER
};
if (lineInfo.HasLineInfo())
{
source[TARGETINFO_LINE] = 1;
}
sources.Add(source);
}
targetInfo.Add(TARGETINFO_SOURCE, sources);
}