Skip to content

feat: allow http modules - #2275

Closed
jcdickinson wants to merge 1 commit into
dagger:mainfrom
jcdickinson:github-token
Closed

jcdickinson wants to merge 1 commit into
dagger:mainfrom
jcdickinson:github-token

Conversation

@jcdickinson

@jcdickinson jcdickinson commented Apr 22, 2022 •

Copy link
Copy Markdown
Contributor

This allows project update to download .tar.gz modules from an HTTP server. The module name is derived from the host and path portions of the URL. The fragment portion of the URL is used to define the actual download path. For example, https://github.com/dagger/dagger#/archive/refs/tags/v0.2.7.tar.gz results in the github.com/dagger/dagger module name and https://github.com/dagger/dagger/archive/refs/tags/v0.2.7.tar.gz download URL.

Support for providing a full authentication header has also been added. This is done with the --authorization-header flag. For example, --authorization-header 'token ghp_...'.

Finally, some of the require_tests were broken. The tests seemed to represent desired behavior, so I updatedparseDaggerRepoName.

Signed-off-by: Jonathan Dickinson

@helderco helderco linked an issue Apr 22, 2022 that may be closed by this pull request
17 tasks done
@jcdickinson

Copy link
Copy Markdown
Contributor Author

lint failure is due to Azure egress limit: https://github.com/dagger/dagger/runs/6132808931?check_suite_focus=true#step:6:384

5:43PM ERR actions.lint.cue._dag."1"._copy | failed: failed to compute cache key: failed to copy: invalid status response 503 Egress is over the account limit. for https://gel7acprodeus1file0.blob.core.windows.net/27543b5d759147d3b6e36a929aab1c78/fa1f96197eb4ec11997e281878563d51?sv=2019-07-07&sr=b&sig=gEI8KjkdxrSOaJqUvJZBsw02Equz4r1x%2BxaYdAJiG%2BY%3D&se=2022-04-22T18%3A43%3A43Z&sp=r&rscl=x-e2eid-98aca182-d5ab455b-aedf5d7e-57a9da85

@jcdickinson
jcdickinson marked this pull request as ready for review April 22, 2022 17:49
@jcdickinson
jcdickinson requested review from a team, aluzzardi, samalba and shykes as code owners April 22, 2022 17:49
@jcdickinson

jcdickinson commented Apr 22, 2022 •

Copy link
Copy Markdown
Contributor Author

Another option here might be to detect github.com and build a download URL, if a PAT is provided.

Edit: I'm building a PR to prove this out.

This allows `project update` to download .tar.gz modules from an HTTP server. The module name is derived from the host and path portions of the URL. The fragment portion of the URL is used to define the actual download path. For example, `https://github.com/dagger/dagger#/archive/refs/tags/v0.2.7.tar.gz` results in the `github.com/dagger/dagger` module name and `https://github.com/dagger/dagger/archive/refs/tags/v0.2.7.tar.gz` download URL.

Support for providing a _full_ authentication header has also been added. This is done with the `authorization-header` flag. For example, `--authorization-header 'token ghp_...'`.

Finally, some of the require_tests were broken. The tests seemed to represent desired behavior, so I updated`parseDaggerRepoName`.

Signed-off-by: Jonathan Dickinson <[email protected]>
@helderco helderco removed a link to an issue Apr 26, 2022
17 tasks done
Comment thread mod/http_repo_test.go
},
}

for _, c := range cases {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread mod/require.go
return nil, fmt.Errorf("issue when parsing HTTP repo")
}

clone, _ := url.Parse(repoName)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it repeated with line above?

@TomChv TomChv added size/medium area/cli All about go code on dagger CLI labels Apr 28, 2022

@TomChv TomChv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Do you have an example of a use case?

I left minor comments and I'll do some test and see how it reacts.

Comment thread mod/require.go
return &Require{
repo: u.Host + u.Path,
path: "",
version: "",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version and subpath are not handle?

Comment thread mod/file.go
}

func downloadHTTPModule(ctx context.Context, req *Require, tmpPath string) error {
return download(ctx, req, tmpPath, viper.GetString("authorization-header"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you do not directly implement download here? This is what we do with cloneGitModule

@jcdickinson

jcdickinson commented Apr 28, 2022 •

Copy link
Copy Markdown
Contributor Author

@TomChv all things considered, I'm increasingly disliking my approach with this PR. I think that #2286 is a much better approach. I just have to figure out what's going wrong with the build.

@jcdickinson
jcdickinson marked this pull request as draft April 28, 2022 20:07
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli All about go code on dagger CLI kind/stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants