dap: improve file explorer source names
Improves the naming for file explorer names when the input relates directly to a source. This is most common when the input is the context (which is just usually a simple source like `local://context`). This should help in most circumstances in determining which input is which. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
+14
-3
@@ -549,14 +549,25 @@ func (t *thread) solveInputs(ctx context.Context, target *step) (string, map[str
|
||||
}
|
||||
|
||||
func (t *thread) determineInputName(op *pb.Op, index int, input *pb.Input) string {
|
||||
switch op := op.Op.(type) {
|
||||
case *pb.Op_Exec:
|
||||
for _, m := range op.Exec.Mounts {
|
||||
// Attempt to match the input to one of the mount destinations if we have
|
||||
// an exec operation.
|
||||
if exec, ok := op.Op.(*pb.Op_Exec); ok {
|
||||
for _, m := range exec.Exec.Mounts {
|
||||
if m.Input >= 0 && m.Input == int64(index) {
|
||||
return m.Dest
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Is our input digest a source? Use the identifier if it is.
|
||||
// That should give us something that is at least more user-friendly.
|
||||
if op := t.ops[digest.Digest(input.Digest)]; op != nil && input.Index == 0 {
|
||||
if source, ok := op.Op.(*pb.Op_Source); ok {
|
||||
return source.Source.Identifier
|
||||
}
|
||||
}
|
||||
|
||||
// Use a default name that matches the input digest.
|
||||
return input.Digest
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user