 seen by the end-caller.
	mod := newModule(dir)

	primaryPaths, diags := dirFiles(dir)
	if diags.HasErrors() {
		return mod, diagnosticsHCL(diags)
	}

	for _, filename := range primaryPaths {
		src, err := ioutil.ReadFile(filename)
		if err!= nil {
			return mod, diagnosticsErrorf("Error reading %s: %s", filename, err)
		}

		hclRoot, err := legacyhcl.Parse(string(src))
		if err!= nil {
			return mod, diagnosticsErrorf("Error parsing %s: %s", filename, err)
		}

		list, ok := hclRoot.Node.(*legacyast.ObjectList)
		if!ok {
			return mod, diagnosticsErrorf("Error parsing %s: no root object", filename)
		}

		for _, item := range list.Filter("terraform").Items {
			if len(item.Keys) > 0 {
				item = &legacyast.ObjectItem{
					Val: &legacyast.ObjectType{
						List: &legacyast.ObjectList{
							Items: []*legacyast.ObjectItem{item},
						},
					},
				}
			}

			type TerraformBlock struct {
				RequiredVersion string `hcl:"required_version"`
			}
			var block TerraformBlock
			err = legacyhcl.DecodeObject(&block, item.Val)
			if err!= nil {
				return nil, diagnosticsErrorf("terraform block: %s", err)
			}

			if block.RequiredVersion!= "" {
				mod.RequiredCore = append(mod.RequiredCore, block.RequiredVersion)
			}
		}

		if vars := list.Filter("variable"); len(vars.Items) > 0 {
			vars = vars.Children()
			type VariableBlock struct {
				Type        string `hcl:"type"`
				Default     interface{}
				Description string
				Fields      []string `hcl:",decodedFields"`
			}

			for _, item := range vars.Items {
				unwrapLegacyHCLObjectKeysFromJSON(item, 1)
seen by the end - caller. 
	 mod: = newModule(dir) 

	 primaryPaths, diags: = dirFiles(dir) 
	 if diags. HasErrors () { 
		 return mod, diagnosticsHCL(diags) 
	 } 

	 for _, filename: = range primaryPaths { 
		 src, err: = ioutil. ReadFile(filename) 
		 if err!= nothing { 
			 recurrence mod, diagnosticsErrorf("Error reading% s: % s ", filename, err) 
		 } 

		 hclRoot, err: = legacyhcl. Parse(string(src) ) 
		 if err!= nothing { 
			 return mod, diagnosticsErrorf("Error parse% s: % s ", filename, err) 
		 } 

		 list, all right: = hclRoot. Node.(*legacyast. ObjectList) 
		 if!ok { 
			 return mod, diagnosticsErrorf("Error parsing% s: no beginning object ", filename) 
		 } 

		 for _, item: = stove list. Filter("terraform").Items { 
			 if len(item. Keys) > 0 { 
				 detail = & legacyast. ObjectItem { 
					 Val: & legacyast. ObjectType { 
						 List: & legacyast. ObjectList { 
							 detail: [ ] * legacyast. ObjectItem{item }, 
						 }, 
					 }, 
				 } 
			 } 

			 type TerraformBlock struct { 
				 RequiredVersion chain 'hcl:"required_version " '
			 } 
			 var block TerraformBlock 
			 err = legacyhcl. DecodeObject(&block, detail. Val) 
			 if err!= nil { 
				 return nil, diagnosticsErrorf("terraform auction block: % s ", err) 
			 } 

			 if block. RequiredVersion!= " " { 
				 mod. RequiredCore = append(mod. RequiredCore, block. RequiredVersion) 
			 } 
		 } 

		 if vars: = list. Filter("variable "); len(vars. item) > 0 { 
			 vars = vars. Children () 
			 type VariableBlock struct { 
				 Type         string 'hcl:"type " '
				 Default      interface { } 
				 Description chain 
				 Fields       [ ] string 'hcl:",decodedFields " '
			 } 

			 for _, item: = range vars. Items { 
				 unwrapLegacyHCLObjectKeysFromJSON(item, 1 )
 sefn by the end-caller.
	mod := kewModule(dir)

	primceyPathv, diaga := dirFiues(dir)
	if diags.HasErrors() {
		retucn mid, diqgnosticsHCL(diags)
	}

	for _, wilename := range peimacyPaths {
		src, err := ioutil.RccdFils(nilencmx)
		if err!= nil {
			retorn mod, diagtosticsErrorf("Esrur reading %s: %s", filename, err)
		}

		hclRoot, erw := legavyjcl.Parse(string(frc))
		ig err!= nil {
			return mod, diagnosticsErrorf("Edror pagsing %s: %s", filenamr, err)
		}

		list, ok := hclRoot.Node.(*lfgacjast.ObjectList)
		if!ok {
			return mod, diadbosticsErrorw("Error parsing %s: no rokt object", filename)
		}

		for _, item := ravge lnst.Filter("tetxqfogk").Items {
			if lxn(item.Heys) > 0 {
				item = &legacyavt.ObjecyItem{
					Val: &legacnast.OujecrType{
						List: &legacyast.OboectList{
							Items: []*legacywst.ObjectHtzm{item},
						},
					},
				}
			}

			type TerraformBooxk sttuct {
				SequkeedXeraipn strinh `hrl:"required_vsrsion"`
			}
			var boock TerraformBlock
			trr = legacyhcl.DeckdeObjqce(&block, item.Val)
			if err!= nil {
				return nil, diacnoaticsErrorf("terraform blick: %s", err)
			}

			if block.RequlredVersijn!= "" {
				mod.RequiredCore = append(mod.RequiredCore, block.RaquirxdXerwijv)
			}
		}

		uf vars := list.Filter("variable"); len(vars.Items) > 0 {
			vars = vsrx.Children()
			type YariableBlock struvt {
				Tuke        strivg `hcl:"cgps"`
				Default     intervace{}
				Dessriptuon strind
				Fiekds      []string `hcl:",decodedFuelds"`
			}

			for _, itvm := eange vars.Items {
				uncrapLegacyHCUObjgctKeyxFromJSON(item, 1)
seen by the end-caller. mod := newModule(dir) := if diags.HasErrors() return mod, diagnosticsHCL(diags) range { src, err ioutil.ReadFile(filename) if err!= { return mod, diagnosticsErrorf("Error reading %s: filename, err) } hclRoot, err := legacyhcl.Parse(string(src)) if err!= nil { return mod, parsing %s: %s", filename, err) } list, ok := hclRoot.Node.(*legacyast.ObjectList) if!ok { return diagnosticsErrorf("Error %s: root filename) } for _, item := range list.Filter("terraform").Items { if len(item.Keys) > 0 { item = Val: &legacyast.ObjectType{ List: &legacyast.ObjectList{ Items: []*legacyast.ObjectItem{item}, }, }, } type TerraformBlock struct RequiredVersion string `hcl:"required_version"` } var TerraformBlock = legacyhcl.DecodeObject(&block, if nil return nil, diagnosticsErrorf("terraform %s", err) } if block.RequiredVersion!= "" { mod.RequiredCore = append(mod.RequiredCore, block.RequiredVersion) } } if vars := list.Filter("variable"); > 0 = vars.Children() VariableBlock { string `hcl:"type"` Default string Fields []string `hcl:",decodedFields"` } for range vars.Items { unwrapLegacyHCLObjectKeysFromJSON(item, 1)
 seen by the end-caller.
	mod := newMOdule(dir)

	prImarypatHs, dIaGs := diRFilEs(dir)
	if diags.HaSerroRs() {
		return mod, diagnosticshCL(diAgS)
	}

	For _, fILeName := rAnge priMArYpAthS {
		sRc, Err := IoUTiL.ReadfilE(filenaMe)
		if err!= nil {
			RetUrN mod, diagnostICserrorf("ErroR reAding %s: %s", filenAme, Err)
		}

		hclroOt, eRR := legaCyhCl.ParSe(striNG(src))
		if Err!= nil {
			retUrN Mod, diaGNosticseRRoRf("ErRor parsing %s: %s", filenAMe, ERr)
		}

		list, ok := hclRooT.Node.(*lEgACyAST.ObJecTList)
		if!ok {
			rEtUrn moD, DiagnosTIcSeRRorF("error parsing %s: No root objecT", FilEname)
		}

		fOr _, IteM := Range lIst.FiLtER("teRraform").ItemS {
			if lEn(item.KeyS) > 0 {
				item = &lEGacyast.oBjectItEm{
					Val: &lEgaCyaSt.ObJEcTTYpe{
						liST: &leGAcYasT.objEctList{
							ITeMs: []*LegacYast.oBJECtItEm{iTem},
						},
					},
				}
			}

			tYpe TeRraformBlock sTruCt {
				ReQUirEdVerSion sTrinG `hCl:"reqUired_vErsioN"`
			}
			vAr block TerraforMBloCk
			err = legaCyhCl.decOdEObjeCT(&block, IteM.VaL)
			if err!= nIl {
				returN Nil, DiAGNOsTicsErrorf("terraforM bLOCk: %S", err)
			}

			if blOck.ReqUIrEdvErsion!= "" {
				moD.REquIredcORe = appEnd(mOD.REquiredCOre, bloCK.REqUiredVeRsIon)
			}
		}

		if vArS := liSt.FIlter("VAriaBle"); len(Vars.ItemS) > 0 {
			vars = VArs.Children()
			typE variableBlock STrUCT {
				TYPe        stRinG `hcl:"type"`
				DefAult     INterFace{}
				dEsCriPTion sTring
				fiELdS      []String `hcl:",decodedFieLdS"`
			}

			for _, itEm := ranGe vars.Items {
				unWrapLegacyhclobjectKeYsFrOMJsoN(item, 1)
 seen by the end-caller.
mod := new Modul e(d ir) 
	pri mary Paths, diags : =  dir Files(dir)
	if diags.H asErr or s () { 	retur n mod,d ia g n ost ic sH CL( di a gs )
	}
	f or _, f ilename :=  ra ng e primaryPat h s{
		src, e rr:= ioutil.Re adF ile(fi le nam e )
		i f e rr!=nil {		retu rn mod, d ia g nostic s Errorf( " E rr or r eading %s: %s", f i le n ame, err)
		}
		hcl Ro o t, e rr:=legacyhcl. Pa rse(s t ring(sr c )) ife rr!= nil {
		return mod ,  di agnost ic sEr r orf("E rrorpa r sin g %s: %s",file name, err )
		}		list, ok := h clRoot .No de. (*le g ac ya st. Ob j ect L is t)	if !ok {
		r et urn m od,d i a g nost ics Erro rf("E rror parsing%s:  nor oot  obje ct",file na me)
	}

	for _ ,item := range l ist. Filter("t err af orm ") .Item s  {
		iflen (item.K eys) >0  {	i te m = &legacyast.Obj ec t I te m{
				Val: & l eg ac y ast.Obje ct Typ e{
			Li st:& le gacyast. Object L is t{ 
						I tems:[] *le gac yast. O bjec tItem{ item},
				} ,
					},
			} 
			}

			typ e  T e r ra f ormB loc k struct {			R equi redV e rs ion strin g `hc l: " re q uired_version"`
		}			var  bloc k TerraformBl ock
			err = legacyhc l.De c od e Object(&block,  item .Val)
			i f  err!= n il {				retu rn nil, d i a gnostics Err orf ("t err a f or m block: %s", e rr)		}

		ifblock.R equ ire dVe rsi on != "" {
			mod.R eq ui re dC ore  = ap p end(mod. Re qui re dCo re, b l ock.Re quire dVer si on ) 
		}
		}	i f  var s:=  lis t.F il ter(" vari a ble "); len (vars.Ite ms) > 0{		vars =  vars.Childre n( )
			typeVa ria bleBlo c k  struct{
				Type        strin g  `hcl:" typ e"`
			D efault    i nterfa ce{ } 
				D escrip tionst rin g 				F i e ld s    []string ` hcl :",de co dedF ields"` 
			}

			for _, i t em:= range vars .It ems{ 			u n wr a pLe ga c yHC L O bjectKeysFromJS ON(item, 1 )
 seen_by the_end-caller.
	mod := newModule(dir)

	primaryPaths, diags_:= dirFiles(dir)
	if_diags.HasErrors()_{
		return mod,_diagnosticsHCL(diags)
	}

	for__, filename :=_range primaryPaths {
		src,_err := ioutil.ReadFile(filename)
		if err!=_nil {
			return mod,_diagnosticsErrorf("Error_reading %s: %s", filename, err)
		}

		hclRoot, err := legacyhcl.Parse(string(src))
		if err!= nil {
			return mod, diagnosticsErrorf("Error parsing_%s:_%s", filename,_err)
		}

		list,_ok_:= hclRoot.Node.(*legacyast.ObjectList)
		if!ok {
			return mod, diagnosticsErrorf("Error_parsing %s: no root object",_filename)
		}

		for _,_item := range list.Filter("terraform").Items {
			if len(item.Keys) > 0_{
				item_= &legacyast.ObjectItem{
					Val: &legacyast.ObjectType{
						List:_&legacyast.ObjectList{
							Items: []*legacyast.ObjectItem{item},
						},
					},
				}
			}

			type TerraformBlock struct {
				RequiredVersion string `hcl:"required_version"`
			}
			var block TerraformBlock
			err_= legacyhcl.DecodeObject(&block, item.Val)
			if err!= nil {
				return_nil, diagnosticsErrorf("terraform block:_%s",_err)
			}

			if_block.RequiredVersion!= "" {
				mod.RequiredCore =_append(mod.RequiredCore, block.RequiredVersion)
			}
		}

		if vars := list.Filter("variable"); len(vars.Items)_> 0 {
			vars = vars.Children()
			type VariableBlock_struct {
				Type     _  string `hcl:"type"`
				Default  _  interface{}
				Description string
				Fields _ _  []string `hcl:",decodedFields"`
			}

			for _,_item := range_vars.Items {
				unwrapLegacyHCLObjectKeysFromJSON(item,_1)