applyAddOperationToDatabase applies an add operation to the database.
(adapter persist.Adapter, op persist.PolicyOperation)
| 158 | |
| 159 | // applyAddOperationToDatabase applies an add operation to the database. |
| 160 | func (tx *Transaction) applyAddOperationToDatabase(adapter persist.Adapter, op persist.PolicyOperation) error { |
| 161 | if batchAdapter, ok := adapter.(persist.BatchAdapter); ok { |
| 162 | // Use batch operation if available. |
| 163 | return batchAdapter.AddPolicies(op.Section, op.PolicyType, op.Rules) |
| 164 | } else { |
| 165 | // Fall back to individual operations. |
| 166 | for _, rule := range op.Rules { |
| 167 | if err := adapter.AddPolicy(op.Section, op.PolicyType, rule); err != nil { |
| 168 | return err |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | return nil |
| 173 | } |
| 174 | |
| 175 | // applyRemoveOperationToDatabase applies a remove operation to the database. |
| 176 | func (tx *Transaction) applyRemoveOperationToDatabase(adapter persist.Adapter, op persist.PolicyOperation) error { |
no test coverage detected