MCPcopy Index your code
hub / github.com/cli/cli / buildRequestURL

Method buildRequestURL

pkg/cmd/attestation/api/client.go:103–128  ·  view source on GitHub ↗
(params FetchParams)

Source from the content-addressed store, hash-verified

101}
102
103func (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
130func (c *LiveClient) getAttestations(params FetchParams) ([]*Attestation, error) {
131 url, err := c.buildRequestURL(params)

Callers 1

getAttestationsMethod · 0.95

Calls 1

ValidateMethod · 0.80

Tested by

no test coverage detected