diff --git a/src/go.mod b/src/go.mod index 4219afc..a984599 100644 --- a/src/go.mod +++ b/src/go.mod @@ -4,6 +4,8 @@ go 1.14 require ( github.com/ajg/form v1.5.1 // indirect + github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5 // indirect + github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect github.com/google/go-querystring v1.0.0 // indirect github.com/gorilla/securecookie v1.1.1 @@ -14,22 +16,23 @@ require ( github.com/kataras/iris/v12 v12.1.8 github.com/markbates/goth v1.62.0 github.com/mattn/go-isatty v0.0.8 // indirect - github.com/minio/minio v0.0.0-20200315185552-c9212819afbf - github.com/minio/minio-go/v6 v6.0.50-0.20200306231101-b882ba63d570 + github.com/minio/minio v0.0.0-20200422230658-6817c5ea58fb + github.com/minio/minio-go/v6 v6.0.53 github.com/moul/http2curl v1.0.0 // indirect github.com/onsi/ginkgo v1.12.0 // indirect github.com/onsi/gomega v1.9.0 // indirect github.com/prometheus/client_golang v1.2.1 github.com/rzrbld/goth-provider-wso2 v0.0.0-20200321083654-32bbe73a67d4 + github.com/satori/go.uuid v1.2.0 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect + github.com/skyrings/skyring-common v0.0.0-20160929130248-d1c0bb1cbd5e // indirect github.com/valyala/fasthttp v1.9.0 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect github.com/yudai/gojsondiff v1.0.0 // indirect github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect github.com/yudai/pp v2.0.1+incompatible // indirect - golang.org/x/net v0.0.0-20200320220750-118fecf932d8 // indirect golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect gopkg.in/yaml.v2 v2.2.8 // indirect ) diff --git a/src/go.sum b/src/go.sum index 3a644b5..4ce4f00 100644 --- a/src/go.sum +++ b/src/go.sum @@ -55,6 +55,8 @@ github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx2 github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.0 h1:yTUvW7Vhb89inJ+8irsUqiWjh8iT6sQPZiQzI6ReGkA= github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM= +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cheggaaa/pb v1.0.28/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= @@ -144,6 +146,7 @@ github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20190328170749-bb2674552d8f h1:4Gslotqbs16iAg+1KR/XdabIfq8TlAWHdwS5QJFksLc= @@ -261,6 +264,7 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kurin/blazer v0.5.4-0.20190613185654-cf2f27cc0be3/go.mod h1:4FCXMUWo9DllR2Do4TtBd377ezyAJ51vB5uTBjt0pGU= +github.com/kurin/blazer v0.5.4-0.20200327014341-8f90a40f8af7/go.mod h1:4FCXMUWo9DllR2Do4TtBd377ezyAJ51vB5uTBjt0pGU= github.com/lestrrat-go/jwx v0.9.0/go.mod h1:iEoxlYfZjvoGpuWwxUz+eR5e6KTJGsaRcy/YNA/UnBk= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= @@ -296,10 +300,15 @@ github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5 github.com/minio/lsync v1.0.1/go.mod h1:tCFzfo0dlvdGl70IT4IAK/5Wtgb0/BrTmo/jE8pArKA= github.com/minio/minio v0.0.0-20200315185552-c9212819afbf h1:srtxK7j7Pl46viXLDRGYcr+hQP/pNf5zqIQsPcpZ5bU= github.com/minio/minio v0.0.0-20200315185552-c9212819afbf/go.mod h1:QbCnTGb/blyNjrkyxB9ecKxtuWWUdcHShqED1bItwa0= +github.com/minio/minio v0.0.0-20200422230658-6817c5ea58fb h1:qDqH+rGTsORP1Y7M8JSswlWPl5L35C9fuz9VR2qhe8Y= +github.com/minio/minio v0.0.0-20200422230658-6817c5ea58fb/go.mod h1:zBua5AiljGs1Irdl2XEyiJjvZVCVDIG8gjozzRBcVlw= github.com/minio/minio-go/v6 v6.0.45/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg= github.com/minio/minio-go/v6 v6.0.50-0.20200306231101-b882ba63d570 h1:GLTZoRC6rhCTucnkJAQ63LhMU2S4CM71MRc9gfX7ohE= github.com/minio/minio-go/v6 v6.0.50-0.20200306231101-b882ba63d570/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg= +github.com/minio/minio-go/v6 v6.0.53 h1:8jzpwiOzZ5Iz7/goFWqNZRICbyWYShbb5rARjrnSCNI= +github.com/minio/minio-go/v6 v6.0.53/go.mod h1:DIvC/IApeHX8q1BAMVCXSXwpmrmM+I+iBvhvztQorfI= github.com/minio/parquet-go v0.0.0-20200125064549-a1e49702e174/go.mod h1:PXYM9yI2l0YPmxHUXe6mFTmkQcyaVasDshAPTbGpDoo= +github.com/minio/parquet-go v0.0.0-20200414234858-838cfa8aae61/go.mod h1:4trzEJ7N1nBTd5Tt7OCZT5SEin+WiAXpdJ/WgPkESA8= github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU= github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/minio/simdjson-go v0.1.5-0.20200303142138-b17fe061ea37/go.mod h1:oKURrZZEBtqObgJrSjN1Ln2n9MJj2icuBTkeJzZnvSI= @@ -320,6 +329,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/montanaflynn/stats v0.5.0 h1:2EkzeTSqBB4V4bJwWrt5gIIrZmpJBcoIRGS2kWLgzmk= +github.com/montanaflynn/stats v0.5.0/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mrjones/oauth v0.0.0-20180629183705-f4e24b6d100c/go.mod h1:skjdDftzkFALcuGzYSklqYd8gvat6F1gZJ4YPVbkZpM= @@ -352,6 +363,7 @@ github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoT github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/getopt v0.0.0-20180729010549-6fdd0a2c7117/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.4.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -409,10 +421,13 @@ github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAriGFsTZppLXDX93OM= github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shirou/gopsutil v2.20.3-0.20200314133625-53cec6b37e6a+incompatible h1:YiKUe2ZOmfpDBH4OSyxwkx/mjNqHHnNhOtZ2mPyRme8= +github.com/shirou/gopsutil v2.20.3-0.20200314133625-53cec6b37e6a+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= github.com/skyrings/skyring-common v0.0.0-20160929130248-d1c0bb1cbd5e/go.mod h1:d8hQseuYt4rJoOo21lFzYJdhMjmDqLY++ayArbgYjWI= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 h1:hBSHahWMEgzwRyS6dRpxY0XyjZsHyQ61s084wo5PJe0= @@ -441,6 +456,7 @@ github.com/tidwall/gjson v1.3.5/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJH github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/sjson v1.0.4/go.mod h1:bURseu1nuBkFpIES5cz6zBtjmYeOQmEESshn7VpF15Y= +github.com/tinylib/msgp v1.1.1/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.1.5-pre/go.mod h1:FwP/aQVg39TXzItUBMwnWp9T9gPQnXw4Poh4/oBQZ/0= @@ -513,6 +529,8 @@ golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8ou golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200320220750-118fecf932d8 h1:1+zQlQqEEhUeStBTi653GZAnAuivZq/2hz+Iz+OP7rg= golang.org/x/net v0.0.0-20200320220750-118fecf932d8/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180620175406-ef147856a6dd/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -549,6 +567,8 @@ golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/src/handlers/groups.go b/src/handlers/groups.go index 77d5f17..4eb6c8a 100644 --- a/src/handlers/groups.go +++ b/src/handlers/groups.go @@ -1,6 +1,7 @@ package handlers import ( + "context" iris "github.com/kataras/iris/v12" madmin "github.com/minio/minio/pkg/madmin" resph "github.com/rzrbld/adminio-api/response" @@ -15,7 +16,7 @@ var GrSetStatus = func(ctx iris.Context) { if resph.CheckAuthBeforeRequest(ctx) != false { var status = madmin.GroupStatus(status) - err = madmClnt.SetGroupStatus(group, status) + err = madmClnt.SetGroupStatus(context.Background(), group, status) var res = resph.DefaultResHandler(ctx, err) ctx.JSON(res) } else { @@ -27,7 +28,7 @@ var GrSetDescription = func(ctx iris.Context) { var group = ctx.FormValue("group") if resph.CheckAuthBeforeRequest(ctx) != false { - grp, err := madmClnt.GetGroupDescription(group) + grp, err := madmClnt.GetGroupDescription(context.Background(), group) var res = resph.BodyResHandler(ctx, err, grp) ctx.JSON(res) } else { @@ -47,7 +48,7 @@ var GrUpdateMembers = func(ctx iris.Context) { } if resph.CheckAuthBeforeRequest(ctx) != false { - err = madmClnt.UpdateGroupMembers(gar) + err = madmClnt.UpdateGroupMembers(context.Background(), gar) var res = resph.DefaultResHandler(ctx, err) ctx.JSON(res) } else { @@ -57,7 +58,7 @@ var GrUpdateMembers = func(ctx iris.Context) { } var GrList = func(ctx iris.Context) { - lg, err := madmClnt.ListGroups() + lg, err := madmClnt.ListGroups(context.Background()) var res = resph.BodyResHandler(ctx, err, lg) ctx.JSON(res) } diff --git a/src/handlers/kv.go b/src/handlers/kv.go index f97e08f..e7aa3e6 100644 --- a/src/handlers/kv.go +++ b/src/handlers/kv.go @@ -1,6 +1,7 @@ package handlers import ( + "context" iris "github.com/kataras/iris/v12" resph "github.com/rzrbld/adminio-api/response" ) @@ -8,7 +9,7 @@ import ( var KvGet = func(ctx iris.Context) { var keyString = ctx.FormValue("keyString") - values, err := madmClnt.GetConfigKV(keyString) + values, err := madmClnt.GetConfigKV(context.Background(), keyString) var res = resph.BodyResHandler(ctx, err, values) ctx.JSON(res) } diff --git a/src/handlers/metrics.go b/src/handlers/metrics.go index 667f955..4de55bc 100644 --- a/src/handlers/metrics.go +++ b/src/handlers/metrics.go @@ -1,6 +1,7 @@ package handlers import ( + "context" "log" "time" @@ -31,7 +32,7 @@ var bucketsCount = promauto.NewGauge(prometheus.GaugeOpts{ func RecordMetrics() { go func() { for { - du, err := madmClnt.DataUsageInfo() + du, err := madmClnt.DataUsageInfo(context.Background()) if err != nil { log.Print("Error while getting bucket size metrics from server") } else { diff --git a/src/handlers/policy.go b/src/handlers/policy.go index a52ccb4..2c3376d 100644 --- a/src/handlers/policy.go +++ b/src/handlers/policy.go @@ -1,14 +1,17 @@ package handlers import ( + "context" iris "github.com/kataras/iris/v12" + iampolicy "github.com/minio/minio/pkg/iam/policy" resph "github.com/rzrbld/adminio-api/response" log "log" strconv "strconv" + "strings" ) var PolList = func(ctx iris.Context) { - lp, err := madmClnt.ListCannedPolicies() + lp, err := madmClnt.ListCannedPolicies(context.Background()) var res = resph.BodyResHandler(ctx, err, lp) ctx.JSON(res) } @@ -19,7 +22,10 @@ var PolAdd = func(ctx iris.Context) { p.policyString = ctx.FormValue("policyString") if resph.CheckAuthBeforeRequest(ctx) != false { - err = madmClnt.AddCannedPolicy(p.policyName, p.policyString) + policy, err := iampolicy.ParseConfig(strings.NewReader(p.policyString)) + if err == nil { + err = madmClnt.AddCannedPolicy(context.Background(), p.policyName, policy) + } var res = resph.DefaultResHandler(ctx, err) ctx.JSON(res) } else { @@ -32,7 +38,7 @@ var PolDelete = func(ctx iris.Context) { p.policyName = ctx.FormValue("policyName") if resph.CheckAuthBeforeRequest(ctx) != false { - err = madmClnt.RemoveCannedPolicy(p.policyName) + err = madmClnt.RemoveCannedPolicy(context.Background(), p.policyName) var res = resph.DefaultResHandler(ctx, err) ctx.JSON(res) } else { @@ -54,7 +60,7 @@ var PolSet = func(ctx iris.Context) { } if resph.CheckAuthBeforeRequest(ctx) != false { - err = madmClnt.SetPolicy(p.policyName, p.entityName, isGroupBool) + err = madmClnt.SetPolicy(context.Background(), p.policyName, p.entityName, isGroupBool) var res = resph.DefaultResHandler(ctx, err) ctx.JSON(res) } else { diff --git a/src/handlers/server.go b/src/handlers/server.go index bdb0824..3501eb0 100644 --- a/src/handlers/server.go +++ b/src/handlers/server.go @@ -1,18 +1,19 @@ package handlers import ( + "context" iris "github.com/kataras/iris/v12" resph "github.com/rzrbld/adminio-api/response" ) var ServerInfo = func(ctx iris.Context) { - si, err := madmClnt.ServerInfo() + si, err := madmClnt.ServerInfo(context.Background()) var res = resph.BodyResHandler(ctx, err, si) ctx.JSON(res) } var DiskInfo = func(ctx iris.Context) { - du, err := madmClnt.DataUsageInfo() + du, err := madmClnt.DataUsageInfo(context.Background()) var res = resph.BodyResHandler(ctx, err, du) ctx.JSON(res) } diff --git a/src/handlers/users.go b/src/handlers/users.go index 73b0a6a..f460c0d 100644 --- a/src/handlers/users.go +++ b/src/handlers/users.go @@ -1,6 +1,7 @@ package handlers import ( + "context" iris "github.com/kataras/iris/v12" madmin "github.com/minio/minio/pkg/madmin" resph "github.com/rzrbld/adminio-api/response" @@ -8,7 +9,7 @@ import ( ) var UsrList = func(ctx iris.Context) { - st, err := madmClnt.ListUsers() + st, err := madmClnt.ListUsers(context.Background()) var res = resph.BodyResHandler(ctx, err, st) ctx.JSON(res) } @@ -19,7 +20,7 @@ var UsrSetStats = func(ctx iris.Context) { us.status = madmin.AccountStatus(ctx.FormValue("status")) if resph.CheckAuthBeforeRequest(ctx) != false { - err = madmClnt.SetUserStatus(us.accessKey, us.status) + err = madmClnt.SetUserStatus(context.Background(), us.accessKey, us.status) var res = resph.DefaultResHandler(ctx, err) ctx.JSON(res) } else { @@ -32,7 +33,7 @@ var UsrDelete = func(ctx iris.Context) { user.accessKey = ctx.FormValue("accessKey") if resph.CheckAuthBeforeRequest(ctx) != false { - err = madmClnt.RemoveUser(user.accessKey) + err = madmClnt.RemoveUser(context.Background(), user.accessKey) var res = resph.DefaultResHandler(ctx, err) ctx.JSON(res) } else { @@ -46,7 +47,7 @@ var UsrAdd = func(ctx iris.Context) { user.secretKey = ctx.FormValue("secretKey") if resph.CheckAuthBeforeRequest(ctx) != false { - err = madmClnt.AddUser(user.accessKey, user.secretKey) + err = madmClnt.AddUser(context.Background(), user.accessKey, user.secretKey) var res = resph.DefaultResHandler(ctx, err) ctx.JSON(res) } else { @@ -64,12 +65,12 @@ var UsrCreateExtended = func(ctx iris.Context) { u.secretKey = ctx.FormValue("secretKey") if resph.CheckAuthBeforeRequest(ctx) != false { - err = madmClnt.AddUser(u.accessKey, u.secretKey) + err = madmClnt.AddUser(context.Background(), u.accessKey, u.secretKey) if err != nil { log.Print(err) ctx.JSON(iris.Map{"error": err.Error()}) } else { - err = madmClnt.SetPolicy(p.policyName, p.entityName, false) + err = madmClnt.SetPolicy(context.Background(), p.policyName, p.entityName, false) var res = resph.DefaultResHandler(ctx, err) ctx.JSON(res) } @@ -90,9 +91,9 @@ var UsrSet = func(ctx iris.Context) { if resph.CheckAuthBeforeRequest(ctx) != false { if u.secretKey == "" { - err = madmClnt.SetUserStatus(u.accessKey, us.status) + err = madmClnt.SetUserStatus(context.Background(), u.accessKey, us.status) } else { - err = madmClnt.SetUser(u.accessKey, u.secretKey, us.status) + err = madmClnt.SetUser(context.Background(), u.accessKey, u.secretKey, us.status) } if err != nil { log.Print(err) @@ -102,7 +103,7 @@ var UsrSet = func(ctx iris.Context) { var res = resph.DefaultResHandler(ctx, err) ctx.JSON(res) } else { - err = madmClnt.SetPolicy(p.policyName, u.accessKey, false) + err = madmClnt.SetPolicy(context.Background(), p.policyName, u.accessKey, false) var res = resph.DefaultResHandler(ctx, err) ctx.JSON(res) }