Skip to content

Commit

Permalink
Fix argocd_application state upgrade for v5.0.0 (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
onematchfox authored Mar 27, 2023
1 parent 37864fe commit 453fe73
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions argocd/schema_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ func resourceArgoCDApplicationStateUpgradeV3(_ context.Context, rawState map[str

syncPolicy := _syncPolicy[0].(map[string]interface{})

if automated, ok := syncPolicy["automated"].(map[string]bool); ok {
if automated, ok := syncPolicy["automated"].(map[string]interface{}); ok {
updated := make(map[string]interface{}, 0)
for k, v := range automated {
updated[k] = v
Expand All @@ -1820,7 +1820,7 @@ func resourceArgoCDApplicationStateUpgradeV3(_ context.Context, rawState map[str

retry := _retry[0].(map[string]interface{})

if backoff, ok := retry["backoff"].(map[string]string); ok {
if backoff, ok := retry["backoff"].(map[string]interface{}); ok {
updated := make(map[string]interface{}, 0)
for k, v := range backoff {
updated[k] = v
Expand Down
12 changes: 6 additions & 6 deletions argocd/schema_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func TestUpgradeSchemaApplication_V3V4(t *testing.T) {
"namespace": "default",
}},
"sync_policy": []interface{}{map[string]interface{}{
"automated": map[string]bool{
"automated": map[string]interface{}{
"prune": true,
"self_heal": true,
"allow_empty": true,
Expand All @@ -256,7 +256,7 @@ func TestUpgradeSchemaApplication_V3V4(t *testing.T) {
},
"retry": []interface{}{map[string]interface{}{
"limit": "5",
"backoff": map[string]string{
"backoff": map[string]interface{}{
"duration": "30s",
"max_duration": "2m",
"factor": "2",
Expand Down Expand Up @@ -336,7 +336,7 @@ func TestUpgradeSchemaApplication_V3V4(t *testing.T) {
},
"retry": []interface{}{map[string]interface{}{
"limit": "5",
"backoff": map[string]string{
"backoff": map[string]interface{}{
"duration": "30s",
"max_duration": "2m",
"factor": "2",
Expand Down Expand Up @@ -404,13 +404,13 @@ func TestUpgradeSchemaApplication_V3V4(t *testing.T) {
"namespace": "default",
}},
"sync_policy": []interface{}{map[string]interface{}{
"automated": map[string]bool{},
"automated": map[string]interface{}{},
"sync_options": []string{
"Validate=false",
},
"retry": []interface{}{map[string]interface{}{
"limit": "5",
"backoff": map[string]string{
"backoff": map[string]interface{}{
"duration": "30s",
"max_duration": "2m",
"factor": "2",
Expand Down Expand Up @@ -479,7 +479,7 @@ func TestUpgradeSchemaApplication_V3V4(t *testing.T) {
"namespace": "default",
}},
"sync_policy": []interface{}{map[string]interface{}{
"automated": map[string]bool{
"automated": map[string]interface{}{
"prune": true,
"self_heal": true,
"allow_empty": true,
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"flag"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"github.com/oboukili/terraform-provider-argocd/argocd"
Expand All @@ -17,7 +19,13 @@ import (
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs

func main() {
var debugMode bool
flag.BoolVar(&debugMode, "debug", false, "set to true to run the provider with support for debuggers like delve")
flag.Parse()

plugin.Serve(&plugin.ServeOpts{
Debug: debugMode,
ProviderAddr: "registry.terraform.io/oboukili/argocd",
ProviderFunc: func() *schema.Provider {
return argocd.Provider()
},
Expand Down

0 comments on commit 453fe73

Please sign in to comment.