Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EC-960 Remove last remnants of go-getter #2300

Merged
merged 4 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ require (
github.com/MakeNowJust/heredoc v1.0.0
github.com/Maldris/go-billy-afero v0.0.0-20200815120323-e9d3de59c99a
github.com/enterprise-contract/enterprise-contract-controller/api v0.1.71
github.com/enterprise-contract/go-gather v0.0.7
github.com/enterprise-contract/go-gather v0.1.2
github.com/evanphx/json-patch v5.9.0+incompatible
github.com/gkampitakis/go-snaps v0.5.7
github.com/go-git/go-git/v5 v5.13.2
github.com/go-logr/logr v1.4.2
github.com/google/go-cmp v0.6.0
github.com/google/go-containerregistry v0.20.2
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
github.com/hashicorp/go-getter v1.7.6
github.com/in-toto/in-toto-golang v0.9.0
github.com/jstemmer/go-junit-report/v2 v2.1.0
github.com/konflux-ci/application-api v0.0.0-20240812090716-e7eb2ecfb409
Expand Down Expand Up @@ -207,6 +206,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.6 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,8 @@ github.com/enterprise-contract/enterprise-contract-controller/api v0.1.71 h1:vQg
github.com/enterprise-contract/enterprise-contract-controller/api v0.1.71/go.mod h1:zkK1IrRezUgKGK4tkN9hJtpu8NVqjKTMh4EshxXOi3g=
github.com/enterprise-contract/go-containerregistry v0.20.3-0.20241118083807-8c8ea269355e h1:Rti5Q7fdkzIMO+lRLAFaBSReLpNx4yTdq+u6PRJv1Tw=
github.com/enterprise-contract/go-containerregistry v0.20.3-0.20241118083807-8c8ea269355e/go.mod h1:QTzGuUYojyBy1anZvBPMhwXRE0LGZPIcpmn3K8DHYrw=
github.com/enterprise-contract/go-gather v0.0.7 h1:xX6sqx65x4YGxXHoCWu3Ssy3Eg1EYbM8Va38ghnsriY=
github.com/enterprise-contract/go-gather v0.0.7/go.mod h1:fk2KNEL5gYVqEgU4zYXI+ckwwL5yDjEF8on8b5L/Iqk=
github.com/enterprise-contract/go-gather v0.1.2 h1:uM13ds2Toq0w3bH1pj55vIiahQ2dQhATx1Pvld/giDo=
github.com/enterprise-contract/go-gather v0.1.2/go.mod h1:DrMwce0sBK/gzEwMDRD/Dx+T0/O6LN6F5C/OaOgZnw0=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
Expand Down
2 changes: 0 additions & 2 deletions internal/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
//
// SPDX-License-Identifier: Apache-2.0

// Package downloader is a wrapper for the equivalent Conftest package,
// which is itself mostly a wrapper for hashicorp/go-getter.
package downloader

import (
Expand Down
16 changes: 4 additions & 12 deletions internal/policy/source/git_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,26 @@ package source
import (
"context"
"fmt"
"strings"

getter "github.com/hashicorp/go-getter"
"github.com/enterprise-contract/go-gather/detector"
log "github.com/sirupsen/logrus"
)

// SourceIsFile returns true if go-getter thinks the src looks like a file path.
// Ensuring that the src is not a git url is important because go-getter can think
// that a git url is a file path url.
func SourceIsFile(src string) bool {
normalizedUrl, err := getter.Detect(src, ".", []getter.Detector{new(getter.FileDetector)})
return err == nil && strings.HasPrefix(normalizedUrl, "file") && !SourceIsGit(src)
return detector.FileDetector(src)
}

// SourceIsGit returns true if go-getter thinks the src looks like a git url
func SourceIsGit(src string) bool {
normalizedUrl, err := getter.Detect(src, ".", []getter.Detector{
new(getter.GitHubDetector),
new(getter.GitLabDetector),
new(getter.GitDetector),
})
return err == nil && strings.HasPrefix(normalizedUrl, "git::")
return detector.GitDetector(src)
}

// SourceIsHttp returns true if go-getter thinks the src looks like an http url
func SourceIsHttp(src string) bool {
normalizedUrl, err := getter.Detect(src, ".", getter.Detectors)
return err == nil && strings.HasPrefix(normalizedUrl, "http")
return detector.HttpDetector(src)
}

func GoGetterDownload(ctx context.Context, tmpDir, src string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/policy/source/git_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestSourceIsFile(t *testing.T) {
want bool
}{
{src: "", want: false},
{src: "foo", want: true},
robnester-rh marked this conversation as resolved.
Show resolved Hide resolved
robnester-rh marked this conversation as resolved.
Show resolved Hide resolved
{src: "foo", want: false},
{src: "https://foo.bar/asdf", want: false},
{src: "git::https://foo.bar/asdf", want: false},
{src: "git::github.com/foo/bar", want: false},
Expand Down
Loading