Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portable, cross-platform tests settings #42

Merged
merged 3 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
curl -sL "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
chmod +x ./kustomize

- name: Install Kind 0.8.1
- name: Install Kind 0.9.0
run: |
curl -sLo ./kind https://kind.sigs.k8s.io/dl/v0.8.1/kind-$(uname)-amd64
curl -sLo ./kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-$(uname)-amd64
chmod +x ./kind

- name: Set up ArgoCD ${{ matrix.argocd_version }}
Expand All @@ -45,7 +45,6 @@ jobs:
run: |
curl https://raw.githubusercontent.com/argoproj/argo-cd/${ARGOCD_VERSION}/manifests/install.yaml > manifests/install/install.yml
sh scripts/testacc_prepare_env.sh
kubectl port-forward -n argocd service/argocd-server --address 127.0.0.1 8080:443&
until $(nc -z 127.0.0.1 8080); do sleep 2;done
netstat -tulpn

Expand Down
21 changes: 21 additions & 0 deletions .run/Template Go Test.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<component name="ProjectRunConfigurationManager">
<configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
<module name="terraform-provider-argocd" />
<working_directory value="$PROJECT_DIR$" />
<go_parameters value="-i" />
<envs>
<env name="ARGOCD_INSECURE" value="true" />
<env name="ARGOCD_SERVER" value="127.0.0.1:8080" />
<env name="ARGOCD_AUTH_USERNAME" value="admin" />
<env name="ARGOCD_AUTH_PASSWORD" value="acceptancetesting" />
<env name="ARGOCD_CONTEXT" value="kind-argocd" />
<env name="TF_ACC" value="1" />
</envs>
<framework value="gotest" />
<kind value="DIRECTORY" />
<package value="github.com/oboukili/terraform-provider-argocd" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
</component>
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,26 @@ In these cases, not only the readability of your Terraform plan will worsen, but

## Installation

* **From binary releases**:
* **From Terraform Public Registry (TF >= 0.13.0)**

https://registry.terraform.io/providers/oboukili/argocd/latest
```hcl
terraform {
required_providers {
argocd = {
source = "oboukili/argocd"
version = "0.4.7"
}
}
}

provider "argocd" {
# Configuration options
}
```


* **From binary releases (TF >= 0.12.0, < 0.13)**:
Get the [latest release](https://github.com/oboukili/terraform-provider-argocd/releases/latest), or adapt and run the following:
```shell script
curl -LO https://github.com/oboukili/terraform-provider-argocd/releases/download/v0.1.0/terraform-provider-argocd_v0.1.0_linux_amd64.gz
Expand Down Expand Up @@ -181,7 +200,7 @@ resource "argocd_application" "kustomize" {
source {
repo_url = "https://github.com/kubernetes-sigs/kustomize"
path = "examples/helloWorld"
target_revision = "master"
target_revision = "release-kustomize-v3.7"
kustomize {
name_prefix = "foo-"
name_suffix = "-bar"
Expand Down
4 changes: 2 additions & 2 deletions argocd/resource_argocd_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ingress:
resource.TestCheckResourceAttr(
"argocd_application.kustomize",
"spec.0.source.0.target_revision",
"master",
"release-kustomize-v3.7",
),
resource.TestCheckResourceAttr(
"argocd_application.kustomize",
Expand Down Expand Up @@ -256,7 +256,7 @@ resource "argocd_application" "kustomize" {
source {
repo_url = "https://github.com/kubernetes-sigs/kustomize"
path = "examples/helloWorld"
target_revision = "master"
target_revision = "release-kustomize-v3.7"
kustomize {
name_prefix = "foo-"
name_suffix = "-bar"
Expand Down
5 changes: 3 additions & 2 deletions argocd/resource_argocd_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ resource "argocd_application" "public" {
}
spec {
source {
repo_url = argocd_repository.simple.repo
path = "examples/helloWorld"
repo_url = argocd_repository.simple.repo
path = "examples/helloWorld"
target_revision = "release-kustomize-v3.7"
}
destination {
server = "https://kubernetes.default.svc"
Expand Down
3 changes: 2 additions & 1 deletion manifests/install/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resources:
- namespace.yml
- install.yml
- git-private-repository.yml
- proxy-service.yml
patchesStrategicMerge:
- patches/deployment.yml
- patches/secret.yml
- patches/secret.yml
21 changes: 21 additions & 0 deletions manifests/install/proxy-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# Access to argocd service port without the need to proxy through kubectl proxy
apiVersion: v1
kind: Service
metadata:
name: argocd-server-proxy
spec:
type: NodePort
ports:
- name: http
port: 80
protocol: TCP
nodePort: 30124
targetPort: 8080
- name: https
port: 443
protocol: TCP
nodePort: 30123
targetPort: 8080
selector:
app.kubernetes.io/name: argocd-server
11 changes: 11 additions & 0 deletions scripts/kind-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
nodes:
- role: control-plane
# Access ArgoCD API server on a MacOS / Windows workstation easily
extraPortMappings:
- containerPort: 30123
hostPort: 8080
listenAddress: "0.0.0.0"
protocol: TCP
13 changes: 11 additions & 2 deletions scripts/testacc_prepare_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ echo '--- Kustomize sanity checks'
kustomize version || exit 1

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

echo '--- Kind sanity checks\n\n'
kubectl get nodes -o wide
kubectl get pods --all-namespaces -o wide
kubectl get services --all-namespaces -o wide

echo '--- Load already available container images from local registry into Kind'
kind load docker-image redis:5.0.3 --name argocd
kind load docker-image quay.io/dexidp/dex:v2.22.0 --name argocd
kind load docker-image argoproj/argocd:${ARGOCD_VERSION:-v1.6.1} --name argocd

echo '--- Install ArgoCD ${ARGOCD_VERSION:-v1.6.1}\n\n'
kustomize build manifests/install | kubectl apply -f - &&
kubectl apply -f manifests/testdata/ &&

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