Skip to content

Commit 2d88e14

Browse files
authored
Portable, cross-platform tests settings (#42)
* persist Goland gotest templates, made Kind test settings cross-platform through extraPortMappings, removed CI testing dependencies with kubectl proxy * fix kustomize acceptance tests, updated README.md
1 parent dfcad7f commit 2d88e14

File tree

9 files changed

+94
-12
lines changed

9 files changed

+94
-12
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ jobs:
3434
curl -sL "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
3535
chmod +x ./kustomize
3636
37-
- name: Install Kind 0.8.1
37+
- name: Install Kind 0.9.0
3838
run: |
39-
curl -sLo ./kind https://kind.sigs.k8s.io/dl/v0.8.1/kind-$(uname)-amd64
39+
curl -sLo ./kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-$(uname)-amd64
4040
chmod +x ./kind
4141
4242
- name: Set up ArgoCD ${{ matrix.argocd_version }}
@@ -45,7 +45,6 @@ jobs:
4545
run: |
4646
curl https://raw.githubusercontent.com/argoproj/argo-cd/${ARGOCD_VERSION}/manifests/install.yaml > manifests/install/install.yml
4747
sh scripts/testacc_prepare_env.sh
48-
kubectl port-forward -n argocd service/argocd-server --address 127.0.0.1 8080:443&
4948
until $(nc -z 127.0.0.1 8080); do sleep 2;done
5049
netstat -tulpn
5150

.run/Template Go Test.run.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
3+
<module name="terraform-provider-argocd" />
4+
<working_directory value="$PROJECT_DIR$" />
5+
<go_parameters value="-i" />
6+
<envs>
7+
<env name="ARGOCD_INSECURE" value="true" />
8+
<env name="ARGOCD_SERVER" value="127.0.0.1:8080" />
9+
<env name="ARGOCD_AUTH_USERNAME" value="admin" />
10+
<env name="ARGOCD_AUTH_PASSWORD" value="acceptancetesting" />
11+
<env name="ARGOCD_CONTEXT" value="kind-argocd" />
12+
<env name="TF_ACC" value="1" />
13+
</envs>
14+
<framework value="gotest" />
15+
<kind value="DIRECTORY" />
16+
<package value="github.com/oboukili/terraform-provider-argocd" />
17+
<directory value="$PROJECT_DIR$" />
18+
<filePath value="$PROJECT_DIR$" />
19+
<method v="2" />
20+
</configuration>
21+
</component>

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,26 @@ In these cases, not only the readability of your Terraform plan will worsen, but
4343

4444
## Installation
4545

46-
* **From binary releases**:
46+
* **From Terraform Public Registry (TF >= 0.13.0)**
47+
48+
https://registry.terraform.io/providers/oboukili/argocd/latest
49+
```hcl
50+
terraform {
51+
required_providers {
52+
argocd = {
53+
source = "oboukili/argocd"
54+
version = "0.4.7"
55+
}
56+
}
57+
}
58+
59+
provider "argocd" {
60+
# Configuration options
61+
}
62+
```
63+
64+
65+
* **From binary releases (TF >= 0.12.0, < 0.13)**:
4766
Get the [latest release](https://github.com/oboukili/terraform-provider-argocd/releases/latest), or adapt and run the following:
4867
```shell script
4968
curl -LO https://github.com/oboukili/terraform-provider-argocd/releases/download/v0.1.0/terraform-provider-argocd_v0.1.0_linux_amd64.gz
@@ -181,7 +200,7 @@ resource "argocd_application" "kustomize" {
181200
source {
182201
repo_url = "https://github.com/kubernetes-sigs/kustomize"
183202
path = "examples/helloWorld"
184-
target_revision = "master"
203+
target_revision = "release-kustomize-v3.7"
185204
kustomize {
186205
name_prefix = "foo-"
187206
name_suffix = "-bar"

argocd/resource_argocd_application_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ ingress:
8383
resource.TestCheckResourceAttr(
8484
"argocd_application.kustomize",
8585
"spec.0.source.0.target_revision",
86-
"master",
86+
"release-kustomize-v3.7",
8787
),
8888
resource.TestCheckResourceAttr(
8989
"argocd_application.kustomize",
@@ -256,7 +256,7 @@ resource "argocd_application" "kustomize" {
256256
source {
257257
repo_url = "https://github.com/kubernetes-sigs/kustomize"
258258
path = "examples/helloWorld"
259-
target_revision = "master"
259+
target_revision = "release-kustomize-v3.7"
260260
kustomize {
261261
name_prefix = "foo-"
262262
name_suffix = "-bar"

argocd/resource_argocd_repository_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ resource "argocd_application" "public" {
9191
}
9292
spec {
9393
source {
94-
repo_url = argocd_repository.simple.repo
95-
path = "examples/helloWorld"
94+
repo_url = argocd_repository.simple.repo
95+
path = "examples/helloWorld"
96+
target_revision = "release-kustomize-v3.7"
9697
}
9798
destination {
9899
server = "https://kubernetes.default.svc"

manifests/install/kustomization.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ resources:
66
- namespace.yml
77
- install.yml
88
- git-private-repository.yml
9+
- proxy-service.yml
910
patchesStrategicMerge:
1011
- patches/deployment.yml
11-
- patches/secret.yml
12+
- patches/secret.yml
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# Access to argocd service port without the need to proxy through kubectl proxy
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: argocd-server-proxy
7+
spec:
8+
type: NodePort
9+
ports:
10+
- name: http
11+
port: 80
12+
protocol: TCP
13+
nodePort: 30124
14+
targetPort: 8080
15+
- name: https
16+
port: 443
17+
protocol: TCP
18+
nodePort: 30123
19+
targetPort: 8080
20+
selector:
21+
app.kubernetes.io/name: argocd-server

scripts/kind-config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: kind.x-k8s.io/v1alpha4
3+
kind: Cluster
4+
nodes:
5+
- role: control-plane
6+
# Access ArgoCD API server on a MacOS / Windows workstation easily
7+
extraPortMappings:
8+
- containerPort: 30123
9+
hostPort: 8080
10+
listenAddress: "0.0.0.0"
11+
protocol: TCP

scripts/testacc_prepare_env.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,25 @@ echo '--- Kustomize sanity checks'
77
kustomize version || exit 1
88

99
echo '--- Create Kind cluster\n\n'
10-
kind create cluster --name argocd
10+
kind create cluster --name argocd --config scripts/kind-config.yml --image kindest/node:${ARGOCD_KUBERNETES_VERSION:-v1.18.8}
1111

1212
echo '--- Kind sanity checks\n\n'
1313
kubectl get nodes -o wide
1414
kubectl get pods --all-namespaces -o wide
1515
kubectl get services --all-namespaces -o wide
1616

17+
echo '--- Load already available container images from local registry into Kind'
18+
kind load docker-image redis:5.0.3 --name argocd
19+
kind load docker-image quay.io/dexidp/dex:v2.22.0 --name argocd
20+
kind load docker-image argoproj/argocd:${ARGOCD_VERSION:-v1.6.1} --name argocd
21+
1722
echo '--- Install ArgoCD ${ARGOCD_VERSION:-v1.6.1}\n\n'
1823
kustomize build manifests/install | kubectl apply -f - &&
1924
kubectl apply -f manifests/testdata/ &&
2025

21-
echo '--- Wait for ArgoCD server to be ready...'
26+
echo '--- Wait for ArgoCD components to be ready...'
2227
kubectl wait --for=condition=available --timeout=600s deployment/argocd-server -n argocd
28+
kubectl wait --for=condition=available --timeout=30s deployment/argocd-repo-server -n argocd
29+
kubectl wait --for=condition=available --timeout=30s deployment/argocd-application-controller -n argocd
30+
kubectl wait --for=condition=available --timeout=30s deployment/argocd-dex-server -n argocd
31+
kubectl wait --for=condition=available --timeout=30s deployment/argocd-redis -n argocd

0 commit comments

Comments
 (0)