Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint issues #27

Merged
merged 5 commits into from
Dec 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"log"

"github.com/databus23/goslo.policy"
policy "github.com/databus23/goslo.policy"
"github.com/sapcc/hermes/pkg/api"
"github.com/sapcc/hermes/pkg/configdb"
"github.com/sapcc/hermes/pkg/identity"
Expand Down
5 changes: 3 additions & 2 deletions pkg/api/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ package api

import (
"fmt"
"net/http"
"strings"

"github.com/gorilla/mux"
"github.com/sapcc/hermes/pkg/configdb"
"github.com/sapcc/hermes/pkg/identity"
"github.com/sapcc/hermes/pkg/storage"
"net/http"
"strings"
)

type v1Provider struct {
Expand Down
12 changes: 7 additions & 5 deletions pkg/api/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ import (
"net/http"

"fmt"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/sapcc/hermes/pkg/hermes"
"github.com/sapcc/hermes/pkg/util"
"reflect"
"strconv"
"strings"
"time"

"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/sapcc/hermes/pkg/hermes"
"github.com/sapcc/hermes/pkg/util"
)

// EventList is the model for JSON returned by the ListEvents API call
Expand Down Expand Up @@ -226,7 +227,8 @@ func (p *v1Provider) GetAttributes(res http.ResponseWriter, req *http.Request) {
// Handle QueryParams
queryName := mux.Vars(req)["attribute_name"]
if queryName == "" {
fmt.Errorf("QueryName not found")
util.LogDebug("attribute_name empty")
return
}
maxdepth, _ := strconv.ParseUint(req.FormValue("max_depth"), 10, 32)
limit, _ := strconv.ParseUint(req.FormValue("limit"), 10, 32)
Expand Down
7 changes: 4 additions & 3 deletions pkg/api/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ package api

import (
"errors"
"log"
"net/http"
"os"

policy "github.com/databus23/goslo.policy"
"github.com/gophercloud/gophercloud"
"github.com/gorilla/mux"
"github.com/sapcc/hermes/pkg/util"
"github.com/spf13/viper"
"log"
"net/http"
"os"
)

//Token represents a user's token, as passed through the X-Auth-Token header of
Expand Down
17 changes: 11 additions & 6 deletions pkg/api/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package api
import (
"bytes"
"encoding/json"
"net/http"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
"github.com/sapcc/hermes/pkg/util"
)

// utility functionality
Expand All @@ -31,11 +33,14 @@ func ReturnJSON(w http.ResponseWriter, code int, data interface{}) {
payload, err := json.MarshalIndent(&data, "", " ")
// Replaces & symbols properly in json within urls.
payload = bytes.Replace(payload, []byte("\\u0026"), []byte("&"), -1)
if err == nil {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
w.Write(payload)
} else {
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
_, err = w.Write(payload)
if err != nil {
util.LogDebug("Issue with writing payload when returning Json")
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/hermes/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package hermes

import (
"fmt"

"github.com/jinzhu/copier"
"github.com/sapcc/hermes/pkg/identity"
"github.com/sapcc/hermes/pkg/storage"
Expand Down
5 changes: 3 additions & 2 deletions pkg/identity/keystone.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ package identity
import (
"fmt"

"github.com/databus23/goslo.policy"
"sync"

policy "github.com/databus23/goslo.policy"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack"
"github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"
"github.com/pkg/errors"
"github.com/sapcc/hermes/pkg/util"
"github.com/spf13/viper"
"sync"
)

//Keystone Openstack Keystone implementation
Expand Down
5 changes: 3 additions & 2 deletions pkg/identity/keystone_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package identity

import (
"container/list"
"github.com/gophercloud/gophercloud"
"github.com/sapcc/hermes/pkg/util"
"sync"
"time"

"github.com/gophercloud/gophercloud"
"github.com/sapcc/hermes/pkg/util"
)

// Cache type used for the name caches
Expand Down
2 changes: 1 addition & 1 deletion pkg/identity/mock.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package identity

import (
"github.com/databus23/goslo.policy"
policy "github.com/databus23/goslo.policy"
"github.com/gophercloud/gophercloud"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/policy/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"os"

"github.com/databus23/goslo.policy"
policy "github.com/databus23/goslo.policy"
"github.com/sapcc/hermes/pkg/util"
"github.com/stretchr/testify/assert"
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/storage/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"encoding/json"
"fmt"
"strings"

"github.com/sapcc/hermes/pkg/util"
"github.com/spf13/viper"
elastic "gopkg.in/olivere/elastic.v5"
"strings"
)

//ElasticSearch struct holds esclient
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,5 @@ type AttributeValueList []AttributeValue
//AttributeValue contains the attribute, and the number of hits.
type AttributeValue struct {
Value string `json:"value"`
count int64 `json:"count"` // Removing export due to desire to not include it in JSON return
count int64 // Removing export due to desire to not include it in JSON return
}
2 changes: 1 addition & 1 deletion pkg/util/load_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"io/ioutil"

"github.com/databus23/goslo.policy"
policy "github.com/databus23/goslo.policy"
)

// LoadPolicyFile used to Load the hermes policy.json file from disk.
Expand Down