terraform-provider-gitlab icon indicating copy to clipboard operation
terraform-provider-gitlab copied to clipboard

Feature Request: Repository archive download

Open ggPeti opened this issue 6 years ago • 4 comments

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.

ggPeti avatar Sep 11 '19 13:09 ggPeti

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)

sudoapt-getclean avatar Sep 27 '19 21:09 sudoapt-getclean

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.

armsnyder avatar Sep 13 '20 00:09 armsnyder

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 😊

timofurrer avatar Aug 27 '22 11:08 timofurrer

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.

ggPeti avatar Aug 27 '22 12:08 ggPeti