From c72dda5239e6b1ec25a68ff37f686a86142e8e25 Mon Sep 17 00:00:00 2001 From: Tomer Brisker Date: Thu, 16 Jun 2022 06:59:05 +0300 Subject: [PATCH] Make PolicyDocument creators return pointer --- pkg/aws/policies.go | 2 +- pkg/aws/policy_document.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/aws/policies.go b/pkg/aws/policies.go index 2fa4ae368a..8fadfe4fa6 100644 --- a/pkg/aws/policies.go +++ b/pkg/aws/policies.go @@ -628,7 +628,7 @@ func (c *awsClient) listPolicies(role *iam.Role) ([]Policy, error) { } policy := Policy{ PolicyName: aws.StringValue(policyOutput.PolicyName), - PolicyDocument: policyDoc, + PolicyDocument: *policyDoc, } policies = append(policies, policy) } diff --git a/pkg/aws/policy_document.go b/pkg/aws/policy_document.go index 85ff8ab943..89f2a2df4c 100644 --- a/pkg/aws/policy_document.go +++ b/pkg/aws/policy_document.go @@ -61,10 +61,10 @@ func NewPolicyDocument() *PolicyDocument { return &PolicyDocument{Version: "2012-10-17"} } -func ParsePolicyDocument(doc string) (PolicyDocument, error) { +func ParsePolicyDocument(doc string) (*PolicyDocument, error) { policy := PolicyDocument{} err := json.Unmarshal([]byte(doc), &policy) - return policy, err + return &policy, err } func (p *PolicyStatement) GetAWSPrincipals() []string { @@ -250,16 +250,16 @@ func InterpolatePolicyDocument(doc string, replacements map[string]string) strin return doc } -func getPolicyDocument(policyDocument *string) (PolicyDocument, error) { +func getPolicyDocument(policyDocument *string) (*PolicyDocument, error) { data := PolicyDocument{} if policyDocument != nil { val, err := url.QueryUnescape(aws.StringValue(policyDocument)) if err != nil { - return data, err + return &data, err } return ParsePolicyDocument(val) } - return data, nil + return &data, nil } func GenerateRolePolicyDoc(cluster *cmv1.Cluster, accountID string, operator *cmv1.STSOperator,