Skip to content

Commit

Permalink
load(nodes): resolve in context of calling node
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Jul 22, 2016
1 parent de38aa8 commit 2e54f9b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions load/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import (
)

type source struct {
Parent string
Source string
Parent string
ParentSource string
Source string
}

func (s *source) String() string {
Expand All @@ -37,7 +38,7 @@ func (s *source) String() string {

// Nodes loads and parses all resources referred to by the provided url
func Nodes(ctx context.Context, root string) (*graph.Graph, error) {
toLoad := []*source{{"root", root}}
toLoad := []*source{{"root", root, root}}

out := graph.New()
out.Add("root", nil)
Expand All @@ -52,7 +53,7 @@ func Nodes(ctx context.Context, root string) (*graph.Graph, error) {
current := toLoad[0]
toLoad = toLoad[1:]

url, err := fetch.ResolveInContext(current.Source, root)
url, err := fetch.ResolveInContext(current.Source, current.ParentSource)
if err != nil {
return nil, err
}
Expand All @@ -79,8 +80,9 @@ func Nodes(ctx context.Context, root string) (*graph.Graph, error) {
toLoad = append(
toLoad,
&source{
Parent: newID,
Source: resource.Source(),
Parent: newID,
ParentSource: url,
Source: resource.Source(),
},
)
}
Expand Down

0 comments on commit 2e54f9b

Please sign in to comment.