Skip to content

Commit

Permalink
use json.Unmarshal instead of Decoder in maintenance_window_update
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsn723 committed Sep 29, 2021
1 parent de06dfa commit 25b01e0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions command/maintenance_window_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"

Expand Down Expand Up @@ -52,16 +53,15 @@ func (c *MaintenanceWindowUpdate) Run(args []string) int {
log.Error("Please specify input json file")
return -1
}

log.Info("Input file is:", flags.Arg(0))
f, err := os.Open(flags.Arg(0))
f, err := ioutil.ReadFile(flags.Arg(0))
if err != nil {
log.Error(err)
return -1
}

defer f.Close()
decoder := json.NewDecoder(f)
if err := decoder.Decode(&mw); err != nil {
if err := json.Unmarshal(f, &mw); err != nil {
log.Errorln("Failed to decode json. Error:", err)
return -1
}
Expand Down

0 comments on commit 25b01e0

Please sign in to comment.