Skip to content

Commit

Permalink
try calling clean on import-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
AriehSchneier committed Nov 19, 2024
1 parent 525327c commit 34e8d1f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/importer/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package importer

import (
"fmt"
"path"
"strings"

"github.com/anz-bank/sysl/internal/bundles"
"github.com/anz-bank/sysl/pkg/arrai"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/anz-bank/sysl/internal/bundles"
"github.com/anz-bank/sysl/pkg/arrai"
)

type ProtobufImporter struct {
Expand All @@ -22,12 +24,20 @@ func MakeProtobufImporter(logger *logrus.Logger) *ProtobufImporter {
return &ProtobufImporter{logger: logger}
}

func cleanImporterPaths(importPaths string) string {
split := strings.Split(importPaths, ",")
for i, p := range split {
split[i] = path.Clean(p)
}
return strings.Join(split, ",")
}

func (p *ProtobufImporter) LoadFile(path string) (string, error) {
b := bundles.ProtoImporter

args, err := buildImporterArgs(&protobufImporterArgs{
specPath: path,
importPaths: p.importPaths,
importPaths: cleanImporterPaths(p.importPaths),
shallow: p.shallow,
})

Expand All @@ -52,7 +62,7 @@ func (p *ProtobufImporter) Load(protoSpec string) (string, error) {

args, err := buildImporterArgs(&protobufImporterArgs{
specContent: protoSpec,
importPaths: p.importPaths,
importPaths: cleanImporterPaths(p.importPaths),
shallow: p.shallow,
})

Expand Down

0 comments on commit 34e8d1f

Please sign in to comment.