Separate engine loading from inspection state
This commit is contained in:
@@ -58,12 +58,62 @@ func testSecretBinding() SecretBinding {
|
||||
}
|
||||
}
|
||||
|
||||
func testLoad[T any](source Source, supplied ...Options[T]) (*Result[T], error) {
|
||||
return Load(source, testSecretBinding(), supplied...)
|
||||
func testLoad[T any](source Source, supplied ...Options[T]) (*testResult[T], error) {
|
||||
loaded, err := Load(source, testSecretBinding(), supplied...)
|
||||
return testLoaded(loaded), err
|
||||
}
|
||||
|
||||
func testLoadWithSecretLookup[T any](source Source, lookup secretLookup, supplied ...Options[T]) (*Result[T], error) {
|
||||
return loadWithSecretLookup(source, testSecretBinding(), lookup, supplied...)
|
||||
func testLoadWithSecretLookup[T any](source Source, lookup secretLookup, supplied ...Options[T]) (*testResult[T], error) {
|
||||
loaded, err := loadWithSecretLookup(source, testSecretBinding(), lookup, supplied...)
|
||||
return testLoaded(loaded), err
|
||||
}
|
||||
|
||||
type testResult[T any] struct {
|
||||
Config T
|
||||
*Inspection
|
||||
}
|
||||
|
||||
func testLoaded[T any](loaded *Loaded[T]) *testResult[T] {
|
||||
if loaded == nil {
|
||||
return nil
|
||||
}
|
||||
return &testResult[T]{Config: loaded.Config, Inspection: loaded.Inspection}
|
||||
}
|
||||
func (r *testResult[T]) Metadata() Metadata {
|
||||
if r == nil {
|
||||
return Metadata{}
|
||||
}
|
||||
return r.Inspection.Metadata()
|
||||
}
|
||||
func (r *testResult[T]) Sources() []SourceInfo {
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
return r.Inspection.Sources()
|
||||
}
|
||||
func (r *testResult[T]) Diagnostics() []Diagnostic {
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
return r.Inspection.Diagnostics()
|
||||
}
|
||||
func (r *testResult[T]) Explain(path Path) (Explanation, bool) {
|
||||
if r == nil {
|
||||
return Explanation{}, false
|
||||
}
|
||||
return r.Inspection.Explain(path)
|
||||
}
|
||||
func (r *testResult[T]) WriteEffective(output io.Writer) error {
|
||||
if r == nil {
|
||||
return errEffectiveUnavailable
|
||||
}
|
||||
return r.Inspection.WriteEffective(output)
|
||||
}
|
||||
func (r *testResult[T]) WriteExplanation(output io.Writer, path Path) error {
|
||||
if r == nil {
|
||||
return errExplanationUnknownPath
|
||||
}
|
||||
return r.Inspection.WriteExplanation(output, path)
|
||||
}
|
||||
|
||||
func testBuildSchema(root reflect.Type) (*schemaDescriptor, *schemaIssue) {
|
||||
|
||||
Reference in New Issue
Block a user