Skip to content

Commit

Permalink
Update Dockerfile, Dockerfile.dev, and 3 more files...
Browse files Browse the repository at this point in the history
  • Loading branch information
rzrbld committed Feb 24, 2020
1 parent 28f1eb5 commit abd072f
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV GOPROXY https://proxy.golang.org

RUN \
apk add --no-cache git && \
git clone https://github.com/minio/minio && cd minio/ && git checkout bd106408462ecef70debf51f1e6179de950c5812 && cd pkg/madmin/examples/ && \
git clone https://github.com/minio/minio && cd minio/ && git checkout d4dcf1d7225a38ecf94abe7cbe7c69a93dc7c0b0 && cd pkg/madmin/examples/ && \
git clone https://github.com/rzrbld/adminio-api && go build adminio-api/src/main.go && cp main /go/bin/adminio

FROM alpine:3.9
Expand Down
28 changes: 28 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM golang:1.13-alpine

LABEL maintainer="rzrbld <[email protected]>"

ENV GOPATH /go
ENV CGO_ENABLED 0
ENV GO111MODULE on
ENV GOPROXY https://proxy.golang.org

RUN \
apk add --no-cache git && \
git clone https://github.com/minio/minio && cd minio/ && git checkout d4dcf1d7225a38ecf94abe7cbe7c69a93dc7c0b0 && cd pkg/madmin/examples/

COPY src/main.go minio/pkg/madmin/examples/

RUN cd minio/pkg/madmin/examples && go build main.go && cp main /go/bin/adminio

FROM alpine:3.9

EXPOSE 8080

COPY --from=0 /go/bin/adminio /usr/bin/adminio

RUN \
apk add --no-cache ca-certificates 'curl>7.61.0' 'su-exec>=0.2' && \
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf

CMD ["adminio"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ after that you can go to `` http://localhost `` and try out
| MINIO_REGION | set minio region | us-east-1 |
| MINIO_ACCESS | set minio Access Key | test |
| MINIO_SECRET | set minio Secret Key | testtest123 |
| ADMINIO_CORS_DOMAIN | set adminio-api CORS policy domain | * |
Binary file modified dist/main
Binary file not shown.
117 changes: 113 additions & 4 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ type UserStatus struct {
status madmin.AccountStatus `json:"status"`
}

type bucketComplex struct {
bucket string
// bucketInfo minio.BucketInfo
// bucketEvents minio.BucketNotification
}

type candidate struct {
name string
interests []string
language string
experience bool
}

func defaultResHandler(ctx iris.Context, err error) iris.Map {
var resp iris.Map
if err != nil {
Expand All @@ -61,11 +74,11 @@ func bodyResHandler(ctx iris.Context, err error, body interface{}) interface{} {

func main() {
fmt.Println("\033[31m\r\n ________ ________ _____ ______ ___ ________ ___ ________ \r\n|\\ __ \\ |\\ ___ \\ |\\ _ \\ _ \\ |\\ \\ |\\ ___ \\ |\\ \\ |\\ __ \\ \r\n\\ \\ \\|\\ \\\\ \\ \\_|\\ \\\\ \\ \\\\\\__\\ \\ \\\\ \\ \\\\ \\ \\\\ \\ \\\\ \\ \\\\ \\ \\|\\ \\ \r\n \\ \\ __ \\\\ \\ \\ \\\\ \\\\ \\ \\\\|__| \\ \\\\ \\ \\\\ \\ \\\\ \\ \\\\ \\ \\\\ \\ \\\\\\ \\ \r\n \\ \\ \\ \\ \\\\ \\ \\_\\\\ \\\\ \\ \\ \\ \\ \\\\ \\ \\\\ \\ \\\\ \\ \\\\ \\ \\\\ \\ \\\\\\ \\ \r\n \\ \\__\\ \\__\\\\ \\_______\\\\ \\__\\ \\ \\__\\\\ \\__\\\\ \\__\\\\ \\__\\\\ \\__\\\\ \\_______\\\r\n \\|__|\\|__| \\|_______| \\|__| \\|__| \\|__| \\|__| \\|__| \\|__| \\|_______|\r\n \r\n \r\n \033[m")
fmt.Println("Admin REST API for http://min.io (minio) s3 server")
fmt.Println("version : 0.4 ")
fmt.Println("\033[33mAdmin REST API for http://min.io (minio) s3 server")
fmt.Println("version : 0.6 ")
fmt.Println("Author : rzrbld")
fmt.Println("License : MIT")
fmt.Println("Git-repo : https://github.com/rzrbld/adminio \r\n")
fmt.Println("Git-repo : https://github.com/rzrbld/adminio \033[m \r\n")

var ssl = false
//config
Expand Down Expand Up @@ -103,6 +116,11 @@ func main() {
serverHostPort = os.Getenv("API_HOST_PORT")
}

adminioCORS, exists := os.LookupEnv("ADMINIO_CORS_DOMAIN")
if !exists {
adminioCORS = "*"
}

// connect
madmClnt, err := madmin.New(server, maccess, msecret, ssl)
if err != nil {
Expand All @@ -117,7 +135,7 @@ func main() {
app := iris.New()

crs := cors.New(cors.Options{
AllowedOrigins: []string{"*"}, // allows everything, use that to change the hosts.
AllowedOrigins: []string{adminioCORS}, // allows everything, use that to change the hosts.
AllowCredentials: true,
})

Expand Down Expand Up @@ -269,6 +287,88 @@ func main() {
ctx.JSON(res)
})

v1.Post("/get-bucket-events", func(ctx iris.Context) {
var bucket = ctx.FormValue("bucket")
bn, err := minioClnt.GetBucketNotification(bucket)

var res = bodyResHandler(ctx, err, bn)
ctx.JSON(res)
})

v1.Post("/remove-bucket-events", func(ctx iris.Context) {
var bucket = ctx.FormValue("bucket")
err := minioClnt.RemoveAllBucketNotification(bucket)

var res = defaultResHandler(ctx, err)
ctx.JSON(res)
})

v1.Post("/set-bucket-events", func(ctx iris.Context) {
var arrARN = strings.Split(ctx.FormValue("stsARN"), ":")

var stsARN = minio.NewArn(arrARN[1], arrARN[2], arrARN[3], arrARN[4], arrARN[5])

var bucket = ctx.FormValue("bucket")
var eventTypes = strings.Split(ctx.FormValue("eventTypes"), ",")
var filterPrefix = ctx.FormValue("filterPrefix")
var filterSuffix = ctx.FormValue("filterSuffix")

bucketNotify, err := minioClnt.GetBucketNotification(bucket)

var newNotification = minio.NewNotificationConfig(stsARN)
for _, event := range eventTypes {
switch event {
case "put":
newNotification.AddEvents(minio.ObjectCreatedAll)
case "delete":
newNotification.AddEvents(minio.ObjectRemovedAll)
case "get":
newNotification.AddEvents(minio.ObjectAccessedAll)
}
}
if filterPrefix != "" {
newNotification.AddFilterPrefix(filterPrefix)
}
if filterSuffix != "" {
newNotification.AddFilterSuffix(filterSuffix)
}

switch arrARN[2] {
case "sns":
if bucketNotify.AddTopic(newNotification) {
err = fmt.Errorf("Overlapping Topic configs")
}
case "sqs":
if bucketNotify.AddQueue(newNotification) {
err = fmt.Errorf("Overlapping Queue configs")
}
case "lambda":
if bucketNotify.AddLambda(newNotification) {
err = fmt.Errorf("Overlapping lambda configs")
}
}

err = minioClnt.SetBucketNotification(bucket, bucketNotify)
var res = defaultResHandler(ctx, err)
ctx.JSON(res)
})

v1.Get("/list-buckets-extended", func(ctx iris.Context) {
lb, err := minioClnt.ListBuckets()
allBuckets := []interface{}{}
for _, bucket := range lb {
bn, err := minioClnt.GetBucketNotification(bucket.Name)
if err != nil {
fmt.Errorf("Error while getting bucket notification")
}
br := iris.Map{"name": bucket.Name, "info": bucket, "events": bn}
allBuckets = append(allBuckets, br)
}

var res = bodyResHandler(ctx, err, allBuckets)
ctx.JSON(res)
})

v1.Get("/list-buckets", func(ctx iris.Context) {
lb, err := minioClnt.ListBuckets()
var res = bodyResHandler(ctx, err, lb)
Expand Down Expand Up @@ -337,6 +437,15 @@ func main() {
var res = defaultResHandler(ctx, err)
ctx.JSON(res)
})

v1.Post("/get-kv", func(ctx iris.Context) {
var keyString = ctx.FormValue("keyString")

values, err := madmClnt.GetConfigKV(keyString)
var res = bodyResHandler(ctx, err, values)
ctx.JSON(res)
})

}

app.Run(iris.Addr(serverHostPort))
Expand Down

0 comments on commit abd072f

Please sign in to comment.