Skip to content

Commit

Permalink
up deps
Browse files Browse the repository at this point in the history
up to date all dependency and  migrate to madmin-go #23
  • Loading branch information
rzrbld committed Jul 13, 2021
1 parent c7657e1 commit 54b2895
Show file tree
Hide file tree
Showing 15 changed files with 164 additions and 313 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN \
apk add --no-cache git && \
git clone https://github.com/rzrbld/adminio-api && cd adminio-api/src/ && go build main.go && cp main /go/bin/adminio

FROM alpine:3.11
FROM alpine:3.14

EXPOSE 8080

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ADD src /src/

RUN cd /src/ && go build main.go && cp main /go/bin/adminio

FROM alpine:3.11
FROM alpine:3.14

EXPOSE 8080

Expand Down
4 changes: 2 additions & 2 deletions src/audit/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
iris "github.com/kataras/iris/v12"
"github.com/markbates/goth"
cnf "github.com/rzrbld/adminio-api/config"
log "log"
log "github.com/sirupsen/logrus"
)

func DefaultAuditLog(user goth.User, ctx iris.Context) {
ctx.ViewData("", user)
if cnf.AuditLogEnable {
log.Print("userNickName: ", user.NickName, "; userID: ", user.UserID, "; method:", ctx.RouteName())
log.Infoln("userNickName: ", user.NickName, "; userID: ", user.UserID, "; method:", ctx.RouteName())
}
}
10 changes: 6 additions & 4 deletions src/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package clients
import (
minio "github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
madmin "github.com/minio/minio/pkg/madmin"

log "github.com/sirupsen/logrus"

madmin "github.com/minio/madmin-go"
cnf "github.com/rzrbld/adminio-api/config"
"log"
)

var MadmClnt, MadmErr = madmin.New(cnf.Server, cnf.Maccess, cnf.Msecret, cnf.Ssl)
Expand All @@ -19,10 +21,10 @@ var MinioClnt, MinioErr = minio.New(cnf.Server, &minio.Options{

func main() {
if MadmErr != nil {
log.Fatal("Error while connecting via admin client ", MadmErr)
log.Fatalln("Error while connecting via admin client ", MadmErr)
}

if MinioErr != nil {
log.Fatal("Error while connecting via minio client ", MinioErr)
log.Fatalln("Error while connecting via minio client ", MinioErr)
}
}
36 changes: 32 additions & 4 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package config
import (
"os"
strconv "strconv"

log "github.com/sirupsen/logrus"
)

var (
Server = getEnv("MINIO_HOST_PORT", "localhost:9000")
Maccess = getEnv("MINIO_ACCESS", "test")
Msecret = getEnv("MINIO_SECRET", "testtest123")
Region = getEnv("MINIO_REGION", "us-east-1")
Server = getEnv("MINIO_HOST_PORT", "localhost:9000")
Maccess = getEnv("MINIO_ACCESS", "test")
Msecret = getEnv("MINIO_SECRET", "testtest123")
Region = getEnv("MINIO_REGION", "us-east-1")
SvcLogLevel = getEnv("ADMINIO_LOG_LEVEL", "INFO")
// Enable object locking by default
DefaultObjectLocking, _ = strconv.ParseBool(getEnv("MINIO_DEFAULT_LOCK_OBLECT_ENABLE", "false"))
Ssl, _ = strconv.ParseBool(getEnv("MINIO_SSL", "false"))
Expand Down Expand Up @@ -41,3 +44,28 @@ func getEnv(key, fallback string) string {

return value
}

func SetLogLevel() {
log.Infoln("Set log level to: ", SvcLogLevel)
selectedLogLevel := log.InfoLevel
switch loglvl := SvcLogLevel; loglvl {
case "TRACE":
selectedLogLevel = log.TraceLevel
case "DEBUG":
selectedLogLevel = log.DebugLevel
case "INFO":
selectedLogLevel = log.InfoLevel
case "WARN":
selectedLogLevel = log.WarnLevel
case "ERROR":
selectedLogLevel = log.ErrorLevel
case "FATAL":
selectedLogLevel = log.FatalLevel
case "PANIC":
selectedLogLevel = log.PanicLevel
default:
log.Errorln("Unknown log level:", SvcLogLevel, ". Fallback to INFO.", "Possible values: \n TRACE \n DEBUG \n INFO \n WARN \n ERROR \n FATAL \n PANIC \n")
}

log.SetLevel(selectedLogLevel)
}
10 changes: 3 additions & 7 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,23 @@ require (
github.com/jarcoal/httpmock v1.0.8 // indirect
github.com/kataras/golog v0.1.7 // indirect
github.com/kataras/iris/v12 v12.2.0-alpha2
github.com/klauspost/compress v1.11.12 // indirect
github.com/klauspost/cpuid/v2 v2.0.5 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/markbates/goth v1.67.1
github.com/minio/madmin-go v1.0.15
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/minio v0.0.0-20210326002359-91eb1fe2ef42
github.com/minio/minio-go/v7 v7.0.11-0.20210302210017-6ae69c73ce78
github.com/montanaflynn/stats v0.6.5 // indirect
github.com/prometheus/client_golang v1.10.0
github.com/prometheus/common v0.20.0 // indirect
github.com/rzrbld/goth-provider-wso2 v0.0.0-20200714144945-8df7b3afa068
github.com/shirou/gopsutil/v3 v3.21.2 // indirect
github.com/sirupsen/logrus v1.8.1
github.com/smartystreets/assertions v1.2.0 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/tdewolff/minify/v2 v2.9.15 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.1 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
Expand Down
Loading

0 comments on commit 54b2895

Please sign in to comment.