terraform-provider-gitlab
terraform-provider-gitlab copied to clipboard
Feature Request: Repository archive download
GitLab exposes the API /<owner>/<project>/repository/archive.{zip,tar.gz} (maybe other formats as well, I don't know at the moment) for downloading the repository's contents in an archive file. For anyone who needs that archive, it would be super helpful to be able to use an attribute on the gitlab_project data source like:
data "gitlab_project" "my_project" {
# Set up project access here ...
}
resource "local_file" "repo_archive" {
filename = "archive.zip"
content = data.gitlab_project.my_project.archive_zip
}
Is there something like that possible at this time? Is someone working on such a feature? I would like to begin working on it, so please let's gather knowledge on this topic. The main benefit of this would be that downloading would use the provider's authentication instead of having to do it separately.
Hi ggPeti,
I have a question and two observations:
Why would you need this file? Is it for backing up? in that case is it is probably not very wise to rely on the moment whenever somebody happens to run Terraform to get a new version of you're backup.
If it is for the purpose of working with the code I would also suggest the use of git clone which has very user friendly authentication based on ssh.
Observation: If this is possible it still really isn't what Terraform is supposed to do. resources are intended to create state in the world. To achieve that they can also gather data, But using it for downloading files is a whole other thing.
Observation 2: the URL you are using is not part of the API, and it seems unlikely that you can even use the api-token that the provider uses to authenticate yourself there. (When using this link from the browser you are identified by the gitlab-session cookie)
It shouldn't be an attribute on the existing gitlab_project data source, because of the added overhead of downloading the archive, but it could be a new data source gitlab_project_repository_archive.
This is one of the oldest open requests without really any activity.
@ggPeti is this still something you would like to have supported in the provider? Could you elaborate on your use case a little bit? As @sudoapt-getclean already mentioned I'm not sure if it really fits the "Terraform use-case" ... however, I'm open to be convinced 😊
Hey @timofurrer, thanks for following up! At the moment I'm not needing this functionality any more, but afaik Google Cloud Functions takes a zipball as input. So this feature could be used in defining a cloud function with code hosted on GitLab.