mirror of
https://github.com/vee1e/gittuf.git
synced 2026-09-05 12:17:06 +00:00
This commit moves existing implementations of attestation predicates into subpackages to start supporting multiple versions in parallel. Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
24 lines
513 B
Go
24 lines
513 B
Go
// Copyright The gittuf Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package common
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"google.golang.org/protobuf/types/known/structpb"
|
|
)
|
|
|
|
func PredicateToPBStruct(predicate any) (*structpb.Struct, error) {
|
|
predicateBytes, err := json.Marshal(predicate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
predicateInterface := &map[string]any{}
|
|
if err := json.Unmarshal(predicateBytes, predicateInterface); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return structpb.NewStruct(*predicateInterface)
|
|
}
|