Skip to content

Commit

Permalink
remove unused root param (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
smonero authored Mar 25, 2024
1 parent d9bcb95 commit e13ccb9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion server/neptune/workflows/activities/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (a *githubActivities) GithubFetchRoot(ctx context.Context, request FetchRoo
if resp.StatusCode != http.StatusFound {
return FetchRootResponse{}, errors.Errorf("getting repo archive link returns non-302 status %d", resp.StatusCode)
}
downloadLink := a.LinkBuilder.BuildDownloadLinkFromArchive(archiveLink, request.Root, request.Repo, request.Revision)
downloadLink := a.LinkBuilder.BuildDownloadLinkFromArchive(archiveLink, request.Repo, request.Revision)
err = a.Getter(ctx, repositoryPath, downloadLink)
if err != nil {
return FetchRootResponse{}, errors.Wrap(err, "fetching and extracting zip")
Expand Down
3 changes: 1 addition & 2 deletions server/neptune/workflows/activities/github/link/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"net/url"

"github.com/runatlantis/atlantis/server/neptune/workflows/activities/github"
"github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform"
)

type Builder struct{}

// BuildDownloadLinkFromArchive is a helper fxn that isolates the logic of modifying a GH archive link
// into source url that the go-getter library understand for downloading
func (b Builder) BuildDownloadLinkFromArchive(archiveURL *url.URL, root terraform.Root, repo github.Repo, revision string) string {
func (b Builder) BuildDownloadLinkFromArchive(archiveURL *url.URL, repo github.Repo, revision string) string {
// Add archive query parameter for getter library to extract archive
queryParams := "archive=zip"
token := archiveURL.Query().Get("token")
Expand Down
11 changes: 2 additions & 9 deletions server/neptune/workflows/activities/github/link/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ import (

"github.com/runatlantis/atlantis/server/neptune/workflows/activities/github"
"github.com/runatlantis/atlantis/server/neptune/workflows/activities/github/link"
"github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform"
"github.com/stretchr/testify/assert"
)

func Test_BuildDownloadLinkFromArchive(t *testing.T) {
expectedURL := "https://github.com/testowner/testrepo/legacy.zip/refs/heads/main//testowner-testrepo-a1b2c3d?archive=zip&token=testtoken123"
testRoot := terraform.Root{
Path: "test/path",
}
testRepo := github.Repo{
Owner: "testowner",
Name: "testrepo",
Expand All @@ -23,15 +19,12 @@ func Test_BuildDownloadLinkFromArchive(t *testing.T) {
archiveURL, err := httpurl.Parse("https://github.com/testowner/testrepo/legacy.zip/refs/heads/main?token=testtoken123")
assert.NoError(t, err)
linkBuilder := link.Builder{}
downloadLink := linkBuilder.BuildDownloadLinkFromArchive(archiveURL, testRoot, testRepo, testRevision)
downloadLink := linkBuilder.BuildDownloadLinkFromArchive(archiveURL, testRepo, testRevision)
assert.Equal(t, expectedURL, downloadLink)
}

func Test_BuildDownloadLinkFromArchive_NoToken(t *testing.T) {
expectedURL := "https://github.com/testowner/testrepo/legacy.zip/refs/heads/main//testowner-testrepo-a1b2c3d?archive=zip"
testRoot := terraform.Root{
Path: "/test/path",
}
testRepo := github.Repo{
Owner: "testowner",
Name: "testrepo",
Expand All @@ -40,6 +33,6 @@ func Test_BuildDownloadLinkFromArchive_NoToken(t *testing.T) {
archiveURL, err := httpurl.Parse("https://github.com/testowner/testrepo/legacy.zip/refs/heads/main")
assert.NoError(t, err)
linkBuilder := link.Builder{}
downloadLink := linkBuilder.BuildDownloadLinkFromArchive(archiveURL, testRoot, testRepo, testRevision)
downloadLink := linkBuilder.BuildDownloadLinkFromArchive(archiveURL, testRepo, testRevision)
assert.Equal(t, expectedURL, downloadLink)
}
3 changes: 1 addition & 2 deletions server/neptune/workflows/activities/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
internal "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github"
"github.com/runatlantis/atlantis/server/neptune/workflows/activities/github/cli"
"github.com/runatlantis/atlantis/server/neptune/workflows/activities/github/link"
"github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform"
"github.com/slack-go/slack"
)

Expand Down Expand Up @@ -205,7 +204,7 @@ type Github struct {
}

type LinkBuilder interface {
BuildDownloadLinkFromArchive(archiveURL *url.URL, root terraform.Root, repo internal.Repo, revision string) string
BuildDownloadLinkFromArchive(archiveURL *url.URL, repo internal.Repo, revision string) string
}

func NewGithubWithClient(client githubClient, dataDir string, getter gogetter, allocator feature.Allocator) (*Github, error) {
Expand Down

0 comments on commit e13ccb9

Please sign in to comment.