From 7ac17d69c04d97ce13028bcf3df61e8ef1a7acd8 Mon Sep 17 00:00:00 2001 From: Calvin Leung Huang Date: Wed, 12 Dec 2018 12:26:11 -0800 Subject: [PATCH] cli/json: correctly output the number of key shares and threshold on stored keys (#5910) --- command/operator_init.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/command/operator_init.go b/command/operator_init.go index 2a0c0cb24f..bfe57ccaa2 100644 --- a/command/operator_init.go +++ b/command/operator_init.go @@ -549,8 +549,15 @@ func newMachineInit(req *api.InitRequest, resp *api.InitResponse) *machineInit { init.UnsealKeysB64[i] = v } - init.UnsealShares = req.SecretShares - init.UnsealThreshold = req.SecretThreshold + // If we don't get a set of keys back, it means that we are storing the keys, + // so the key shares and threshold has been set to 1. + if len(resp.Keys) == 0 { + init.UnsealShares = 1 + init.UnsealThreshold = 1 + } else { + init.UnsealShares = req.SecretShares + init.UnsealThreshold = req.SecretThreshold + } init.RecoveryKeysHex = make([]string, len(resp.RecoveryKeys)) for i, v := range resp.RecoveryKeys {