Skip to content

Commit

Permalink
Switched to use In-Memory FileSystem for file manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
juliosueiras committed Feb 16, 2020
1 parent 2c6a29f commit 827f992
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default:
go build -ldflags "-X main.GitCommit=$$(git rev-list -1 HEAD) -X main.Version=$$(git describe --tags) -X main.Date=$$(date --rfc-3339=date)"
go build -ldflags "-X main.GitCommit=$$(git rev-list -1 HEAD) -X main.Version=$$(git describe --tags) -X main.Date=$$(date --rfc-3339=date)"

copy:
go build -ldflags "-X main.GitCommit=$$(git rev-list -1 HEAD) -X main.Version=$$(git describe --tags) -X main.Date=$$(date --rfc-3339=date)" && cp ./terraform-lsp ~/.bin/ && cp ./terraform-lsp ~/
Expand Down
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@ go 1.12

require (
github.com/creachadair/jrpc2 v0.1.2
github.com/creack/pty v1.1.9 // indirect
github.com/davecgh/go-spew v1.1.1
github.com/go-errors/errors v1.0.1 // indirect
github.com/gogo/protobuf v1.2.1 // indirect
github.com/gruntwork-io/terragrunt v0.21.13
github.com/hashicorp/go-hclog v0.9.0 // indirect
github.com/hashicorp/go-plugin v1.0.1-0.20190610192547-a1bc61569a26
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.3.0
github.com/hashicorp/hcl2 v0.0.0-20191002203319-fb75b3253c80 // indirect
github.com/hashicorp/hil v0.0.0-20190212132231-97b3a9cdfa93 // indirect
github.com/hashicorp/terraform v0.12.20
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/mattn/go-isatty v0.0.7 // indirect
github.com/mattn/go-zglob v0.0.1 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/sourcegraph/go-lsp v0.0.0-20181119182933-0c7d621186c1
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/afero v1.2.2
github.com/ulikunitz/xz v0.5.6 // indirect
github.com/urfave/cli v1.22.2 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/zclconf/go-cty v1.2.1
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
Expand Down
18 changes: 18 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creachadair/jrpc2 v0.1.2 h1:HxqF+XvtBf6MQz0L12gKbr9y3DyCNqjvILpnw6FGaaA=
github.com/creachadair/jrpc2 v0.1.2/go.mod h1:hZIkdv6dHxrBp5ORguCyhNwE1eUrbhaGm/u3UAh9epQ=
github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -102,6 +106,8 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
Expand Down Expand Up @@ -148,6 +154,8 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/gruntwork-io/terragrunt v0.21.13 h1:W939obrQTlqsBAjsabsBtv46BHhmwRybDR5GahanrgA=
github.com/gruntwork-io/terragrunt v0.21.13/go.mod h1:SVtVlzW6IomArG5OJo0TDZZJ1MYcsTzc2AmgqNfAR+E=
github.com/hashicorp/aws-sdk-go-base v0.3.0/go.mod h1:ZIWACGGi0N7a4DZbf15yuE1JQORmWLtBcVM6F5SXNFU=
github.com/hashicorp/aws-sdk-go-base v0.4.0/go.mod h1:eRhlz3c4nhqxFZJAahJEFL7gh6Jyj5rQmQc7F9eHFyQ=
github.com/hashicorp/consul v0.0.0-20171026175957-610f3c86a089/go.mod h1:mFrjN1mfidgJfYP1xrJCF+AfRhr6Eaqhb2+sfyn/OOI=
Expand Down Expand Up @@ -204,6 +212,8 @@ github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggU
github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8=
github.com/hashicorp/hcl2 v0.0.0-20190821123243-0c888d1241f6 h1:JImQpEeUQ+0DPFMaWzLA0GdUNPaUlCXLpfiqkSZBUfc=
github.com/hashicorp/hcl2 v0.0.0-20190821123243-0c888d1241f6/go.mod h1:Cxv+IJLuBiEhQ7pBYGEuORa0nr4U994pE8mYLuFd7v0=
github.com/hashicorp/hcl2 v0.0.0-20191002203319-fb75b3253c80 h1:PFfGModn55JA0oBsvFghhj0v93me+Ctr3uHC/UmFAls=
github.com/hashicorp/hcl2 v0.0.0-20191002203319-fb75b3253c80/go.mod h1:Cxv+IJLuBiEhQ7pBYGEuORa0nr4U994pE8mYLuFd7v0=
github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590/go.mod h1:n2TSygSNwsLJ76m8qFXTSc7beTb+auJxYdqrnoqwZWE=
github.com/hashicorp/hil v0.0.0-20190212132231-97b3a9cdfa93 h1:T1Q6ag9tCwun16AW+XK3tAql24P4uTGUMIn1/92WsQQ=
github.com/hashicorp/hil v0.0.0-20190212132231-97b3a9cdfa93/go.mod h1:n2TSygSNwsLJ76m8qFXTSc7beTb+auJxYdqrnoqwZWE=
Expand Down Expand Up @@ -267,6 +277,8 @@ github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-shellwords v1.0.4/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
github.com/mattn/go-zglob v0.0.1 h1:xsEx/XUoVlI6yXjqBK062zYhRTZltCNmYPx6v+8DNaY=
github.com/mattn/go-zglob v0.0.1/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.0.8/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0 h1:iGBIsUe3+HZ/AD/Vd7DErOt5sU9fa8Uj7A2s1aggv1Y=
Expand Down Expand Up @@ -320,10 +332,14 @@ github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
Expand All @@ -347,6 +363,8 @@ github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5/go.mod h1:hnLbHMwcvSihnD
github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8=
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
Expand Down
13 changes: 7 additions & 6 deletions helper/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ import (
"github.com/hashicorp/hcl/v2/hclsyntax"
"github.com/hashicorp/terraform/configs"
"github.com/juliosueiras/terraform-lsp/hclstructs"
"github.com/juliosueiras/terraform-lsp/memfs"
"github.com/sourcegraph/go-lsp"
"github.com/spf13/afero"
"github.com/zclconf/go-cty/cty"
"io/ioutil"
"log"
"os"
"reflect"
"regexp"
"strings"
"unicode/utf8"
)

func CheckAndGetConfig(parser *configs.Parser, originalFile *os.File, line int, character int) (*configs.File, hcl.Diagnostics, int, *hclsyntax.Body, bool) {
fileText, _ := ioutil.ReadFile(originalFile.Name())
func CheckAndGetConfig(parser *configs.Parser, originalFile afero.File, line int, character int) (*configs.File, hcl.Diagnostics, int, *hclsyntax.Body, bool) {
fileText, _ := afero.ReadFile(memfs.MemFs, originalFile.Name())
result := make([]byte, 1)
pos := FindOffset(string(fileText), line, character)

tempFile, _ := ioutil.TempFile("", "check_tf_lsp")
defer os.Remove(tempFile.Name())
tempFile, _ := afero.TempFile(memfs.MemFs, "", "check_tf_lsp")

defer memfs.MemFs.Remove(tempFile.Name())

originalFile.ReadAt(result, int64(pos))

Expand Down
10 changes: 6 additions & 4 deletions langserver/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import (
"github.com/juliosueiras/terraform-lsp/hclstructs"
"github.com/juliosueiras/terraform-lsp/helper"
"github.com/juliosueiras/terraform-lsp/tfstructs"
"io/ioutil"
"github.com/juliosueiras/terraform-lsp/memfs"
"github.com/spf13/afero"
)

func TextDocumentComplete(ctx context.Context, vs lsp.CompletionParams) (lsp.CompletionList, error) {
parser := configs.NewParser(nil)
//log.Println(tfstructs.Clients)
parser := configs.NewParser(memfs.MemFs)

fileURL := strings.Replace(string(vs.TextDocument.URI), "file://", "", 1)

Expand Down Expand Up @@ -49,7 +51,7 @@ func TextDocumentComplete(ctx context.Context, vs lsp.CompletionParams) (lsp.Com

files, diags := configs.NewModule(resultFiles, nil)

fileText, _ := ioutil.ReadFile(tempFile.Name())
fileText, _ := afero.ReadFile(memfs.MemFs, tempFile.Name())
pos := helper.FindOffset(string(fileText), vs.Position.Line+1, column)

var result []lsp.CompletionItem
Expand Down Expand Up @@ -97,7 +99,7 @@ func TextDocumentComplete(ctx context.Context, vs lsp.CompletionParams) (lsp.Com

if expr == nil && attr == nil && blocks == nil {
attrs, _ := config.JustAttributes()
fileText, _ := ioutil.ReadFile(tempFile.Name())
fileText, _ := afero.ReadFile(memfs.MemFs, tempFile.Name())
pos := helper.FindOffset(string(fileText), vs.Position.Line+1, column+1)

posHCL2 := hcl.Pos{
Expand Down
7 changes: 5 additions & 2 deletions langserver/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ package langserver

import (
"context"
"os"
"log"
"os"
"github.com/juliosueiras/terraform-lsp/memfs"

lsp "github.com/sourcegraph/go-lsp"
)

func Exit(ctx context.Context, vs lsp.None) error {
err := os.Remove(tempFile.Name())
err := memfs.MemFs.Remove(tempFile.Name())
if err != nil {
return err
}

log.Println("Exited")
os.Exit(0)
return nil
}
6 changes: 3 additions & 3 deletions langserver/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package langserver
import (
"context"
lsp "github.com/sourcegraph/go-lsp"
"io/ioutil"
"github.com/juliosueiras/terraform-lsp/memfs"
"github.com/spf13/afero"
"log"
)

func Initialize(ctx context.Context, vs lsp.InitializeParams) (lsp.InitializeResult, error) {

file, err := ioutil.TempFile("", "tf-lsp-")
file, err := afero.TempFile(memfs.MemFs, "", "tf-lsp-")
if err != nil {
log.Fatal(err)
}
Expand Down
6 changes: 4 additions & 2 deletions langserver/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ package langserver

import (
"context"
"os"
"log"
"github.com/juliosueiras/terraform-lsp/memfs"

lsp "github.com/sourcegraph/go-lsp"
)

func Shutdown(ctx context.Context, vs lsp.None) error {
err := os.Remove(tempFile.Name())
err := memfs.MemFs.Remove(tempFile.Name())
if err != nil {
return err
}

log.Println("Shutdown")
return nil
}
4 changes: 2 additions & 2 deletions langserver/temp.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package langserver

import (
"github.com/creachadair/jrpc2"
"github.com/spf13/afero"
lsp "github.com/sourcegraph/go-lsp"
"os"
)

var tempFile *os.File
var tempFile afero.File
var DiagsFiles = make(map[string][]lsp.Diagnostic)
var Server *jrpc2.Server
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ func main() {
if err := Server.Wait(); err != nil {
log.Printf("Server exited: %v", err)
}

log.Print("Server Finish")
}
7 changes: 7 additions & 0 deletions memfs/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package memfs

import "github.com/spf13/afero"

var base = afero.NewOsFs()
var roBase = afero.NewReadOnlyFs(base)
var MemFs = afero.NewCopyOnWriteFs(roBase, afero.NewMemMapFs())
11 changes: 7 additions & 4 deletions tfstructs/diags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ import (
"github.com/hashicorp/terraform/configs"
"github.com/zclconf/go-cty/cty"
//"github.com/juliosueiras/terraform-lsp/helper"
"github.com/juliosueiras/terraform-lsp/memfs"
"github.com/sourcegraph/go-lsp"
"os"
"github.com/spf13/afero"
"path/filepath"
)

func GetDiagnostics(fileName string, originalFile string) []lsp.Diagnostic {
parser := configs.NewParser(nil)

parser := configs.NewParser(memfs.MemFs)
result := make([]lsp.Diagnostic, 0)
originalFileName := originalFile
if _, err := os.Stat(fileName); os.IsNotExist(err) {

if exist, _ := afero.Exists(memfs.MemFs, fileName); !exist {
return result
}

if _, err := os.Stat(originalFile); os.IsNotExist(err) {
if exist, _ := afero.Exists(memfs.MemFs, originalFile); !exist {
originalFile = fileName
}

Expand Down
5 changes: 3 additions & 2 deletions tfstructs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/hashicorp/terraform/providers"
"github.com/hashicorp/terraform/provisioners"
"github.com/juliosueiras/terraform-lsp/helper"
"github.com/juliosueiras/terraform-lsp/memfs"
"github.com/zclconf/go-cty/cty"
"path/filepath"
"strings"
Expand All @@ -26,7 +27,7 @@ type TerraformProvisionerSchema struct {
}

func GetModuleVariables(moduleAddr string, config hcl.Body, targetDir string) (map[string]*configs.Variable, bool) {
parser := configs.NewParser(nil)
parser := configs.NewParser(memfs.MemFs)

t, _ := parser.LoadConfigDir(filepath.Join(targetDir, moduleAddr))
if t == nil || len(t.Variables) == 0 {
Expand Down Expand Up @@ -312,7 +313,7 @@ func GetProviderSchema(providerType string, config hcl.Body, targetDir string) *
}

func GetAllConfigs(filePath string, tempFilePath string) *configs.Module {
parser := configs.NewParser(nil)
parser := configs.NewParser(memfs.MemFs)
fileURL := strings.Replace(filePath, "file://", "", 1)

fileDir := filepath.Dir(fileURL)
Expand Down

0 comments on commit 827f992

Please sign in to comment.