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

Pass headers to download url #190

Open
mruz opened this issue Sep 28, 2023 · 3 comments
Open

Pass headers to download url #190

mruz opened this issue Sep 28, 2023 · 3 comments

Comments

@mruz
Copy link
Contributor

mruz commented Sep 28, 2023

Is it possible to pass auth token in the headers to download_url? I need it to download asset from api.github.com:

curl -X POST registry.example.com/v1/api/modules/my-module/provider/1.0.0/upload \
    -H "Authorization: Bearer x-api-key:$TERRALIST_API_KEY" \
    -d '{
        "download_url": "https://api.github.com/repos/{OWNER}/{REPO}/releases/assets/{ASSET-ID}",
        "headers": {
           "Accept": "application/octet-stream",
           "Authorization:": "Bearer {TOKEN}",
           "X-GitHub-Api-Version": "2022-11-28"
        }
    }'
@valentindeaconu
Copy link
Collaborator

The short answer is no. Let me explain it: depending on how you're using Terralist there are 2 possibilities:

  1. You're using the "proxy" mode, which means it will forward the URLs to the clients. In that case, you can use go-getter's git protocol and save the URLs in this format. Then, on your clients, you must ensure they have git installed and configured with credentials that can read from those sources.
  2. You're using the S3 backend, meaning Terralist needs access to that resource. Again, you can use the go-getter's git protocol and configure Terralist to have git access to your resources.

However, in your case, you're trying to download assets from a particular release, and not the entire tag, and AFAIK this is not possible with go-getter, since this is not a git-specific feature, but a GitHub-specific.

I see there's a way for the go-getter package to forward some HTTP headers using the HTTP protocol, but unfortunately this is not currently available in Terralist.

@mruz
Copy link
Contributor Author

mruz commented Sep 29, 2023

In the latest release we have git installed, it works if I download the entire tag, but I have some modules that have symlinks to other modules and it doesn't work hashicorp/go-getter#60.

When I release a new version of modules that reference other modules, I upload an asset that follows symlinks, but to download it I have to use api.github.com and HTTP.

@mruz
Copy link
Contributor Author

mruz commented Sep 29, 2023

Instead of uploading the asset to github and downloading from the api, I uploaded it to s3 and downloaded from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants