Skip to content

Commit bacef74

Browse files
authored
Merge pull request #1023 from Shocktrooper/FixRegistryEnable
Adding registry enablement fixes
2 parents f283205 + a799b52 commit bacef74

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ website/build
3030
website/node_modules
3131
website/vendor
3232
/tmp
33+
certs/gitlab-registry.crt
34+
certs/gitlab-registry.key

CONTRIBUTING.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing to GitLab Terraform Provider
22

3-
Thank you for contributing to this provider! :tada: :heart: :trophy:
3+
Thank you for contributing to this provider! :tada: :heart: :trophy:
44

55
Generally we accept any change that adds or changes a Terraform resource that is in line with the [GitLab API](https://docs.gitlab.com/ee/api/api_resources.html). It is always best to [open an issue](https://github.com/gitlabhq/terraform-provider-gitlab/issues/new/choose) before starting on a change.
66

@@ -77,16 +77,15 @@ You'll first need [Go](http://www.golang.org) installed on your machine (version
7777
$ make build
7878
```
7979

80-
80+
8181
### Use a Remote Environment via GitPod
8282

83-
You can choose to use your own development environment if desired, however a `.gitpod.yml` file is included within the repository to allow the use of [GitPod](https://gitpod.io/) easily.
84-
This will allow you to use GitPod's integration with GitHub to quickly start a web-based development environment including Go and Docker, which are necessary
85-
for running tests. To use GitPod's integration, you have two different options described below. After you've completed one of the two options, your development environment
86-
will be ready within a minute or two. As part of starting up, your development environment will automatically start up the `gitlab-ce` container necessary for running
83+
You can choose to use your own development environment if desired, however a `.gitpod.yml` file is included within the repository to allow the use of [GitPod](https://gitpod.io/) easily.
84+
This will allow you to use GitPod's integration with GitHub to quickly start a web-based development environment including Go and Docker, which are necessary
85+
for running tests. To use GitPod's integration, you have two different options described below. After you've completed one of the two options, your development environment
86+
will be ready within a minute or two. As part of starting up, your development environment will automatically start up the `gitlab-ce` container necessary for running
8787
tests, as described in the "Running Tests/Option 1" section below.
8888

89-
9089
#### Option 1: Manually navigate to GitPod
9190

9291
You can manually sign in and open your workspace within GitPod by following these steps:
@@ -113,6 +112,8 @@ The acceptance tests can run against a Gitlab instance where you have a token wi
113112

114113
This option is the easiest and requires [docker-compose](https://docs.docker.com/compose/install/) (version 1.13+) to be installed on your machine.
115114

115+
Note that the you need an up-to-date version of GNU make and an up-to-date version of openssl / libressl.
116+
116117
1. Start the Gitlab container. It will take about 5 minutes for the container to become healthy.
117118

118119
```sh

GNUmakefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,20 @@ SERVICE ?= gitlab-ce
6565
GITLAB_TOKEN ?= ACCTEST1234567890123
6666
GITLAB_BASE_URL ?= http://127.0.0.1:8080/api/v4
6767

68-
testacc-up: ## Launch a GitLab instance.
68+
testacc-up: | certs ## Launch a GitLab instance.
6969
docker-compose up -d $(SERVICE)
7070
./scripts/await-healthy.sh
7171

7272
testacc-down: ## Teardown a GitLab instance.
73-
docker-compose down
73+
docker-compose down --volumes
7474

7575
testacc: ## Run acceptance tests against a GitLab instance.
7676
TF_ACC=1 GITLAB_TOKEN=$(GITLAB_TOKEN) GITLAB_BASE_URL=$(GITLAB_BASE_URL) go test -v $(PROVIDER_SRC_DIR) $(TESTARGS) -timeout 40m
7777

78+
certs: ## Generate certs for the GitLab container registry
79+
mkdir -p certs
80+
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout certs/gitlab-registry.key -out certs/gitlab-registry.crt -subj "/CN=gitlab-registry.com" -addext "subjectAltName=DNS:IP:127.0.0.1"
81+
7882
# TOOLS
7983
# Tool dependencies are installed into a project-local /bin folder.
8084

@@ -104,3 +108,6 @@ TERRAFORM_VERSION = v1.1.4
104108
tool-terraform:
105109
@# See https://github.com/hashicorp/terraform/issues/30356
106110
@[ -f $(GOBIN)/terraform ] || { mkdir -p tmp; cd tmp; rm -rf terraform; git clone --branch $(TERRAFORM_VERSION) --depth 1 https://github.com/hashicorp/terraform.git; cd terraform; GOBIN=$(GOBIN) go install; cd ..; rm -rf terraform; }
111+
112+
clean: testacc-down
113+
@rm -rf certs/

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ services:
1717
- logs-ce:/var/log/gitlab
1818
- data-ce:/var/opt/gitlab
1919
- ${PWD}/scripts/healthcheck-and-setup.sh:/healthcheck-and-setup.sh:Z
20+
- ${PWD}/scripts/gitlab.rb:/etc/gitlab/gitlab.rb:ro
21+
- ${PWD}/certs:/etc/gitlab/ssl:ro
2022
healthcheck:
2123
test: /healthcheck-and-setup.sh
2224
interval: 10s
@@ -38,6 +40,8 @@ services:
3840
- data-ee:/var/opt/gitlab
3941
- ${PWD}/scripts/healthcheck-and-setup.sh:/healthcheck-and-setup.sh:Z
4042
- ${PWD}/Gitlab-license.txt:/Gitlab-license.txt:Z
43+
- ${PWD}/scripts/gitlab.rb:/etc/gitlab/gitlab.rb:ro
44+
- ${PWD}/certs:/etc/gitlab/ssl:ro
4145
healthcheck:
4246
test: /healthcheck-and-setup.sh
4347
interval: 10s

scripts/gitlab.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
registry_external_url 'http://127.0.0.1:5050'
2+
registry['enable'] = true
3+
registry_nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab-registry.pem"
4+
registry_nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab-registry.key"

scripts/healthcheck-and-setup.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ test -f $done || {
2828
printf 'terraform_token.save!;'
2929
) | gitlab-rails console
3030

31-
echo "Enabling the container registry for the instance so that Personal Access Tokens can be created with the read_registry and write_registry scopes"
32-
(
33-
printf 'Gitlab.config.registry["enabled"] = true'
34-
) | gitlab-rails console
35-
3631
# 2020-09-07: Currently Gitlab (version 13.3.6 ) doesn't allow in admin API
3732
# ability to set a group as instance level templates.
3833
# To test resource_gitlab_project_test template features we add

0 commit comments

Comments
 (0)