Skip to content

Commit fef1e1a

Browse files
authored
Harbor V2 Acceptance Tests (#16)
Add support for Harbor V1 and V2 Acceptance Tests.
1 parent dd91204 commit fef1e1a

29 files changed

+521
-142
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/i
4848
RUN curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.3.0
4949

5050
RUN npm i markdown-spellcheck -g
51+
52+
RUN curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
53+
54+
RUN npm i madr adr-log -g

.devcontainer/DockerfileDocs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:alpine
2+
3+
RUN echo "**** install Python ****" && \
4+
apk add --update-cache \
5+
linux-headers gnupg openssl gcc build-base libc-dev musl-dev ca-certificates \
6+
&& rm -rf /var/cache/apk/*
7+
8+
ARG USERNAME=vscode
9+
ARG USER_UID=1000
10+
ARG USER_GID=1000
11+
12+
RUN adduser $USERNAME -s /bin/sh -D -u $USER_UID $USER_GID
13+
14+
RUN pip install mkdocs
15+
16+
RUN mkdir -p /workspace \
17+
&& chown -R ${USER_UID}:${USER_UID} /workspace
18+
19+
USER ${USERNAME}
20+
21+
WORKDIR /workspace

.devcontainer/devcontainer.json

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
],
66
"service": "vscode",
77
"runServices": [
8-
"vscode"
8+
"vscode",
9+
"mkdocs"
910
],
1011
"mounts": [
1112
"source=terraform-harbor-vol,target=/home/vscode/.vscode-server/extensions,type=volume",
@@ -22,6 +23,7 @@
2223
"redhat.vscode-yaml", // Kubernetes and Kedge syntax support
2324
// Go
2425
"ms-vscode.go",
26+
"hbenl.vscode-test-explorer",
2527
"ethan-reesor.vscode-go-test-adapter",
2628
// Console
2729
"IBM.output-colorizer",
@@ -45,7 +47,7 @@
4547
// markdown
4648
"docsmsft.docs-article-templates",
4749
"docsmsft.docs-markdown",
48-
"mauve.terraform",
50+
"HashiCorp.terraform",
4951
"ms-kubernetes-tools.kind-vscode",
5052
"ms-kubernetes-tools.vscode-kubernetes-tools",
5153
"jetmartin.bats",
@@ -65,16 +67,6 @@
6567
"editor.insertSpaces": false,
6668
"editor.detectIndentation": false
6769
},
68-
"go.testEnvVars": {
69-
"HARBOR_ENDPOINT":"harbor.192-168-178-51.sslip.io",
70-
"HARBOR_USERNAME":"admin",
71-
"HARBOR_PASSWORD":"Harbor12345",
72-
"HARBOR_INSECURE":"true",
73-
"TF_ACC":"1"
74-
},
75-
76-
"go.testFlags": ["-v"],
77-
"go.buildFlags": ["-v"],
78-
"go.testTimeout": "180s"
70+
"go.useLanguageServer": true,
7971
}
8072
}

.devcontainer/docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
version: "3.7"
22

33
services:
4+
mkdocs:
5+
build:
6+
context: .
7+
dockerfile: DockerfileDocs
8+
volumes:
9+
- ../:/workspace:ro
10+
entrypoint: mkdocs serve -a 0.0.0.0:8000
11+
ports:
12+
- 8000:8000
413
vscode:
514
build: .
615
# image: docker.pkg.github.com/nolte/vscode-devcontainers/k8s-operator:latest

.github/workflows/cicd-acc.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Acception Tests CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
tags-ignore:
8+
- "*.*"
9+
pull_request:
10+
jobs:
11+
acc:
12+
name: Acception Tests
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Set up Go 1.x
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: ^1.14
19+
id: go
20+
21+
- name: Get dependencies
22+
run: |
23+
SWAGGER_VERSION=v0.23.0
24+
mkdir -p $HOME/bin
25+
curl -Lo $HOME/bin/swagger https://github.com/go-swagger/go-swagger/releases/download/${SWAGGER_VERSION}/swagger_linux_amd64 \
26+
&& chmod +x $HOME/bin/swagger
27+
echo "::add-path::$HOME/bin"
28+
29+
- name: Use Node.js
30+
uses: actions/setup-node@v1
31+
with:
32+
node-version: 12.x
33+
34+
- name: npm install swagger-merger
35+
run: |
36+
npm install swagger-merger -g
37+
38+
- name: Check out code into the Go module directory
39+
uses: actions/checkout@v2
40+
41+
- name: install golangci-lint
42+
run: |
43+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
44+
45+
- name: test provider
46+
run: |
47+
make generate
48+
49+
#- name: setup Docker
50+
# uses: docker-practice/actions-setup-docker@master
51+
# with:
52+
# docker_version: 19.09
53+
# docker_channel: stable
54+
#- name: Test
55+
# run: |
56+
# set -x
57+
# docker version
58+
# cat /etc/docker/daemon.json
59+
# docker buildx version || true
60+
# docker buildx ls || true
61+
# https://github.com/engineerd/setup-kind
62+
- uses: engineerd/[email protected]
63+
with:
64+
skipClusterCreation: true
65+
66+
- name: Starting the Kind Cluster
67+
run: |
68+
./scripts/tst-00-prepare-kind.sh
69+
70+
- name: Testing
71+
run: |
72+
kind export kubeconfig
73+
kubectl cluster-info
74+
kubectl get pods -n kube-system
75+
NODEDNSNAME=$(kubectl get nodes -ojson | jq '.items[0].status.addresses[0].address' -r | sed 's/\./-/g')
76+
echo "::set-env name=INGRESS_DOMAIN::${NODEDNSNAME}.sslip.io"
77+
echo "current-context:" $(kubectl config current-context)
78+
echo "environment-kubeconfig:" ${KUBECONFIG}
79+
80+
- name: install helm3
81+
run: |
82+
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
83+
84+
- name: install harbor
85+
run: |
86+
./scripts/tst-01-prepare-harbor.sh ${INGRESS_DOMAIN} "1.4.0"
87+
#- name: install harbor
88+
# run: |
89+
# echo "::set-env name=INGRESS_DOMAIN::harbor.${NODEDNSNAME}.sslip.io"
90+
91+
- name: Starting the Acc
92+
run: |
93+
./scripts/tst-15-execute-go-acc.sh "/api/v2.0"
94+
95+
- name: remove the kind cluster
96+
if: ${{ always() }}
97+
run: |
98+
kind delete cluster
99+
100+
#

.github/workflows/cicd-build.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,3 @@ jobs:
4545
- name: test provider
4646
run: |
4747
make build
48-
49-
- name: Upload Binaryies for publishing
50-
uses: actions/[email protected]
51-
with:
52-
name: bin
53-
path: ${{ github.workspace }}/bin/**

.github/workflows/cicd-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
tags:
66
- "release/*"
77
jobs:
8-
build:
9-
name: Build
8+
releaseBuild:
9+
name: ReleaseBuild
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Set up Go 1.x
@@ -69,7 +69,7 @@ jobs:
6969
publish_release_artefacts:
7070
name: Publish Release Artefacts
7171
runs-on: ubuntu-latest
72-
needs: [build]
72+
needs: [releaseBuild]
7373
steps:
7474
- uses: actions/download-artifact@v2
7575
with:
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: devcontainers
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
paths:
7+
- ".devcontainer/Dockerfile**"
8+
- .github/workflows/devcontainers.yml
9+
push:
10+
branches:
11+
- "**"
12+
paths:
13+
- ".devcontainer/Dockerfile**"
14+
- .github/workflows/devcontainers.yml
15+
16+
jobs:
17+
devcontainers-check:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: azure/docker-login@v1
22+
with:
23+
login-server: docker.pkg.github.com
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: buid vscode dev image
28+
run: |
29+
cd .devcontainer
30+
docker build -f Dockerfile .
31+
docscontainers-check:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v2
35+
36+
- name: buid docs image
37+
run: |
38+
cd .devcontainer
39+
docker build -f DockerfileDocs .

Makefile

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,32 @@ scriptsLint:
5858

5959
e2e_prepare:
6060
scripts/tst-00-prepare-kind.sh
61-
scripts/tst-01-prepare-harbor.sh
6261

63-
e2e_cleanup:
64-
kind delete cluster
6562

66-
e2e_test:
67-
scripts/tst-15-execute-go-acc.sh
63+
e2e_prepare_harbor_v1:
64+
scripts/tst-01-prepare-harbor.sh "172-17-0-1.sslip.io" "1.3.2"
65+
66+
e2e_prepare_harbor_v2:
67+
scripts/tst-01-prepare-harbor.sh "172-17-0-1.sslip.io" "1.4.0"
68+
69+
e2e_clean_cluster:
70+
kind delete cluster || true
71+
72+
e2e_clean_harbor:
73+
helm delete tf-harbor-test -n harbor
74+
sleep 10
75+
76+
e2e_test_v2:
77+
scripts/tst-15-execute-go-acc.sh "/api/v2.0"
78+
79+
e2e_test_v1:
80+
scripts/tst-15-execute-go-acc.sh "/api"
6881

6982
e2e_test_classic:
7083
bats scripts/test/bats
7184

85+
e2e_full_run: e2e_clean_cluster e2e_prepare e2e_prepare_harbor_v2 e2e_test_v2 e2e_clean_harbor e2e_prepare_harbor_v1 e2e_test_v1 e2e_clean_cluster
86+
# e2e_prepare e2e_prepare_harbor_v1 e2e_test e2e_cleanup
7287
spellingCheck:
7388
mdspell '**/*.md' '!**/node_modules/**/*.md'
7489

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Harbor Provider
22

3-
The ```terraform-provider-harbor``` is used to configure an instance of [Harbor](https://goharbor.io) in version `1.10.2`
3+
The ```terraform-provider-harbor``` is used to configure an instance of [Harbor](https://goharbor.io).
44

55
This is original based on the Work from [BESTSELLER/terraform-harbor-provider](https://github.com/BESTSELLER/terraform-harbor-provider), but with some incompatible changes, like the access to the Harbor API.
66

7-
![Classic CI/CD](https://github.com/nolte/terraform-provider-harbor/workflows/Classic%20CI/CD/badge.svg)
8-
![Release Flow](https://github.com/nolte/terraform-provider-harbor/workflows/Release%20Flow/badge.svg)
7+
[![Classic CI/CD](https://github.com/nolte/terraform-provider-harbor/workflows/Classic%20CI/CD/badge.svg)](https://github.com/nolte/terraform-provider-harbor/actions?query=workflow%3A%22Classic+CI%2FCD%22)
8+
[![Release Flow](https://github.com/nolte/terraform-provider-harbor/workflows/Release%20Flow/badge.svg)](https://github.com/nolte/terraform-provider-harbor/actions?query=workflow%3A%22Release+Flow%22)
9+
10+
911

1012
## Project Status
1113

@@ -47,6 +49,8 @@ For Easy development use [Visual Studio Code DevContainer](https://code.visualst
4749
make
4850
```
4951

52+
After starting the VisualStudio Code DevContainer, you can access the Documentation at [localhost:8000](http://localhost:8000).
53+
5054
### Precondition Tools
5155

5256
For full building and testing you need the following tools on our machine.
@@ -65,8 +69,4 @@ For full building and testing you need the following tools on our machine.
6569

6670
## Supported Versions
6771

68-
Tested with Harbor v2.1.0 and v1.10.2.
69-
70-
## Tests
71-
72-
For the End To End Tests we use a local [kind](https://kind.sigs.k8s.io) _(KubernetesInDocker)_ Cluster.
72+
Tested with Harbor v1.10.2, v2.0.0 and v2.1.0.

0 commit comments

Comments
 (0)