SetMetadata store arbitrary metadata along the last not-commit version. If the version has been commit to git already, a new identical version is added and will need to be commit.
(key string, value string)
| 529 | // If the version has been commit to git already, a new identical version is added and will need to be |
| 530 | // commit. |
| 531 | func (i *Identity) SetMetadata(key string, value string) { |
| 532 | // once commit, data is immutable so we create a new version |
| 533 | if i.lastVersion().commitHash != "" { |
| 534 | i.versions = append(i.versions, i.lastVersion().Clone()) |
| 535 | } |
| 536 | // if Id() has been called, we can't change the first version anymore, so we create a new version |
| 537 | if len(i.versions) == 1 && i.versions[0].id != entity.UnsetId && i.versions[0].id != "" { |
| 538 | i.versions = append(i.versions, i.lastVersion().Clone()) |
| 539 | } |
| 540 | |
| 541 | i.lastVersion().SetMetadata(key, value) |
| 542 | } |
| 543 | |
| 544 | // ImmutableMetadata return all metadata for this Identity, accumulated from each version. |
| 545 | // If multiple value are found, the first defined takes precedence. |