mirror of
https://github.com/minio/minio.git
synced 2025-01-14 16:25:01 -05:00
Merge pull request #839 from harshavardhana/add-missing-golint
Fix all the golint complaints about newly added changes
This commit is contained in:
commit
1c5454e007
4
Makefile
4
Makefile
@ -29,8 +29,8 @@ fmt:
|
|||||||
|
|
||||||
lint:
|
lint:
|
||||||
@echo "Running $@:"
|
@echo "Running $@:"
|
||||||
@GO15VENDOREXPERIMENT=1 golint .
|
@GO15VENDOREXPERIMENT=1 golint *.go
|
||||||
@GO15VENDOREXPERIMENT=1 golint pkg
|
@GO15VENDOREXPERIMENT=1 golint github.com/minio/minio/pkg...
|
||||||
|
|
||||||
cyclo:
|
cyclo:
|
||||||
@echo "Running $@:"
|
@echo "Running $@:"
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Version version string
|
||||||
type Version struct {
|
type Version struct {
|
||||||
Date string
|
Date string
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ func getRPCHandler() http.Handler {
|
|||||||
s.RegisterService(new(rpc.VersionService), "Version")
|
s.RegisterService(new(rpc.VersionService), "Version")
|
||||||
s.RegisterService(new(rpc.DonutService), "Donut")
|
s.RegisterService(new(rpc.DonutService), "Donut")
|
||||||
s.RegisterService(new(rpc.AuthService), "Auth")
|
s.RegisterService(new(rpc.AuthService), "Auth")
|
||||||
s.RegisterService(rpc.NewServerService(), "Server")
|
s.RegisterService(new(rpc.ServerService), "Server")
|
||||||
// Add new RPC services here
|
// Add new RPC services here
|
||||||
return registerRPC(router.NewRouter(), s)
|
return registerRPC(router.NewRouter(), s)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/gorilla/rpc/v2/json"
|
"github.com/gorilla/rpc/v2/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Server new rpc server container
|
||||||
type Server struct {
|
type Server struct {
|
||||||
*rpc.Server
|
*rpc.Server
|
||||||
}
|
}
|
||||||
|
@ -25,26 +25,35 @@ import (
|
|||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/minio/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// MinioServer - container for minio server data
|
||||||
type MinioServer struct {
|
type MinioServer struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
IP string `json:"ip"`
|
IP string `json:"ip"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServerArg - server arg
|
||||||
type ServerArg struct {
|
type ServerArg struct {
|
||||||
MinioServer
|
MinioServer
|
||||||
}
|
}
|
||||||
|
|
||||||
type DummyReply struct{}
|
// ServerAddReply - server add reply
|
||||||
|
type ServerAddReply struct {
|
||||||
|
Server MinioServer `json:"server"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MemStatsReply memory statistics
|
||||||
type MemStatsReply struct {
|
type MemStatsReply struct {
|
||||||
runtime.MemStats `json:"memstats"`
|
runtime.MemStats `json:"memstats"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DiskStatsReply disk statistics
|
||||||
type DiskStatsReply struct {
|
type DiskStatsReply struct {
|
||||||
DiskStats syscall.Statfs_t `json:"diskstats"`
|
DiskStats syscall.Statfs_t `json:"diskstats"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SysInfoReply system info
|
||||||
type SysInfoReply struct {
|
type SysInfoReply struct {
|
||||||
Hostname string `json:"hostname"`
|
Hostname string `json:"hostname"`
|
||||||
SysARCH string `json:"sys.arch"`
|
SysARCH string `json:"sys.arch"`
|
||||||
@ -54,30 +63,38 @@ type SysInfoReply struct {
|
|||||||
GOVersion string `json:"goversion"`
|
GOVersion string `json:"goversion"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListReply struct {
|
// ServerListReply list of minio servers
|
||||||
List []MinioServer `json:"list"`
|
type ServerListReply struct {
|
||||||
|
ServerList []MinioServer `json:"servers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServerService server json rpc service
|
||||||
type ServerService struct {
|
type ServerService struct {
|
||||||
list []MinioServer
|
serverList []MinioServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ServerService) Add(r *http.Request, arg *ServerArg, reply *DummyReply) error {
|
// Add - add new server
|
||||||
this.list = append(this.list, MinioServer{arg.Name, arg.IP, arg.ID})
|
func (s *ServerService) Add(r *http.Request, arg *ServerArg, reply *ServerAddReply) error {
|
||||||
|
reply.Server = MinioServer{arg.Name, arg.IP, arg.ID}
|
||||||
|
reply.Status = "connected"
|
||||||
|
s.serverList = append(s.serverList, reply.Server)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ServerService) MemStats(r *http.Request, arg *ServerArg, reply *MemStatsReply) error {
|
// MemStats - memory statistics on the server
|
||||||
|
func (s *ServerService) MemStats(r *http.Request, arg *ServerArg, reply *MemStatsReply) error {
|
||||||
runtime.ReadMemStats(&reply.MemStats)
|
runtime.ReadMemStats(&reply.MemStats)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ServerService) DiskStats(r *http.Request, arg *ServerArg, reply *DiskStatsReply) error {
|
// DiskStats - disk statistics on the server
|
||||||
|
func (s *ServerService) DiskStats(r *http.Request, arg *ServerArg, reply *DiskStatsReply) error {
|
||||||
syscall.Statfs("/", &reply.DiskStats)
|
syscall.Statfs("/", &reply.DiskStats)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ServerService) SysInfo(r *http.Request, arg *ServerArg, reply *SysInfoReply) error {
|
// SysInfo - system info for the server
|
||||||
|
func (s *ServerService) SysInfo(r *http.Request, arg *ServerArg, reply *SysInfoReply) error {
|
||||||
reply.SysARCH = runtime.GOARCH
|
reply.SysARCH = runtime.GOARCH
|
||||||
reply.SysOS = runtime.GOOS
|
reply.SysOS = runtime.GOOS
|
||||||
reply.SysCPUS = runtime.NumCPU()
|
reply.SysCPUS = runtime.NumCPU()
|
||||||
@ -91,17 +108,12 @@ func (this *ServerService) SysInfo(r *http.Request, arg *ServerArg, reply *SysIn
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ServerService) List(r *http.Request, arg *ServerArg, reply *ListReply) error {
|
// List of servers in the cluster
|
||||||
reply.List = this.list
|
func (s *ServerService) List(r *http.Request, arg *ServerArg, reply *ServerListReply) error {
|
||||||
return nil
|
reply.ServerList = []MinioServer{
|
||||||
}
|
|
||||||
|
|
||||||
func NewServerService() *ServerService {
|
|
||||||
s := &ServerService{}
|
|
||||||
s.list = []MinioServer{
|
|
||||||
{"server.one", "192.168.1.1", "192.168.1.1"},
|
{"server.one", "192.168.1.1", "192.168.1.1"},
|
||||||
{"server.two", "192.168.1.2", "192.168.1.2"},
|
{"server.two", "192.168.1.2", "192.168.1.2"},
|
||||||
{"server.three", "192.168.1.3", "192.168.1.3"},
|
{"server.three", "192.168.1.3", "192.168.1.3"},
|
||||||
}
|
}
|
||||||
return s
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
"github.com/rs/cors"
|
"github.com/rs/cors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// MiddlewareHandler - useful to chain different middleware http.Handler
|
||||||
type MiddlewareHandler func(http.Handler) http.Handler
|
type MiddlewareHandler func(http.Handler) http.Handler
|
||||||
|
|
||||||
type contentTypeHandler struct {
|
type contentTypeHandler struct {
|
||||||
@ -153,6 +154,7 @@ func (h validateAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CorsHandler handler for CORS (Cross Origin Resource Sharing)
|
||||||
func CorsHandler(h http.Handler) http.Handler {
|
func CorsHandler(h http.Handler) http.Handler {
|
||||||
return cors.Default().Handler(h)
|
return cors.Default().Handler(h)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user