Provide passive per-source resource contexts
This commit is contained in:
@@ -12,9 +12,10 @@ import (
|
||||
type resolutionInput struct {
|
||||
metadata Metadata
|
||||
sources map[string]SourceInfo
|
||||
contexts map[string]ResourceContext
|
||||
}
|
||||
|
||||
func newResolutionInput(metadata Metadata, final *document.Node, sources []SourceInfo) resolutionInput {
|
||||
func newResolutionInput(metadata Metadata, final *document.Node, sources []SourceInfo, contexts ...map[string]ResourceContext) resolutionInput {
|
||||
frozen := Metadata{
|
||||
fields: make(map[string]FieldInfo, len(metadata.fields)),
|
||||
effectivePaths: effectivePathIndex(final),
|
||||
@@ -32,7 +33,11 @@ func newResolutionInput(metadata Metadata, final *document.Node, sources []Sourc
|
||||
}
|
||||
indexed[source.ID] = cloneSourceInfo(source)
|
||||
}
|
||||
return resolutionInput{metadata: frozen, sources: indexed}
|
||||
result := resolutionInput{metadata: frozen, sources: indexed}
|
||||
if len(contexts) != 0 {
|
||||
result.contexts = cloneResourceContexts(contexts[0])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (input resolutionInput) lookup(path Path) (FieldInfo, bool) {
|
||||
@@ -47,6 +52,11 @@ func (input resolutionInput) source(id string) (SourceInfo, bool) {
|
||||
return cloneSourceInfo(source), true
|
||||
}
|
||||
|
||||
func (input resolutionInput) sourceContext(id string) (ResourceContext, bool) {
|
||||
context, ok := input.contexts[id]
|
||||
return context, ok
|
||||
}
|
||||
|
||||
func metadataFromDecoded(decoded decodedConfiguration) Metadata {
|
||||
metadata := Metadata{
|
||||
fields: make(map[string]FieldInfo),
|
||||
|
||||
Reference in New Issue
Block a user