private getResourceHierarchy()

in packages/rulesets/src/native/utilities/arm-helper.ts [407:427]


  private getResourceHierarchy(model: string | Workspace.EnhancedSchema) {
    let hierarchy: string[] = []
    const enhancedModel: Workspace.EnhancedSchema = typeof model === "string" ? this.getInternalModel(model)! : model

    if (!enhancedModel) {
      return hierarchy
    }
    const unwrappedSchema = Workspace.resolveRef(enhancedModel, this.inventory)!
    for (const refs of jsonPathIt(unwrappedSchema.value, `$.allOf`)) {
      refs
        .filter((ref: any) => !!ref.$ref)
        .forEach((ref: any) => {
          const allOfModel = this.stripDefinitionPath(ref.$ref)
          if (allOfModel) {
            hierarchy.push(allOfModel)
            hierarchy = hierarchy.concat(this.getResourceHierarchy(this.enhancedSchema(ref, unwrappedSchema.file)))
          }
        })
    }
    return hierarchy
  }