(rule *creationRule, kmsEncryptionContext map[string]*string)
| 465 | } |
| 466 | |
| 467 | func configFromRule(rule *creationRule, kmsEncryptionContext map[string]*string) (*Config, error) { |
| 468 | cryptRuleCount := 0 |
| 469 | if rule.UnencryptedSuffix != "" { |
| 470 | cryptRuleCount++ |
| 471 | } |
| 472 | if rule.EncryptedSuffix != "" { |
| 473 | cryptRuleCount++ |
| 474 | } |
| 475 | if rule.UnencryptedRegex != "" { |
| 476 | cryptRuleCount++ |
| 477 | } |
| 478 | if rule.EncryptedRegex != "" { |
| 479 | cryptRuleCount++ |
| 480 | } |
| 481 | if rule.UnencryptedCommentRegex != "" { |
| 482 | cryptRuleCount++ |
| 483 | } |
| 484 | if rule.EncryptedCommentRegex != "" { |
| 485 | cryptRuleCount++ |
| 486 | } |
| 487 | |
| 488 | if cryptRuleCount > 1 { |
| 489 | return nil, fmt.Errorf("error loading config: cannot use more than one of encrypted_suffix, unencrypted_suffix, encrypted_regex, unencrypted_regex, encrypted_comment_regex, or unencrypted_comment_regex for the same rule") |
| 490 | } |
| 491 | |
| 492 | groups, err := getKeyGroupsFromCreationRule(rule, kmsEncryptionContext) |
| 493 | if err != nil { |
| 494 | return nil, err |
| 495 | } |
| 496 | |
| 497 | return &Config{ |
| 498 | KeyGroups: groups, |
| 499 | ShamirThreshold: rule.ShamirThreshold, |
| 500 | UnencryptedSuffix: rule.UnencryptedSuffix, |
| 501 | EncryptedSuffix: rule.EncryptedSuffix, |
| 502 | UnencryptedRegex: rule.UnencryptedRegex, |
| 503 | EncryptedRegex: rule.EncryptedRegex, |
| 504 | UnencryptedCommentRegex: rule.UnencryptedCommentRegex, |
| 505 | EncryptedCommentRegex: rule.EncryptedCommentRegex, |
| 506 | MACOnlyEncrypted: rule.MACOnlyEncrypted, |
| 507 | }, nil |
| 508 | } |
| 509 | |
| 510 | func parseDestinationRuleForFile(conf *configFile, filePath string, kmsEncryptionContext map[string]*string) (*Config, error) { |
| 511 | var rule *creationRule |
no test coverage detected