Set records the value and policy for (namespace, operation, inputs).
(namespace, operation string, inputs []any, value any, policy string)
| 128 | |
| 129 | // Set records the value and policy for (namespace, operation, inputs). |
| 130 | func (l *Lockfile) Set(namespace, operation string, inputs []any, value any, policy string) error { |
| 131 | if l == nil { |
| 132 | return fmt.Errorf("nil lockfile") |
| 133 | } |
| 134 | if l.entries == nil { |
| 135 | l.entries = map[tupleKey]lockEntry{} |
| 136 | } |
| 137 | |
| 138 | canonicalInputs, inputsJSON, err := canonicalizeInputs(inputs) |
| 139 | if err != nil { |
| 140 | return fmt.Errorf("canonicalizing lock inputs: %w", err) |
| 141 | } |
| 142 | canonicalValue, err := canonicalizeValue(value) |
| 143 | if err != nil { |
| 144 | return fmt.Errorf("canonicalizing lock value: %w", err) |
| 145 | } |
| 146 | |
| 147 | l.entries[entryKey(namespace, operation, inputsJSON)] = lockEntry{ |
| 148 | namespace: namespace, |
| 149 | operation: operation, |
| 150 | inputs: canonicalInputs, |
| 151 | inputsJSON: inputsJSON, |
| 152 | value: canonicalValue, |
| 153 | policy: policy, |
| 154 | } |
| 155 | return nil |
| 156 | } |
| 157 | |
| 158 | // Delete removes the result for (namespace, operation, inputs). |
| 159 | func (l *Lockfile) Delete(namespace, operation string, inputs []any) bool { |
nothing calls this directly
no test coverage detected