diff --git a/destroyer/destroyer.go b/destroyer/destroyer.go index ff2f2c1..6f715bb 100644 --- a/destroyer/destroyer.go +++ b/destroyer/destroyer.go @@ -2,11 +2,11 @@ package destroyer import ( "encoding/json" + "errors" "fmt" "io/ioutil" "log" "net/http" - "errors" "github.com/barbosaigor/april" "github.com/barbosaigor/april/auth" diff --git a/destroyer/instance.go b/destroyer/instance.go index 03fa78b..c9883c9 100644 --- a/destroyer/instance.go +++ b/destroyer/instance.go @@ -1,6 +1,7 @@ package destroyer type Status uint8 + // Status allowed values const ( Up = Status(iota) @@ -11,5 +12,5 @@ const ( type Instance struct { Name string - Sts Status + Sts Status } diff --git a/destroyer/request/reqtodtyr.go b/destroyer/request/reqtodtyr.go index bdceb15..16acb63 100644 --- a/destroyer/request/reqtodtyr.go +++ b/destroyer/request/reqtodtyr.go @@ -5,8 +5,8 @@ import ( "encoding/json" "errors" "fmt" - "net/http" "io/ioutil" + "net/http" "github.com/barbosaigor/april" "github.com/barbosaigor/april/destroyer" @@ -42,11 +42,11 @@ func ReqToDestroy(host string, svcs []april.Service, token string) error { return err } defer resp.Body.Close() - + if resp.StatusCode == 500 { body, err := ioutil.ReadAll(resp.Body) if err != nil { - return errors.New("Fail to destroy services or read response body") + return errors.New("Fail to destroy services or read response body") } resMsg := destroyer.ResponseMessage{} json.Unmarshal(body, &resMsg) diff --git a/internal/chaoshost/chaos.go b/internal/chaoshost/chaos.go index 4abdb85..c841968 100644 --- a/internal/chaoshost/chaos.go +++ b/internal/chaoshost/chaos.go @@ -2,12 +2,12 @@ package chaoshost import ( "github.com/barbosaigor/april" - "github.com/barbosaigor/april/util" "github.com/barbosaigor/april/destroyer/request" + "github.com/barbosaigor/april/util" ) type ChaosHost struct { - Host string + Host string Token string } @@ -27,7 +27,7 @@ func (ch ChaosHost) PickAndShutdownInstances(conf *april.ConfData, n uint32) ([] svs := make([]april.Service, len(services)) for i, svcName := range services { svs[i].Name = svcName - svs[i].Selector = conf.Services[svcName].Selector; + svs[i].Selector = conf.Services[svcName].Selector } if err = request.ReqToDestroy(ch.Host, svs, ch.Token); err != nil { return nil, err @@ -41,4 +41,4 @@ func (ch ChaosHost) PickAndShutdownInstancesFile(filePath string, n uint32) ([]s return nil, err } return ch.PickAndShutdownInstances(conf, n) -} \ No newline at end of file +} diff --git a/server/server.go b/server/server.go index b3a698e..7738973 100644 --- a/server/server.go +++ b/server/server.go @@ -109,7 +109,7 @@ func chaosHandler(w http.ResponseWriter, r *http.Request) { svs := make([]april.Service, len(services)) for i, s := range services { svs[i].Name = s - svs[i].Selector = conf.Services[s].Selector; + svs[i].Selector = conf.Services[s].Selector } err = request.ReqToDestroy(destroyerHost, svs, token) if err == request.ErrUnauthorized { diff --git a/util/file.go b/util/file.go index 7c7fa65..edaed30 100644 --- a/util/file.go +++ b/util/file.go @@ -16,4 +16,4 @@ func ReadFile(fpath string) ([]byte, error) { return nil, err } return fdata, nil -} \ No newline at end of file +}