Skip to content

Commit

Permalink
Merge pull request #23 from marensofier/shamir-from-string
Browse files Browse the repository at this point in the history
fix: hent ut shamir threshold fra encrypt-config
  • Loading branch information
Fosso committed May 31, 2024
2 parents 8e451c9 + 6e7a644 commit d4ac2a5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/sops/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ func getEncryptConfigFromString(c *cli.Context, fileName string, configString st
}

var threshold int
threshold, err = shamirThreshold(c, fileName)
threshold, err = shamirThresholdFromString(configString, fileName)
if err != nil {
return encryptConfig{}, err
}
Expand Down Expand Up @@ -2241,6 +2241,17 @@ func shamirThreshold(c *cli.Context, file string) (int, error) {
return conf.ShamirThreshold, nil
}

func shamirThresholdFromString(c string, file string) (int, error) {
conf, err := loadConfigFromString(c, file, nil)
if conf == nil {
// This takes care of the following two case:
// 1. No config was provided. Err will be nil and ShamirThreshold will be the default value of 0.
// 2. We did find a config file, but failed to load it. In that case the calling function will print the error and exit.
return 0, err
}
return conf.ShamirThreshold, nil
}

func jsonValueToTreeInsertableValue(jsonValue string) (interface{}, error) {
var valueToInsert interface{}
err := encodingjson.Unmarshal([]byte(jsonValue), &valueToInsert)
Expand Down

0 comments on commit d4ac2a5

Please sign in to comment.