Skip to content

Commit

Permalink
Migrate to SDK V2 (#62)
Browse files Browse the repository at this point in the history
* fix: bumped terraform-json to 0.12, kind to 0.11.1, Go to 1.16, protobuf to 1.5.2, added argocd 2.1 and 2.0 to test suite
* update to argocd 2.1.2, kube-api 0.21

Co-authored-by: Claire Bellivier <claire@bellivier.com>
Co-authored-by: Olivier Boukili <boukili.olivier@gmail.com>
  • Loading branch information
3 people committed Sep 8, 2021
1 parent bbff05e commit 3c90ff9
Show file tree
Hide file tree
Showing 39 changed files with 1,443 additions and 700 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16

- name: Import GPG key
id: import_gpg
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
strategy:
fail-fast: false
matrix:
argocd_version: ["v.1.8.3", "v1.7.11"]
argocd_version: ["v2.1.2", "v2.0.5", "v.1.8.7"]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.15
go-version: 1.16
id: go
- name: Restore Go cache
uses: actions/cache@v1
Expand All @@ -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.9.0
- name: Install Kind 0.11.1
run: |
curl -sLo ./kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-$(uname)-amd64
curl -sLo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-$(uname)-amd64
chmod +x ./kind
- name: Set up ArgoCD ${{ matrix.argocd_version }}
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.idea
terraform-provider-argocd
./manifests/install/install.yml
.idea
.vscode
# Env variables settings
/scripts/testacc
/scripts/testacc_prepare_env
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ For example if you use Docker as your local container runtime:
```shell
docker pull argoproj/argocd:v1.8.3
docker pull ghcr.io/dexidp/dex:v2.27.0
docker pull redis:5.0.10-alpine
docker pull banzaicloud/vault-operator:1.3.3
docker pull redis:6.2.4-alpine
docker pull bitnami/redis:6.2.5
```

#### Troubleshooting during local development
Expand All @@ -380,4 +380,4 @@ docker pull banzaicloud/vault-operator:1.3.3
* Thanks to [JetBrains](https://www.jetbrains.com/?from=terraform-provider-argocd) for providing a GoLand open source license to support the development of this provider.
* Thanks to [Keplr](https://www.welcometothejungle.com/fr/companies/keplr) for allowing me to contribute to this side-project of mine during paid work hours.

![](sponsors/jetbrains.svg?display=inline-block) ![](sponsors/keplr.png?display=inline-block)
![](sponsors/jetbrains.svg?display=inline-block) ![](sponsors/keplr.png?display=inline-block)
14 changes: 7 additions & 7 deletions argocd/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package argocd
import (
"fmt"
"github.com/Masterminds/semver"
"github.com/argoproj/argo-cd/pkg/apiclient"
"github.com/argoproj/argo-cd/pkg/apiclient/application"
"github.com/argoproj/argo-cd/pkg/apiclient/cluster"
"github.com/argoproj/argo-cd/pkg/apiclient/project"
"github.com/argoproj/argo-cd/pkg/apiclient/repocreds"
"github.com/argoproj/argo-cd/pkg/apiclient/repository"
"github.com/argoproj/argo-cd/pkg/apiclient/version"
"github.com/argoproj/argo-cd/v2/pkg/apiclient"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/application"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/cluster"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/project"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/repocreds"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/repository"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/version"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion argocd/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package argocd
import (
"fmt"
"github.com/Masterminds/semver"
"github.com/argoproj/argo-cd/pkg/apiclient/version"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/version"
"github.com/stretchr/testify/assert"
"math/rand"
"modernc.org/mathutil"
Expand Down
24 changes: 12 additions & 12 deletions argocd/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package argocd
import (
"context"
"fmt"
"sync"

"github.com/Masterminds/semver"
"github.com/argoproj/argo-cd/pkg/apiclient"
"github.com/argoproj/argo-cd/pkg/apiclient/application"
"github.com/argoproj/argo-cd/pkg/apiclient/cluster"
"github.com/argoproj/argo-cd/pkg/apiclient/project"
"github.com/argoproj/argo-cd/pkg/apiclient/repocreds"
"github.com/argoproj/argo-cd/pkg/apiclient/repository"
"github.com/argoproj/argo-cd/pkg/apiclient/session"
"github.com/argoproj/argo-cd/util/io"
"github.com/argoproj/argo-cd/v2/pkg/apiclient"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/application"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/cluster"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/project"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/repocreds"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/repository"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/session"
"github.com/argoproj/argo-cd/v2/util/io"
"github.com/golang/protobuf/ptypes/empty"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"sync"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

var apiClientConnOpts apiclient.ClientOptions
Expand All @@ -26,7 +26,7 @@ var tokenMutexConfiguration = &sync.RWMutex{}
// Used to handle concurrent access to each ArgoCD project
var tokenMutexProjectMap = make(map[string]*sync.RWMutex, 0)

func Provider() terraform.ResourceProvider {
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"server_addr": {
Expand Down
16 changes: 8 additions & 8 deletions argocd/provider_test.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package argocd

import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

var testAccProviders map[string]terraform.ResourceProvider
var testAccProvider *schema.Provider
var testAccProviders map[string]func() (*schema.Provider, error)

func init() {
testAccProvider = Provider().(*schema.Provider)
testAccProviders = map[string]terraform.ResourceProvider{
"argocd": testAccProvider,
testAccProviders = map[string]func() (*schema.Provider, error){
"argocd": func() (*schema.Provider, error) {
return Provider(), nil
},
}
}

func TestProvider(t *testing.T) {
if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
if err := Provider().InternalValidate(); err != nil {
t.Fatalf("err: %s", err)
}
}
Expand Down

0 comments on commit 3c90ff9

Please sign in to comment.