Skip to content

Commit

Permalink
Merge pull request #40 from oboukili/39-fix-projects-deletion-panics
Browse files Browse the repository at this point in the history
argocd_project: fix project deletion gopanic (#40)
  • Loading branch information
oboukili committed Jan 17, 2021
2 parents f703e45 + 3f95366 commit 173474c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions argocd/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/argoproj/argo-cd/pkg/apiclient/version"
"github.com/stretchr/testify/assert"
"math/rand"
"modernc.org/mathutil"
"testing"
)

Expand Down Expand Up @@ -36,9 +37,9 @@ func serverInterfaceTestData(t *testing.T, argocdVersion string, semverOperator
case semverLess:
v, err = semver.NewVersion(
fmt.Sprintf("%d.%d.%d",
v.Major()-incMajor%v.Major(),
v.Minor()-incMinor%v.Minor(),
v.Patch()-incPatch%v.Patch(),
mathutil.MinInt64(v.Major(), v.Major()-incMajor%v.Major()),
mathutil.MinInt64(v.Minor(), v.Minor()-incMinor%v.Minor()),
mathutil.MinInt64(v.Patch(), v.Patch()-incPatch%v.Patch()),
))
assert.NoError(t, err)
default:
Expand Down
3 changes: 3 additions & 0 deletions argocd/resource_argocd_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func resourceArgoCDProjectDelete(d *schema.ResourceData, meta interface{}) error
server := meta.(ServerInterface)
c := *server.ProjectClient
projectName := d.Id()
if _, ok := tokenMutexProjectMap[projectName]; !ok {
tokenMutexProjectMap[projectName] = &sync.RWMutex{}
}

tokenMutexProjectMap[projectName].Lock()
_, err := c.Delete(context.Background(), &projectClient.ProjectQuery{Name: projectName})
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/stretchr/testify v1.5.1
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586
k8s.io/apimachinery v0.16.6
modernc.org/mathutil v1.0.0
)

replace (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7q
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI=
github.com/quobyte/api v0.1.2/go.mod h1:jL7lIHrmqQ7yh05OJ+eEEdHr0u/kmT1Ff9iHd+4H6VI=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446 h1:/NRJ5vAYoqz+7sG51ubIDHXeWO8DlTSrToPu6q11ziA=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
github.com/robfig/cron v1.1.0 h1:jk4/Hud3TTdcrJgUOBgsqrZBarcxl6ADIjSC2iniwLY=
github.com/robfig/cron v1.1.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
Expand Down Expand Up @@ -967,6 +968,7 @@ k8s.io/utils v0.0.0-20191114200735-6ca3b61696b6/go.mod h1:sZAwmy6armz5eXlNoLmJcl
layeh.com/gopher-json v0.0.0-20190114024228-97fed8db8427/go.mod h1:ivKkcY8Zxw5ba0jldhZCYYQfGdb2K6u9tbYK1AwMIBc=
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.0.0 h1:93vKjrJopTPrtTNpZ8XIovER7iCIH1QU7wNbOQXC60I=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I=
Expand Down

0 comments on commit 173474c

Please sign in to comment.