zbindenren / terraform-provider-gitlab

Terraform GitLab provider

Home Page:https://www.terraform.io/docs/providers/gitlab/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform Provider for Gitlab

Requirements

  • Terraform 0.12.x
  • Go >= 1.14 (to build the provider plugin)

Developing The Provider

If you wish to work on the provider, you'll first need Go installed on your machine (version 1.14+ is required).

  1. Clone the git repository.

    $ git clone git@github.com:gitlabhq/terraform-provider-gitlab
    $ cd terraform-provider-gitlab
  2. Build the provider with make build. This will build the provider and put the provider binary in the $GOPATH/bin directory.

    $ make build

Running Tests

The acceptance tests can run against a Gitlab instance where you have a token with administrator permissions (likely not gitlab.com).

Option 1: Run tests against a local Gitlab container with docker-compose

This option is the easiest and requires docker-compose (version 1.13+) to be installed on your machine.

  1. Start the Gitlab container. It will take about 5 minutes for the container to become healthy.
$ make testacc-up
  1. Run the acceptance tests. The full suite takes 10-20 minutes to run.
$ make testacc
  1. Stop the Gitlab container.
$ make testacc-down

Option 2: Run tests against your own Gitlab instance

If you have your own hosted Gitlab instance, you can run the tests against it directly.

$ make testacc GITLAB_TOKEN=example123 GITLAB_BASE_URL=https://example.com/api/v4

GITLAB_TOKEN must be a valid token for an account with admin privileges.

Testing Tips

  • Gitlab Community Edition and Gitlab Enterprise Edition:

    This module supports both Gitlab CE and Gitlab EE. We run tests on Gitlab EE, but can't run them on pull requests from forks.

    Features that only work on one flavour can use the following helpers as SkipFunc: isRunningInEE and isRunningInCE. You can see an example of this for gitlab_project_level_mr_approvals tests.

  • Run EE tests:

    If you have a Gitlab-license.txt you can run Gitlab EE, which will enable the full suite of tests:

    $ make testacc-up SERVICE=gitlab-ee
  • Run a single test:

    You can pass a pattern to the RUN variable to run a reduced number of tests. For example:

    $ make testacc RUN=TestAccGitlabGroup

    ...will run all tests for the gitlab_group resource.

  • Debug a test in an IDE:

    First start the Gitlab container with make testacc-up. Then run the desired Go test as you would normally from your IDE, but configure your run configuration to set these environment variables:

    GITLAB_TOKEN=ACCTEST
    GITLAB_BASE_URL=http://127.0.0.1:8080/api/v4
    TF_ACC=1
    
  • Useful HashiCorp documentation:

    Refer to HashiCorp's testing guide and HashiCorp's testing best practices.

About

Terraform GitLab provider

https://www.terraform.io/docs/providers/gitlab/

License:Mozilla Public License 2.0


Languages

Language:Go 99.2%Language:Shell 0.6%Language:Makefile 0.2%