From d09b71262ad08b3a9006714c6a2fc1c5b8a5238e Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Thu, 5 Oct 2023 12:57:08 -0600 Subject: [PATCH] Minor formatting --- bin/magellan.sh | 14 +++++++++----- internal/util/util.go | 30 +++++++++++++++--------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/bin/magellan.sh b/bin/magellan.sh index 0850f87..676c62d 100644 --- a/bin/magellan.sh +++ b/bin/magellan.sh @@ -1,17 +1,21 @@ function build(){ - go mod tidy && go build -C bin/magellan + go mod tidy && go build -C bin/magellan } function scan() { - ./magellan scan --subnet 172.16.0.0 --port 443 + ./magellan scan --subnet 172.16.0.0 --port 443 } -function list(){ - ./magellan list +function list() { + ./magellan list +} + +function update() { + ./magellan update --user admin --pass password --host 172.16.0.109 --component BMC --protocol HTTP --firmware-path "" } function collect() { - ./magellan collect --user admin --pass password + ./magellan collect --user admin --pass password } diff --git a/internal/util/util.go b/internal/util/util.go index 661d2ba..0efa1b5 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -11,10 +11,10 @@ import ( ) func PathExists(path string) (bool, error) { - _, err := os.Stat(path) - if err == nil { return true, nil } - if os.IsNotExist(err) { return false, nil } - return false, err + _, err := os.Stat(path) + if err == nil { return true, nil } + if os.IsNotExist(err) { return false, nil } + return false, err } func MakeRequest(url string, httpMethod string, body []byte, headers map[string]string) (*http.Response, []byte, error) { @@ -37,20 +37,20 @@ func MakeRequest(url string, httpMethod string, body []byte, headers map[string] } func MakeOutputDirectory(path string) (string, error) { - // get the current data + time using Go's stupid formatting - t := time.Now() - dirname := t.Format("2006-01-01 15:04:05") - final := path + "/" + dirname + // get the current data + time using Go's stupid formatting + t := time.Now() + dirname := t.Format("2006-01-01 15:04:05") + final := path + "/" + dirname // check if path is valid and directory - pathExists, err := PathExists(final); - if err != nil { - return final, fmt.Errorf("could not check for existing path: %v", err) - } + pathExists, err := PathExists(final); + if err != nil { + return final, fmt.Errorf("could not check for existing path: %v", err) + } if pathExists { - // make sure it is directory with 0o644 permissions - return final, fmt.Errorf("found existing path: %v", final) - } + // make sure it is directory with 0o644 permissions + return final, fmt.Errorf("found existing path: %v", final) + } // create directory with data + time err = os.MkdirAll(final, 0766)