Skip to content

Commit

Permalink
fix golint error
Browse files Browse the repository at this point in the history
  • Loading branch information
sinbai committed Dec 12, 2022
1 parent 2eb47bc commit bb705aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 31 deletions.
12 changes: 4 additions & 8 deletions internal/services/lighthouse/lighthouse_definition_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,18 +444,14 @@ func expandLighthouseDefinitionJustInTimeAccessPolicy(input []interface{}) (*reg
}
result.MultiFactorAuthProvider = multiFactorAuthProvider

approvers, err := expandLighthouseDefinitionApprover(justInTimeAccessPolicy["approver"].(*pluginsdk.Set).List())
if err != nil {
return nil, err
}
result.ManagedByTenantApprovers = approvers
result.ManagedByTenantApprovers = expandLighthouseDefinitionApprover(justInTimeAccessPolicy["approver"].(*pluginsdk.Set).List())

return &result, nil
}

func expandLighthouseDefinitionApprover(input []interface{}) (*[]registrationdefinitions.EligibleApprover, error) {
func expandLighthouseDefinitionApprover(input []interface{}) *[]registrationdefinitions.EligibleApprover {
if len(input) == 0 || input[0] == nil {
return nil, nil
return nil
}

var results []registrationdefinitions.EligibleApprover
Expand All @@ -474,7 +470,7 @@ func expandLighthouseDefinitionApprover(input []interface{}) (*[]registrationdef
results = append(results, result)
}

return &results, nil
return &results
}

func flattenLighthouseDefinitionEligibleAuthorization(input *[]registrationdefinitions.EligibleAuthorization) []interface{} {
Expand Down
34 changes: 11 additions & 23 deletions internal/services/network/route_map_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,7 @@ func expandRules(input []Rule) (*[]network.RouteMapRule, error) {
Name: utils.String(v.Name),
}

actions, err := expandActions(v.Actions)
if err != nil {
return nil, err
}
rule.Actions = actions
rule.Actions = expandActions(v.Actions)

rule.MatchCriteria = expandCriteria(v.MatchCriteria)

Expand All @@ -391,7 +387,7 @@ func expandRules(input []Rule) (*[]network.RouteMapRule, error) {
return &rules, nil
}

func expandActions(input []Action) (*[]network.Action, error) {
func expandActions(input []Action) *[]network.Action {
var actions []network.Action

for _, v := range input {
Expand All @@ -404,7 +400,7 @@ func expandActions(input []Action) (*[]network.Action, error) {
actions = append(actions, action)
}

return &actions, nil
return &actions
}

func expandParameters(input []Parameter) *[]network.Parameter {
Expand Down Expand Up @@ -468,17 +464,9 @@ func flattenRules(input *[]network.RouteMapRule) ([]Rule, error) {
for _, v := range *input {
rule := Rule{}

actions, err := flattenActions(v.Actions)
if err != nil {
return nil, err
}
rule.Actions = actions
rule.Actions = flattenActions(v.Actions)

matchCriteria, err := flattenCriteria(v.MatchCriteria)
if err != nil {
return nil, err
}
rule.MatchCriteria = matchCriteria
rule.MatchCriteria = flattenCriteria(v.MatchCriteria)

if v.Name != nil {
rule.Name = *v.Name
Expand All @@ -494,10 +482,10 @@ func flattenRules(input *[]network.RouteMapRule) ([]Rule, error) {
return rules, nil
}

func flattenActions(input *[]network.Action) ([]Action, error) {
func flattenActions(input *[]network.Action) []Action {
var actions []Action
if input == nil {
return actions, nil
return actions
}

for _, v := range *input {
Expand All @@ -512,7 +500,7 @@ func flattenActions(input *[]network.Action) ([]Action, error) {
actions = append(actions, action)
}

return actions, nil
return actions
}

func flattenParameters(input *[]network.Parameter) []Parameter {
Expand Down Expand Up @@ -542,10 +530,10 @@ func flattenParameters(input *[]network.Parameter) []Parameter {
return parameters
}

func flattenCriteria(input *[]network.Criterion) ([]Criterion, error) {
func flattenCriteria(input *[]network.Criterion) []Criterion {
var criteria []Criterion
if input == nil {
return criteria, nil
return criteria
}

for _, v := range *input {
Expand All @@ -570,5 +558,5 @@ func flattenCriteria(input *[]network.Criterion) ([]Criterion, error) {
criteria = append(criteria, criterion)
}

return criteria, nil
return criteria
}

0 comments on commit bb705aa

Please sign in to comment.