Define main-relative input options
This commit is contained in:
@@ -16,6 +16,7 @@ type loadRequest[T any] struct {
|
||||
effectiveVersion *VersionRule
|
||||
overlay string
|
||||
overlayFilesystem *FilesystemContext
|
||||
overlayFallback *FilesystemContext
|
||||
overrides []Override
|
||||
ordinary bool
|
||||
}
|
||||
@@ -31,6 +32,7 @@ type loadInput struct {
|
||||
source Source
|
||||
imports bool
|
||||
filesystem *FilesystemContext
|
||||
mainRelative *MainRelativeContext
|
||||
destination Path
|
||||
placementMode PlacementMode
|
||||
}
|
||||
@@ -57,6 +59,9 @@ func loadGroupedWithSecretLookupLimit[T any](request loadRequest[T], secrets Sec
|
||||
request.importDefaults = defaults
|
||||
request.sequencePolicy = policy
|
||||
request.definition.sequenceIdentityRegistrations = nil
|
||||
if request.main.mainRelative != nil && request.main.filesystem == nil {
|
||||
diagnostics = append(diagnostics, optionDiagnostic(CodeOptionsInvalid, "main input cannot use main-relative context"))
|
||||
}
|
||||
main, mainDiagnostics := normalizeInput(request.main, "")
|
||||
request.main = main
|
||||
diagnostics = append(diagnostics, mainDiagnostics...)
|
||||
@@ -64,6 +69,13 @@ func loadGroupedWithSecretLookupLimit[T any](request loadRequest[T], secrets Sec
|
||||
for groupIndex := range request.underlays {
|
||||
for inputIndex := range request.underlays[groupIndex].inputs {
|
||||
input := &request.underlays[groupIndex].inputs[inputIndex]
|
||||
if input.mainRelative != nil && input.filesystem == nil {
|
||||
if input.source.kind == sourceFile || input.source.kind == sourceFilesystem || input.source.kind == sourceSearch {
|
||||
diagnostics = append(diagnostics, optionDiagnostic(CodeOptionsInvalid, "file and search underlays cannot use main-relative context"))
|
||||
} else if input.mainRelative.Fallback != nil {
|
||||
diagnostics = append(diagnostics, filesystemOptionDiagnostics(Source{kind: sourceBytes}, input.mainRelative.Fallback)...)
|
||||
}
|
||||
}
|
||||
normalized, inputDiagnostics := normalizeInput(*input, "")
|
||||
*input = normalized
|
||||
diagnostics = append(diagnostics, inputDiagnostics...)
|
||||
@@ -71,10 +83,10 @@ func loadGroupedWithSecretLookupLimit[T any](request loadRequest[T], secrets Sec
|
||||
}
|
||||
diagnostics = append(diagnostics, overlayOptionDiagnostics(request.overlay)...)
|
||||
if activeOverlay(request.overlay) {
|
||||
if request.overlayFilesystem == nil {
|
||||
diagnostics = append(diagnostics, optionDiagnostic(CodeOptionsInvalid, "selected overlay requires explicit filesystem context"))
|
||||
} else {
|
||||
if request.overlayFilesystem != nil {
|
||||
diagnostics = append(diagnostics, filesystemOptionDiagnostics(Source{kind: sourceBytes}, request.overlayFilesystem)...)
|
||||
} else if request.overlayFallback != nil {
|
||||
diagnostics = append(diagnostics, filesystemOptionDiagnostics(Source{kind: sourceBytes}, request.overlayFallback)...)
|
||||
}
|
||||
}
|
||||
if len(diagnostics) != 0 {
|
||||
|
||||
Reference in New Issue
Block a user