Skip to content

Commit 820c322

Browse files
committed
simplify.
1 parent f36c0a4 commit 820c322

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

service/policy/db/attribute_values.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,10 @@ func (c PolicyDBClient) GetAttributeValue(ctx context.Context, identifier any) (
101101
}
102102
}
103103

104-
obligations := make([]*policy.Obligation, 0)
105-
if av.Obligations != nil {
106-
obligations, err = unmarshalObligations(av.Obligations)
107-
if err != nil {
108-
c.logger.ErrorContext(ctx, "could not unmarshal obligations", slog.String("error", err.Error()))
109-
return nil, err
110-
}
104+
obligations, err := unmarshalObligations(av.Obligations)
105+
if err != nil {
106+
c.logger.ErrorContext(ctx, "could not unmarshal obligations", slog.String("error", err.Error()))
107+
return nil, err
111108
}
112109

113110
return &policy.Value{

service/policy/db/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func unmarshalObligationTrigger(triggerJSON []byte) (*policy.ObligationTrigger,
162162

163163
func unmarshalObligations(obligationsJSON []byte) ([]*policy.Obligation, error) {
164164
if obligationsJSON == nil {
165-
return nil, nil
165+
return make([]*policy.Obligation, 0), nil
166166
}
167167

168168
raw := []json.RawMessage{}

0 commit comments

Comments
 (0)