signature/policy_config.go
func newPolicyReferenceMatchFromJSON(data []byte) (PolicyReferenceMatch, error) {
	var typeField prmCommon
	if err := json.Unmarshal(data, &typeField); err != nil {
		return nil, err
	}
	var res PolicyReferenceMatch
	switch typeField.Type {
	case prmTypeMatchExact:
		res = &prmMatchExact{}
	case prmTypeMatchRepoDigestOrExact:
		res = &prmMatchRepoDigestOrExact{}
	case prmTypeMatchRepository:
		res = &prmMatchRepository{}
	case prmTypeExactReference:
		res = &prmExactReference{}
	case prmTypeExactRepository:
		res = &prmExactRepository{}
	default:
		return nil, InvalidPolicyFormatError(fmt.Sprintf("Unknown policy reference match type \"%s\"", typeField.Type))
	}
	if err := json.Unmarshal(data, &res); err != nil {
		return nil, err
	}
	return res, nil
}
func newPolicyReferenceMatchFromJSON(data []byte) (PolicyReferenceMatch, error) {
	var typeField prmCommon
	if err := json.Unmarshal(data, &typeField); err != nil {
		return nil, err
	}
	var res PolicyReferenceMatch
	switch typeField.Type {
	case prmTypeMatchExact:
		res = &prmMatchExact{}
	case prmTypeMatchRepoDigestOrExact:
		res = &prmMatchRepoDigestOrExact{}
	case prmTypeMatchRepository:
		res = &prmMatchRepository{}
	case prmTypeExactReference:
		res = &prmExactReference{}
	case prmTypeExactRepository:
		res = &prmExactRepository{}
	default:
		return nil, InvalidPolicyFormatError(fmt.Sprintf("Unknown policy reference match type \"%s\"", typeField.Type))
	}
	if err := json.Unmarshal(data, &res); err != nil {
		return nil, err
	}
	return res, nil
}
func newPolicyReferenceMatchFromJSON ( data [ ] byte ) ( PolicyReferenceMatch , error ) { var typeField prmCommon if err := json . Unmarshal ( data , & typeField ) ; err != nil { return nil , err } var res PolicyReferenceMatch switch typeField . Type { case prmTypeMatchExact : res = & prmMatchExact { } case prmTypeMatchRepoDigestOrExact : res = & prmMatchRepoDigestOrExact { } case prmTypeMatchRepository : res = & prmMatchRepository { } case prmTypeExactReference : res = & prmExactReference { } case prmTypeExactRepository : res = & prmExactRepository { } default : return nil , InvalidPolicyFormatError ( fmt . Sprintf ( " \" \" " , typeField . Type ) ) } if err := json . Unmarshal ( data , & res ) ; err != nil { return nil , err } return res , nil }
// newPolicyReferenceMatchFromJSON parses JSON data into a PolicyReferenceMatch implementation.
newPolicyReferenceMatchFromJSON parses JSON data into a PolicyReferenceMatch implementation .