MCPcopy Create free account
hub / github.com/conforma/cli / applyPatches

Function applyPatches

acceptance/image/image.go:1397–1426  ·  view source on GitHub ↗
(statement *in_toto.ProvenanceStatementSLSA02, patches *godog.Table)

Source from the content-addressed store, hash-verified

1395}
1396
1397func applyPatches(statement *in_toto.ProvenanceStatementSLSA02, patches *godog.Table) (*in_toto.ProvenanceStatementSLSA02, error) {
1398 if statement == nil || patches == nil || len(patches.Rows) == 0 {
1399 return statement, nil
1400 }
1401
1402 stmt, err := json.Marshal(statement)
1403 if err != nil {
1404 return nil, err
1405 }
1406
1407 for _, patch := range patches.Rows {
1408 val := patch.Cells[0].Value
1409 jp, err := jsonpatch.DecodePatch([]byte(val))
1410 if err != nil {
1411 return nil, err
1412 }
1413
1414 stmt, err = jp.Apply(stmt)
1415 if err != nil {
1416 return nil, err
1417 }
1418 }
1419
1420 var modified in_toto.ProvenanceStatementSLSA02
1421 if err := json.Unmarshal(stmt, &modified); err != nil {
1422 return nil, err
1423 }
1424
1425 return &modified, nil
1426}
1427
1428// steal creates an image using createAndPushImage and steals the signature
1429// ("sig") or attestation ("att")

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected