File tree Expand file tree Collapse file tree 5 files changed +18
-12
lines changed Expand file tree Collapse file tree 5 files changed +18
-12
lines changed Original file line number Diff line number Diff line change 1
1
language : go
2
2
go : 1.14
3
3
sudo : false
4
+ before_script :
5
+ - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
4
6
cache :
5
7
directories :
6
8
- $GOPATH/pkg/mod
9
+ script :
10
+ - ./bin/golangci-lint run
11
+ - go test -race ./...
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package health
2
2
3
3
import (
4
4
"encoding/json"
5
+ "log"
5
6
"net/http"
6
7
)
7
8
@@ -10,7 +11,9 @@ var GitRevision = "unknown"
10
11
// Handler returns the value of GitRevision in simple struct.
11
12
func Handler (w http.ResponseWriter , r * http.Request ) {
12
13
w .Header ().Set ("Content-Type" , "application/json" )
13
- json .NewEncoder (w ).Encode (struct {
14
+ if err := json .NewEncoder (w ).Encode (struct {
14
15
Version string `json:"version"`
15
- }{Version : GitRevision })
16
+ }{Version : GitRevision }); err != nil {
17
+ log .Printf ("failed to encode Health response: %s" , err )
18
+ }
16
19
}
Original file line number Diff line number Diff line change @@ -209,5 +209,7 @@ func refFromQuery(v url.Values) string {
209
209
func marshalResponse (w http.ResponseWriter , v interface {}) {
210
210
w .Header ().Set ("Content-Type" , "application/json" )
211
211
w .Header ().Set ("Access-Control-Allow-Origin" , "*" )
212
- json .NewEncoder (w ).Encode (v )
212
+ if err := json .NewEncoder (w ).Encode (v ); err != nil {
213
+ log .Printf ("failed to encode response: %s" , err )
214
+ }
213
215
}
Original file line number Diff line number Diff line change @@ -7,18 +7,19 @@ import (
7
7
)
8
8
9
9
const (
10
- authHeader = "Authorization"
11
- authTokenCtxKey = "auth-token"
10
+ authHeader = "Authorization"
12
11
)
13
12
13
+ type authTokenCtxKey struct {}
14
+
14
15
// AuthToken gets the auth token from the context.
15
16
func AuthToken (ctx context.Context ) string {
16
- return ctx .Value (authTokenCtxKey ).(string )
17
+ return ctx .Value (authTokenCtxKey {} ).(string )
17
18
}
18
19
19
20
// WithAuthToken sets the auth token into the context.
20
21
func WithAuthToken (ctx context.Context , t string ) context.Context {
21
- return context .WithValue (ctx , authTokenCtxKey , t )
22
+ return context .WithValue (ctx , authTokenCtxKey {} , t )
22
23
}
23
24
24
25
// AuthenticationMiddleware wraps an http.Handler and checks for the presence of
Original file line number Diff line number Diff line change @@ -13,11 +13,6 @@ import (
13
13
"github.com/rhd-gitops-example/gitops-backend/pkg/gitfs"
14
14
)
15
15
16
- const (
17
- serviceLabel = "app.kubernetes.io/name"
18
- appLabel = "app.kubernetes.io/part-of"
19
- )
20
-
21
16
// ParseFromGit takes a go-git CloneOptions struct and a filepath, and extracts
22
17
// the service configuration from there.
23
18
func ParseFromGit (path string , opts * git.CloneOptions ) ([]* Resource , error ) {
You can’t perform that action at this time.
0 commit comments