Skip to content

Commit 5a58187

Browse files
committed
go fmt project
1 parent 7a7db11 commit 5a58187

File tree

12 files changed

+31
-42
lines changed

12 files changed

+31
-42
lines changed

common/funcs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ func GetMD5Hash(text string) string {
1919
func ExecutionTime(start time.Time, name string) {
2020
elapsed := time.Since(start)
2121
log.Debugf("%s took %s", name, elapsed)
22-
}
22+
}

config/config.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package config
22

33
import (
4-
"github.com/spf13/viper"
5-
"strings"
6-
"os"
74
"fmt"
5+
"os"
6+
"strings"
7+
8+
"github.com/spf13/viper"
89
)
910

1011
func ConfigInit(cfgFile string) {
@@ -74,22 +75,22 @@ func printConfigSummary() {
7475
"server.bind_port",
7576
"backend.db_driver",
7677
"backend.db_dsn",
77-
} {
78+
} {
7879

7980
log.Debugf("%s: %s\n", c, viper.GetString(c))
8081
}
8182
}
8283

8384
func sanityChecks() {
8485

85-
if viper.GetString("backend.db_driver") != "mysql" && viper.GetString("backend.db_driver") != "" {
86+
if viper.GetString("backend.db_driver") != "mysql" && viper.GetString("backend.db_driver") != "" {
8687

8788
log.Fatalf("only mysql is supported for backend_db_driver (value: %s)", viper.GetString("backend.db_driver"))
8889
}
8990

90-
if viper.GetString("backend.db_dsn") == "" {
91+
if viper.GetString("backend.db_dsn") == "" {
9192

9293
log.Fatal("backend_db_dsn must be set")
9394
}
9495

95-
}
96+
}

config/logger.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package config
22

33
import (
4-
"github.com/op/go-logging"
54
"os"
5+
6+
"github.com/op/go-logging"
67
)
78

89
var log = logging.MustGetLogger("vsummary")
@@ -12,7 +13,6 @@ func loggingInit(loglevel string) {
1213
// In case of an invalid log level we default to ERROR
1314
var log_level logging.Level = logging.ERROR
1415

15-
1616
// Validating log levels
1717
_, err := logging.LogLevel(loglevel)
1818
if err != nil {
@@ -46,4 +46,4 @@ func loggingInit(loglevel string) {
4646
log_backend_fl.SetLevel(log_level, "")
4747

4848
logging.SetBackend(log_backend_fl)
49-
}
49+
}

crypto/aes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ func Decrypt(cryptoText string) (decryptedText string, err error) {
100100
decryptedText = fmt.Sprintf("%s", ciphertext)
101101

102102
return
103-
}
103+
}

db/selects.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package db
22

33
import (
4-
54
"github.com/gbolo/vsummary/common"
65
)
76

@@ -23,4 +22,3 @@ func (b *Backend) GetPollers() (pollers []common.Poller, err error) {
2322
return
2423

2524
}
26-

main.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package main
22

33
import (
4-
54
_ "github.com/go-sql-driver/mysql"
65
//"github.com/jmoiron/sqlx"
6+
"github.com/gbolo/vsummary/config"
77
back "github.com/gbolo/vsummary/db"
88
"github.com/gbolo/vsummary/poller"
99
"github.com/gbolo/vsummary/server"
10-
"github.com/gbolo/vsummary/config"
1110
//"github.com/gbolo/vsummary/crypto"
1211

1312
//"context"
@@ -17,8 +16,8 @@ import (
1716

1817
"crypto/md5"
1918
"encoding/hex"
20-
"github.com/op/go-logging"
2119
"fmt"
20+
"github.com/op/go-logging"
2221
//"net/http"
2322
"time"
2423
//"os"
@@ -50,8 +49,6 @@ func main() {
5049
pollers, err := b.GetPollers()
5150
fmt.Println(pollers)
5251

53-
54-
5552
//// vmware section ----------------------------------------------------------------------
5653
//ctx, cancel := context.WithCancel(context.Background())
5754
//defer cancel()
@@ -75,7 +72,6 @@ func main() {
7572

7673
go server.Start()
7774

78-
7975
time.Sleep(3 * time.Second)
8076

8177
fmt.Println("---------------------------------------------------------------------------------------")
@@ -90,4 +86,4 @@ func GetMD5Hash(text string) string {
9086
hasher := md5.New()
9187
hasher.Write([]byte(text))
9288
return hex.EncodeToString(hasher.Sum(nil))
93-
}
89+
}

poller/client.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package poller
22

33
import (
4-
"net/http"
5-
"time"
6-
"fmt"
7-
"github.com/spf13/viper"
84
"bytes"
5+
"fmt"
96
"io"
107
"io/ioutil"
8+
"net/http"
9+
"time"
10+
11+
"github.com/spf13/viper"
1112
)
1213

1314
var vSummaryClient *http.Client
@@ -52,7 +53,7 @@ func sendResults(endpoint string, jsonBody []byte) (err error) {
5253
// send request
5354
log.Debugf("sending results to: %s", url)
5455
//log.Debugf("jsonBody: %s", string(jsonBody))
55-
res, err := vSummaryClient.Post(url,"application/json", bytes.NewReader(jsonBody))
56+
res, err := vSummaryClient.Post(url, "application/json", bytes.NewReader(jsonBody))
5657

5758
// this means the vsummary server api is unreachable
5859
if err != nil {
@@ -74,4 +75,4 @@ func sendResults(endpoint string, jsonBody []byte) (err error) {
7475

7576
log.Infof("api call successful: %d %s", res.StatusCode, url)
7677
return
77-
}
78+
}

poller/load.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ func pollerLoop(p *Poller) (err error) {
6868
}
6969
}
7070

71-
}
71+
}

poller/poll_datacenters.go

+6-10
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@ package poller
22

33
import (
44
"context"
5-
//"encoding/json"
5+
"encoding/json"
66
"time"
77

88
"github.com/gbolo/vsummary/common"
99
"github.com/vmware/govmomi/view"
1010
"github.com/vmware/govmomi/vim25/mo"
11-
//"github.com/vmware/govmomi/govc/datacenter"
12-
"encoding/json"
1311
)
1412

15-
16-
1713
func (p *Poller) GetDatacenters() (dcList []common.Datacenter, err error) {
1814

1915
// log time on debug
@@ -48,11 +44,11 @@ func (p *Poller) GetDatacenters() (dcList []common.Datacenter, err error) {
4844
for _, dc := range dcs {
4945

5046
dcStruct := common.Datacenter{
51-
Name: dc.Name,
52-
Moref: dc.Self.Value,
53-
EsxiFolderMoref: dc.HostFolder.Value,
54-
VmFolderMoref: dc.VmFolder.Value,
55-
VcenterId: v.Client().ServiceContent.About.InstanceUuid,
47+
Name: dc.Name,
48+
Moref: dc.Self.Value,
49+
EsxiFolderMoref: dc.HostFolder.Value,
50+
VmFolderMoref: dc.VmFolder.Value,
51+
VcenterId: v.Client().ServiceContent.About.InstanceUuid,
5652
}
5753

5854
dcList = append(dcList, dcStruct)

poller/poll_vms.go

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
"github.com/vmware/govmomi/vim25/mo"
1111
)
1212

13-
14-
1513
func (p *Poller) GetVMs() (vmList []common.Vm, err error) {
1614

1715
// log time on debug

poller/poller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ func logPollingResult(err error) {
6868
} else {
6969
log.Warningf("poll was not successful: %s", err)
7070
}
71-
}
71+
}

server/handlers.go

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ func handlerPoller(w http.ResponseWriter, req *http.Request) {
9292
return
9393
}
9494

95-
9695
// insert to backend
9796
err = backend.InsertPoller(poller)
9897
if err != nil {

0 commit comments

Comments
 (0)