MCPcopy Create free account
hub / github.com/getsops/sops / loadConfig

Function loadConfig

cmd/sops/main.go:2521–2537  ·  view source on GitHub ↗

loadConfig will look for an existing config file, either provided through the command line, or using findConfigFile Since a config file is not required, this function does not error when one is not found, and instead returns a nil config pointer

(c *cli.Context, file string, kmsEncryptionContext map[string]*string)

Source from the content-addressed store, hash-verified

2519// loadConfig will look for an existing config file, either provided through the command line, or using findConfigFile
2520// Since a config file is not required, this function does not error when one is not found, and instead returns a nil config pointer
2521func loadConfig(c *cli.Context, file string, kmsEncryptionContext map[string]*string) (*config.Config, error) {
2522 var err error
2523 configPath := c.GlobalString("config")
2524 if configPath == "" {
2525 // Ignore config not found errors returned from findConfigFile since the config file is not mandatory
2526 configPath, err = findConfigFile()
2527 if err != nil {
2528 // If we can't find a config file, but we were not explicitly requested to, assume it does not exist
2529 return nil, nil
2530 }
2531 }
2532 conf, err := config.LoadCreationRuleForFile(configPath, file, kmsEncryptionContext)
2533 if err != nil {
2534 return nil, err
2535 }
2536 return conf, nil
2537}
2538
2539func shamirThreshold(c *cli.Context, file string, optionalConfig *config.Config) (int, error) {
2540 if c.Int("shamir-secret-sharing-threshold") != 0 {

Callers 4

mainFunction · 0.85
getEncryptConfigFunction · 0.85
keyGroupsFunction · 0.85
shamirThresholdFunction · 0.85

Calls 2

LoadCreationRuleForFileFunction · 0.92
findConfigFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…