Fix missing capabilities in FileOp

Marshal the constraints after the capabilities are added, not before.

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
master
Aaron Lehmann 2022-02-07 08:22:25 -08:00
parent a640b47cb1
commit b92a6170cf
1 changed files with 7 additions and 5 deletions

View File

@ -683,12 +683,18 @@ func (f *FileOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
f.constraints.Platform = p f.constraints.Platform = p
} }
state := newMarshalState(ctx)
for _, st := range state.actions {
if adder, isCapAdder := st.action.(capAdder); isCapAdder {
adder.addCaps(f)
}
}
pop, md := MarshalConstraints(c, &f.constraints) pop, md := MarshalConstraints(c, &f.constraints)
pop.Op = &pb.Op_File{ pop.Op = &pb.Op_File{
File: pfo, File: pfo,
} }
state := newMarshalState(ctx)
_, err := state.add(f.action, c) _, err := state.add(f.action, c)
if err != nil { if err != nil {
return "", nil, nil, nil, err return "", nil, nil, nil, err
@ -696,10 +702,6 @@ func (f *FileOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
pop.Inputs = state.inputs pop.Inputs = state.inputs
for i, st := range state.actions { for i, st := range state.actions {
if adder, isCapAdder := st.action.(capAdder); isCapAdder {
adder.addCaps(f)
}
output := pb.OutputIndex(-1) output := pb.OutputIndex(-1)
if i+1 == len(state.actions) { if i+1 == len(state.actions) {
output = 0 output = 0