(params FetchParams)
| 102 | } |
| 103 | |
| 104 | func (c *LiveClient) buildRequestURL(params FetchParams) (safeurl.SafeURL, error) { |
| 105 | if err := params.Validate(); err != nil { |
| 106 | return nil, err |
| 107 | } |
| 108 | |
| 109 | var u *safeurl.MutableSafeURL |
| 110 | if params.Repo != "" { |
| 111 | // check if Repo is set first because if Repo has been set, Owner will be set using the value of Repo. |
| 112 | // If Repo is not set, the field will remain empty. It will not be populated using the value of Owner. |
| 113 | owner, name, err := safeurl.RepoPartsFromNWO(params.Repo) |
| 114 | if err != nil { |
| 115 | return nil, err |
| 116 | } |
| 117 | u, err = safeurl.JoinPath("repos", owner, name, "attestations", params.Digest) |
| 118 | if err != nil { |
| 119 | return nil, err |
| 120 | } |
| 121 | } else { |
| 122 | var err error |
| 123 | u, err = safeurl.JoinPath("orgs", params.Owner, "attestations", params.Digest) |
| 124 | if err != nil { |
| 125 | return nil, err |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | perPage := params.Limit |
| 130 | if perPage > maxLimitForFetch { |
| 131 | perPage = maxLimitForFetch |
| 132 | } |
| 133 | |
| 134 | // ref: https://github.com/cli/go-gh/blob/d32c104a9a25c9de3d7c7b07a43ae0091441c858/example_gh_test.go#L96 |
| 135 | u.SetQuery("per_page", strconv.Itoa(perPage)) |
| 136 | if params.PredicateType != "" { |
| 137 | u.SetQuery("predicate_type", params.PredicateType) |
| 138 | } |
| 139 | return u, nil |
| 140 | } |
| 141 | |
| 142 | func (c *LiveClient) getAttestations(params FetchParams) ([]*Attestation, error) { |
| 143 | u, err := c.buildRequestURL(params) |
no test coverage detected