Skip to content

Commit

Permalink
Merge pull request #93 from nabbar/aws_policies_version
Browse files Browse the repository at this point in the history
Fix error in CompareUpdate : policy version document is url encoded...
  • Loading branch information
Nicolas JUHEL authored Mar 9, 2021
2 parents 13117f2 + db1b203 commit 0b4225b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion aws/policy/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ package policy

import (
"fmt"
"net/url"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/iam"
Expand Down Expand Up @@ -147,9 +148,11 @@ func (cli *client) VersionDel(arn string, vers string) liberr.Error {

func (cli *client) CompareUpdate(arn string, doc string) (upd bool, err liberr.Error) {
var (
e error
pol *types.Policy
pvs *types.PolicyVersion
vrs string
dec string
)

if pol, err = cli.Get(arn); err != nil {
Expand All @@ -166,7 +169,13 @@ func (cli *client) CompareUpdate(arn string, doc string) (upd bool, err liberr.E
return false, libhlp.ErrorResponse.Error(nil)
} else if *pvs.Document == doc {
return false, nil
} else if err = cli.Update(*pol.PolicyId, doc); err != nil {
} else if dec, e = url.QueryUnescape(*pvs.Document); e != nil {
dec = *pvs.Document
}

if dec == doc {
return false, nil
} else if err = cli.Update(*pol.Arn, doc); err != nil {
return true, err
} else {
return true, nil
Expand Down

0 comments on commit 0b4225b

Please sign in to comment.