Skip to content

Commit

Permalink
Make PolicyDocument creators return pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrisker committed Jun 16, 2022
1 parent 8ca362e commit c72dda5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/aws/policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/aws/policy_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c72dda5

Please sign in to comment.