Skip to content

Commit

Permalink
[FAB-8473] Make configtxlator truncate output file
Browse files Browse the repository at this point in the history
The new configtxlator CLI mode allows specifying an output file.  If the
file already exists, the output is appended.  This is fairly unintuitive
behavior or a CLI and it should truncate the file instead.  This CR
simply adds the truncate flag to the file opens in the flag options.

Change-Id: I5ea14170da1dc93f4f5c5b9aa555080311f71e9e
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Feb 23, 2018
1 parent d8e5726 commit 692d54b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions common/tools/configtxlator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ var (
protoEncode = app.Command("proto_encode", "Converts a JSON document to protobuf.")
protoEncodeType = protoEncode.Flag("type", "The type of protobuf structure to encode to. For example, 'common.Config'.").Required().String()
protoEncodeSource = protoEncode.Flag("input", "A file containing the JSON document.").Default(os.Stdin.Name()).File()
protoEncodeDest = protoEncode.Flag("output", "A file to write the output to.").Default(os.Stdout.Name()).OpenFile(os.O_RDWR|os.O_CREATE, 0600)
protoEncodeDest = protoEncode.Flag("output", "A file to write the output to.").Default(os.Stdout.Name()).OpenFile(os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)

protoDecode = app.Command("proto_decode", "Converts a proto message to JSON.")
protoDecodeType = protoDecode.Flag("type", "The type of protobuf structure to decode from. For example, 'common.Config'.").Required().String()
protoDecodeSource = protoDecode.Flag("input", "A file containing the proto message.").Default(os.Stdin.Name()).File()
protoDecodeDest = protoDecode.Flag("output", "A file to write the JSON document to.").Default(os.Stdout.Name()).OpenFile(os.O_RDWR|os.O_CREATE, 0600)
protoDecodeDest = protoDecode.Flag("output", "A file to write the JSON document to.").Default(os.Stdout.Name()).OpenFile(os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)

computeUpdate = app.Command("compute_update", "Takes two marshaled common.Config messages and computes the config update which transitions between the two.")
computeUpdateOriginal = computeUpdate.Flag("original", "The original config message.").File()
computeUpdateUpdated = computeUpdate.Flag("updated", "The updated config message.").File()
computeUpdateChannelID = computeUpdate.Flag("channel_id", "The name of the channel for this update.").Required().String()
computeUpdateDest = computeUpdate.Flag("output", "A file to write the JSON document to.").Default(os.Stdout.Name()).OpenFile(os.O_RDWR|os.O_CREATE, 0600)
computeUpdateDest = computeUpdate.Flag("output", "A file to write the JSON document to.").Default(os.Stdout.Name()).OpenFile(os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)

version = app.Command("version", "Show version information")
)
Expand Down

0 comments on commit 692d54b

Please sign in to comment.