From 5462582401fcc68b3e4a7b13004fec2227715704 Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Mon, 13 Jan 2025 11:05:17 -0700 Subject: [PATCH] drop unneeded methods Signed-off-by: Meredith Lancaster --- pkg/cmd/attestation/api/client.go | 14 ++--------- pkg/cmd/attestation/api/client_test.go | 34 +++++++++++++------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/pkg/cmd/attestation/api/client.go b/pkg/cmd/attestation/api/client.go index 526916bcd..c3670f42d 100644 --- a/pkg/cmd/attestation/api/client.go +++ b/pkg/cmd/attestation/api/client.go @@ -60,27 +60,17 @@ func NewLiveClient(hc *http.Client, host string, l *ioconfig.Handler) *LiveClien } } -func (c *LiveClient) BuildRepoAndDigestURL(repo, digest string) string { - repo = strings.Trim(repo, "/") - return fmt.Sprintf(GetAttestationByRepoAndSubjectDigestPath, repo, digest) -} - // GetByRepoAndDigest fetches the attestation by repo and digest func (c *LiveClient) GetByRepoAndDigest(repo, digest string, limit int) ([]*Attestation, error) { c.logger.VerbosePrintf("Fetching attestations for artifact digest %s\n\n", digest) - url := c.BuildRepoAndDigestURL(repo, digest) + url := fmt.Sprintf(GetAttestationByRepoAndSubjectDigestPath, repo, digest) return c.getByURL(url, limit) } -func (c *LiveClient) BuildOwnerAndDigestURL(owner, digest string) string { - owner = strings.Trim(owner, "/") - return fmt.Sprintf(GetAttestationByOwnerAndSubjectDigestPath, owner, digest) -} - // GetByOwnerAndDigest fetches attestation by owner and digest func (c *LiveClient) GetByOwnerAndDigest(owner, digest string, limit int) ([]*Attestation, error) { c.logger.VerbosePrintf("Fetching attestations for artifact digest %s\n\n", digest) - url := c.BuildOwnerAndDigestURL(owner, digest) + url := fmt.Sprintf(GetAttestationByOwnerAndSubjectDigestPath, owner, digest) return c.getByURL(url, limit) } diff --git a/pkg/cmd/attestation/api/client_test.go b/pkg/cmd/attestation/api/client_test.go index 9728b265c..b93d53b70 100644 --- a/pkg/cmd/attestation/api/client_test.go +++ b/pkg/cmd/attestation/api/client_test.go @@ -42,23 +42,23 @@ func NewClientWithMockGHClient(hasNextPage bool) Client { } } -func TestGetURL(t *testing.T) { - c := LiveClient{} - - testData := []struct { - repo string - digest string - expected string - }{ - {repo: "/github/example/", digest: "sha256:12313213", expected: "repos/github/example/attestations/sha256:12313213"}, - {repo: "/github/example", digest: "sha256:12313213", expected: "repos/github/example/attestations/sha256:12313213"}, - } - - for _, data := range testData { - s := c.BuildRepoAndDigestURL(data.repo, data.digest) - require.Equal(t, data.expected, s) - } -} +//func TestGetURL(t *testing.T) { +// c := LiveClient{} +// +// testData := []struct { +// repo string +// digest string +// expected string +// }{ +// {repo: "/github/example/", digest: "sha256:12313213", expected: "repos/github/example/attestations/sha256:12313213"}, +// {repo: "/github/example", digest: "sha256:12313213", expected: "repos/github/example/attestations/sha256:12313213"}, +// } +// +// for _, data := range testData { +// s := c.BuildRepoAndDigestURL(data.repo, data.digest) +// require.Equal(t, data.expected, s) +// } +//} func TestGetByDigest(t *testing.T) { c := NewClientWithMockGHClient(false)