(params FetchParams)
| 101 | } |
| 102 | |
| 103 | func (c *LiveClient) buildRequestURL(params FetchParams) (string, error) { |
| 104 | if err := params.Validate(); err != nil { |
| 105 | return "", err |
| 106 | } |
| 107 | |
| 108 | var url string |
| 109 | if params.Repo != "" { |
| 110 | // check if Repo is set first because if Repo has been set, Owner will be set using the value of Repo. |
| 111 | // If Repo is not set, the field will remain empty. It will not be populated using the value of Owner. |
| 112 | url = fmt.Sprintf(GetAttestationByRepoAndSubjectDigestPath, params.Repo, params.Digest) |
| 113 | } else { |
| 114 | url = fmt.Sprintf(GetAttestationByOwnerAndSubjectDigestPath, params.Owner, params.Digest) |
| 115 | } |
| 116 | |
| 117 | perPage := params.Limit |
| 118 | if perPage > maxLimitForFetch { |
| 119 | perPage = maxLimitForFetch |
| 120 | } |
| 121 | |
| 122 | // ref: https://github.com/cli/go-gh/blob/d32c104a9a25c9de3d7c7b07a43ae0091441c858/example_gh_test.go#L96 |
| 123 | url = fmt.Sprintf("%s?per_page=%d", url, perPage) |
| 124 | if params.PredicateType != "" { |
| 125 | url = fmt.Sprintf("%s&predicate_type=%s", url, neturl.QueryEscape(params.PredicateType)) |
| 126 | } |
| 127 | return url, nil |
| 128 | } |
| 129 | |
| 130 | func (c *LiveClient) getAttestations(params FetchParams) ([]*Attestation, error) { |
| 131 | url, err := c.buildRequestURL(params) |
no test coverage detected