MCPcopy Index your code
hub / github.com/getsops/sops / configFromRule

Function configFromRule

config/config.go:467–508  ·  view source on GitHub ↗
(rule *creationRule, kmsEncryptionContext map[string]*string)

Source from the content-addressed store, hash-verified

465}
466
467func 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
510func parseDestinationRuleForFile(conf *configFile, filePath string, kmsEncryptionContext map[string]*string) (*Config, error) {
511 var rule *creationRule

Callers 2

parseCreationRuleForFileFunction · 0.85

Calls 1

Tested by

no test coverage detected