github.com/google/go-github/v32 v32.1.0
github.com/google/uuid v1.2.0
github.com/gorilla/context v1.1.1
+ github.com/gorilla/sessions v1.2.1 // indirect
+ github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.6.8 // indirect
github.com/hashicorp/go-version v1.2.1
github.com/huandu/xstrings v1.3.2
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
github.com/klauspost/compress v1.11.7
github.com/klauspost/pgzip v1.2.5 // indirect
- github.com/lafriks/xormstore v1.3.2
+ github.com/lafriks/xormstore v1.4.0
github.com/lib/pq v1.9.0
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96
github.com/markbates/goth v1.66.1
github.com/mholt/archiver/v3 v3.5.0
github.com/microcosm-cc/bluemonday v1.0.4
github.com/minio/md5-simd v1.1.1 // indirect
- github.com/minio/minio-go/v7 v7.0.7
+ github.com/minio/minio-go/v7 v7.0.9
github.com/mitchellh/go-homedir v1.1.0
github.com/msteinert/pam v0.0.0-20200810204841-913b8f8cdf8b
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/pierrec/lz4/v4 v4.1.1 // indirect
github.com/pkg/errors v0.9.1
github.com/pquerna/otp v1.3.0
- github.com/prometheus/client_golang v1.8.0
+ github.com/prometheus/client_golang v1.9.0
github.com/quasoft/websspi v1.0.0
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sergi/go-diff v1.1.0
github.com/unrolled/render v1.0.3
github.com/urfave/cli v1.22.5
github.com/willf/bitset v1.1.11 // indirect
- github.com/xanzy/go-gitlab v0.42.0
+ github.com/xanzy/go-gitlab v0.44.0
github.com/yohcop/openid-go v1.0.0
- github.com/yuin/goldmark v1.3.1
+ github.com/yuin/goldmark v1.3.2
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691
github.com/yuin/goldmark-meta v1.0.0
go.jolheiser.com/hcaptcha v0.0.4
go.jolheiser.com/pwn v0.0.3
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/net v0.0.0-20210119194325-5f4716e94777
- golang.org/x/oauth2 v0.0.0-20210126194326-f9ce19ea3013
+ golang.org/x/oauth2 v0.0.0-20210210192628-66670185b0cd
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
golang.org/x/text v0.3.5
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
gopkg.in/yaml.v2 v2.4.0
mvdan.cc/xurls/v2 v2.2.0
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
- xorm.io/builder v0.3.7
- xorm.io/xorm v1.0.6
+ xorm.io/builder v0.3.9
+ xorm.io/xorm v1.0.7
)
replace github.com/hashicorp/go-version => github.com/6543/go-version v1.2.4
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
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.29/go.mod h1:W40334L7FMC5JKWldsTWbdGjLo0RxUKK73K+TuPxX30=
github.com/chris-ramon/douceur v0.2.0 h1:IDMEdxlEUUBYBKE4z/mJnFyVXox+MjuEVDJNN27glkU=
github.com/chris-ramon/douceur v0.2.0/go.mod h1:wDW5xjJdeoMm1mRt4sD4c/LbF/mWdEpRXQKjTR8nIBE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM=
-github.com/denisenkom/go-mssqldb v0.0.0-20190924004331-208c0a498538/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzqk8QCaRC4os14xoKDdbHqqlJtJA0oc1ZAjg=
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/ethantkoenig/rupture v1.0.0 h1:gPInt1N30UErGNzd8t5js5Qbnpjcd1l6yU2MCrJxIe8=
github.com/ethantkoenig/rupture v1.0.0/go.mod h1:GyE9QabHfxA6ch0NZgwsHopRbOLcYjUr9g4FTJmq0WM=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
-github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
-github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
github.com/go-swagger/scan-repo-boundary v0.0.0-20180623220736-973b3573c013/go.mod h1:b65mBPzqzZWxOZGxSWrqs4GInLIn+u99Q9q7p+GKni0=
github.com/go-testfixtures/testfixtures/v3 v3.4.1 h1:Qz9y0wUOXPHzKhK6C79A/menChtEu/xd0Dn5ngVyMD0=
github.com/go-testfixtures/testfixtures/v3 v3.4.1/go.mod h1:P4L3WxgOsCLbAeUC50qX5rdj1ULZfUMqgCbqah3OH5U=
-github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg=
github.com/gorilla/sessions v1.1.1/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w=
github.com/gorilla/sessions v1.2.0 h1:S7P+1Hm5V/AT9cjEcUD5uDaQSX0OE577aCXgoaKpYbQ=
github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
+github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI=
+github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
+github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
+github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
-github.com/lafriks/xormstore v1.3.2 h1:hqi3F8s/B4rz8GuEZZDuHuOxRjeuOpEI/cC7vcnWwH4=
-github.com/lafriks/xormstore v1.3.2/go.mod h1:mVNIwIa25QIr8rfR7YlVjrqN/apswHkVdtLCyVYBzXw=
+github.com/lafriks/xormstore v1.4.0 h1:DX1yS9WUhVY+MTHGaOJ2tDVpwL1w/247iro5KR0BQEQ=
+github.com/lafriks/xormstore v1.4.0/go.mod h1:5a3wJ6Ro0TFJmJcH1ywtHO/fBEIWYfSfO4WTYmM7qEk=
github.com/lestrrat-go/jwx v0.9.0/go.mod h1:iEoxlYfZjvoGpuWwxUz+eR5e6KTJGsaRcy/YNA/UnBk=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
-github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
-github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
-github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
-github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg=
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
github.com/minio/md5-simd v1.1.1 h1:9ojcLbuZ4gXbB2sX53MKn8JUZ0sB/2wfwsEcRw+I08U=
github.com/minio/md5-simd v1.1.1/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
-github.com/minio/minio-go/v7 v7.0.7 h1:Qld/xb8C1Pwbu0jU46xAceyn9xXKCMW+3XfNbpmTB70=
-github.com/minio/minio-go/v7 v7.0.7/go.mod h1:pEZBUa+L2m9oECoIA6IcSK8bv/qggtQVLovjeKK5jYc=
+github.com/minio/minio-go/v7 v7.0.9 h1:v+RS2/dpRq+XaarlZItHd3MVjjQcN2noRn4HxmVdmg4=
+github.com/minio/minio-go/v7 v7.0.9/go.mod h1:td4gW1ldOsj1PbSNS+WYK43j+P1XVhX/8W8awaYlBFo=
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/sio v0.2.1/go.mod h1:8b0yPp2avGThviy/+OCJBI6OMpvxoUuiLvE6F1lebhw=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
-github.com/prometheus/client_golang v1.8.0 h1:zvJNkoCFAnYFNC24FV8nW4JdRJ3GIFcLbg65lL/JDcw=
-github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM=
+github.com/prometheus/client_golang v1.9.0 h1:Rrch9mh17XcxvEu9D9DEpb4isxjGBtcevQjKvxPRQIU=
+github.com/prometheus/client_golang v1.9.0/go.mod h1:FqZLKOZnGdFAhOK4nqGHa7D66IdsO+O441Eve7ptJDU=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
-github.com/prometheus/common v0.14.0 h1:RHRyE8UocrbjU+6UvRzwi6HjiDfxrrBU91TtbKzkGp4=
-github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
+github.com/prometheus/common v0.15.0 h1:4fgOnadei3EZvgRwxJ7RMpG1k1pOZth5Pc13tyspaKM=
+github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
-github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v1.1.1 h1:T/YLemO5Yp7KPzS+lVtu+WsHn8yoSwTfItdAd1r3cck=
github.com/smartystreets/assertions v1.1.1/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
-github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
github.com/willf/bitset v1.1.11 h1:N7Z7E9UvjW+sGsEl7k/SJrvY2reP1A07MrGuCjIOjRE=
github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI=
-github.com/xanzy/go-gitlab v0.42.0 h1:daNdMFnw2FG+lDRBcX+YLnKbqIKMdefVyVztMHwsFhk=
-github.com/xanzy/go-gitlab v0.42.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug=
+github.com/xanzy/go-gitlab v0.44.0 h1:cEiGhqu7EpFGuei2a2etAwB+x6403E5CvpLn35y+GPs=
+github.com/xanzy/go-gitlab v0.44.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug=
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
-github.com/yuin/goldmark v1.3.1 h1:eVwehsLsZlCJCwXyGLgg+Q4iFWE/eTIMG0e8waCmm/I=
-github.com/yuin/goldmark v1.3.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+github.com/yuin/goldmark v1.3.2 h1:YjHC5TgyMmHpicTgEqDN0Q96Xo8K6tLXPnmNOHXCgs0=
+github.com/yuin/goldmark v1.3.2/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691 h1:VWSxtAiQNh3zgHJpdpkpVYjTPqRE3P6UZCOPa1nRDio=
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691/go.mod h1:YLF3kDffRfUH/bTxOxHhV6lxwIB3Vfj91rEwNMS9MXo=
github.com/yuin/goldmark-meta v1.0.0 h1:ScsatUIT2gFS6azqzLGUjgOnELsBOxMXerM3ogdJhAM=
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
-golang.org/x/oauth2 v0.0.0-20210126194326-f9ce19ea3013 h1:55H5j7lotzuFCEOKDsMch+fRNUQ9DgtyHOUP31FNqKc=
-golang.org/x/oauth2 v0.0.0-20210126194326-f9ce19ea3013/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20210210192628-66670185b0cd h1:2arJsLyTCJGek+eeptQ3z49Rqndm0f+zvvpwNIXWNIA=
+golang.org/x/oauth2 v0.0.0-20210210192628-66670185b0cd/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
-google.golang.org/appengine v1.6.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
-google.golang.org/appengine v1.6.4/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 h1:mUcz5b3FJbP5Cvdq7Khzn6J9OCUQJaBwgBkCR+MOwSs=
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1:FJGmPh3vz9jSos1L/F91iAgnC/aejc0wIIrF2ZwJxdY=
-xorm.io/builder v0.3.6/go.mod h1:LEFAPISnRzG+zxaxj2vPicRwz67BdhFreKg8yv8/TgU=
xorm.io/builder v0.3.7 h1:2pETdKRK+2QG4mLX4oODHEhn5Z8j1m8sXa7jfu+/SZI=
xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
-xorm.io/core v0.7.2 h1:mEO22A2Z7a3fPaZMk6gKL/jMD80iiyNwRrX5HOv3XLw=
-xorm.io/core v0.7.2/go.mod h1:jJfd0UAEzZ4t87nbQYtVjmqpIODugN6PD2D9E+dJvdM=
-xorm.io/xorm v0.8.0/go.mod h1:ZkJLEYLoVyg7amJK/5r779bHyzs2AU8f8VMiP6BM7uY=
+xorm.io/builder v0.3.9 h1:Sd65/LdWyO7LR8+Cbd+e7mm3sK/7U9k0jS3999IDHMc=
+xorm.io/builder v0.3.9/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
xorm.io/xorm v1.0.6 h1:7eco1c8QUpGz+3dztpLDj9gU1bTiQdFC/KtmPaLxUJk=
xorm.io/xorm v1.0.6/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4=
+xorm.io/xorm v1.0.7 h1:26yBTDVI+CfQpVz2Y88fISh+aiJXIPP4eNoTJlwzsC4=
+xorm.io/xorm v1.0.7/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4=
session.Values["foo"] = "bar"
session.Values[42] = 43
// Save it before we write to the response/return from the handler.
- session.Save(r, w)
+ err := session.Save(r, w)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
}
```
- [github.com/EnumApps/clustersqlstore](https://github.com/EnumApps/clustersqlstore) - MySQL Cluster
- [github.com/antonlindstrom/pgstore](https://github.com/antonlindstrom/pgstore) - PostgreSQL
- [github.com/boj/redistore](https://github.com/boj/redistore) - Redis
+- [github.com/rbcervilla/redisstore](https://github.com/rbcervilla/redisstore) - Redis (Single, Sentinel, Cluster)
- [github.com/boj/rethinkstore](https://github.com/boj/rethinkstore) - RethinkDB
- [github.com/boj/riakstore](https://github.com/boj/riakstore) - Riak
- [github.com/michaeljs1990/sqlitestore](https://github.com/michaeljs1990/sqlitestore) - SQLite
- [github.com/gernest/qlstore](https://github.com/gernest/qlstore) - ql
- [github.com/quasoft/memstore](https://github.com/quasoft/memstore) - In-memory implementation for use in unit tests
- [github.com/lafriks/xormstore](https://github.com/lafriks/xormstore) - XORM (MySQL, PostgreSQL, SQLite, Microsoft SQL Server, TiDB)
+- [github.com/GoogleCloudPlatform/firestore-gorilla-sessions](https://github.com/GoogleCloudPlatform/firestore-gorilla-sessions) - Cloud Firestore
+- [github.com/stephenafamo/crdbstore](https://github.com/stephenafamo/crdbstore) - CockroachDB
## License
// environmental variable, or flag (or both), and don't accidentally commit it
// alongside your code. Ensure your key is sufficiently random - i.e. use Go's
// crypto/rand or securecookie.GenerateRandomKey(32) and persist the result.
- var store = sessions.NewCookieStore(os.Getenv("SESSION_KEY"))
+ // Ensure SESSION_KEY exists in the environment, or sessions will fail.
+ var store = sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY")))
func MyHandler(w http.ResponseWriter, r *http.Request) {
// Get a session. Get() always returns a session, even if empty.
session.Values["foo"] = "bar"
session.Values[42] = 43
// Save it before we write to the response/return from the handler.
- session.Save(r, w)
+ err = session.Save(r, w)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
}
First we initialize a session store calling NewCookieStore() and passing a
// Set a new flash.
session.AddFlash("Hello, flash messages world!")
}
- session.Save(r, w)
+ err = session.Save(r, w)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
}
Flash messages are useful to set information to be read after a redirection,
session2, _ := store.Get(r, "session-two")
session2.Values[42] = 43
// Save all sessions.
- sessions.Save(r, w)
+ err = sessions.Save(r, w)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
}
This is possible because when we call Get() from a session store, it adds the
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
+ ForceAttemptHTTP2: true,
MaxIdleConnsPerHost: runtime.GOMAXPROCS(0) + 1,
}
return transport
module github.com/hashicorp/go-cleanhttp
+
+go 1.13
module github.com/lafriks/xormstore
-go 1.11
+go 1.13
require (
- github.com/denisenkom/go-mssqldb v0.0.0-20190924004331-208c0a498538
- github.com/go-sql-driver/mysql v1.4.1
+ github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc
+ github.com/go-sql-driver/mysql v1.5.0
+ github.com/golang/protobuf v1.3.1 // indirect
github.com/gorilla/context v1.1.1
github.com/gorilla/securecookie v1.1.1
github.com/gorilla/sessions v1.2.0
- github.com/lib/pq v1.2.0
- github.com/mattn/go-sqlite3 v1.11.0
+ github.com/kr/pretty v0.2.1 // indirect
+ github.com/lib/pq v1.7.0
+ github.com/mattn/go-sqlite3 v1.14.0
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad // indirect
- google.golang.org/appengine v1.6.4 // indirect
+ golang.org/x/text v0.3.2 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
- xorm.io/core v0.7.2
- xorm.io/xorm v0.8.0
+ xorm.io/xorm v1.0.6
)
-cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
-github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
-github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
-github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
-github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
-github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
-github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
-github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
+gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
+github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
+github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
-github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM=
-github.com/denisenkom/go-mssqldb v0.0.0-20190924004331-208c0a498538 h1:bpWCJ5MddHsv4Xtl3azkK89mZzd/vvut32mvAnKbyUA=
-github.com/denisenkom/go-mssqldb v0.0.0-20190924004331-208c0a498538/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
-github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
-github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
-github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
+github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzqk8QCaRC4os14xoKDdbHqqlJtJA0oc1ZAjg=
+github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
+github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
-github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
-github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
-github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
-github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
-github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
-github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=
-github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
-github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
-github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
+github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
+github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
-github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
-github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
-github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
-github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
-github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
-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/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
-github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/sessions v1.2.0 h1:S7P+1Hm5V/AT9cjEcUD5uDaQSX0OE577aCXgoaKpYbQ=
github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
-github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
-github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
-github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
-github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
-github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
-github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
-github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
-github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
+github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
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/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
-github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
-github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
-github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
-github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q=
-github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
-github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
-github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
+github.com/lib/pq v1.7.0 h1:h93mCPfUSkaul3Ka/VG8uZdmW1uMHDGxzu0NWHuJmHY=
+github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
+github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
+github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
-github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
-github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
-github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
-github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
-github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
-github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
-github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
-github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
-github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
-github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
-github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
+github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
-go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
-golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad h1:5E5raQxcv+6CZ11RrBYQe5WRbUIWpScjh0kvHZkZIrQ=
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
-golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
-golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
-golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
-golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
-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=
+golang.org/x/net v0.0.0-20200202094626-16171245cfb2/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/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/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.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
-golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
-golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
-golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
-golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
-google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
-google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
-google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
-google.golang.org/appengine v1.6.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
-google.golang.org/appengine v1.6.4 h1:WiKh4+/eMB2HaY7QhCfW/R7MuRAoA8QMCSJA6jP5/fo=
-google.golang.org/appengine v1.6.4/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
-google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
-google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
-google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
-gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-xorm.io/builder v0.3.6 h1:ha28mQ2M+TFx96Hxo+iq6tQgnkC9IZkM6D8w9sKHHF8=
-xorm.io/builder v0.3.6/go.mod h1:LEFAPISnRzG+zxaxj2vPicRwz67BdhFreKg8yv8/TgU=
-xorm.io/core v0.7.2 h1:mEO22A2Z7a3fPaZMk6gKL/jMD80iiyNwRrX5HOv3XLw=
-xorm.io/core v0.7.2/go.mod h1:jJfd0UAEzZ4t87nbQYtVjmqpIODugN6PD2D9E+dJvdM=
-xorm.io/xorm v0.8.0 h1:iALxgJrX8O00f8Jk22GbZwPmxJNgssV5Mv4uc2HL9PM=
-xorm.io/xorm v0.8.0/go.mod h1:ZkJLEYLoVyg7amJK/5r779bHyzs2AU8f8VMiP6BM7uY=
+xorm.io/builder v0.3.7 h1:2pETdKRK+2QG4mLX4oODHEhn5Z8j1m8sXa7jfu+/SZI=
+xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
+xorm.io/xorm v1.0.6 h1:7eco1c8QUpGz+3dztpLDj9gU1bTiQdFC/KtmPaLxUJk=
+xorm.io/xorm v1.0.6/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4=
// Low level implementation of CopyObject API, supports only upto 5GiB worth of copy.
func (c Client) copyObjectDo(ctx context.Context, srcBucket, srcObject, destBucket, destObject string,
- metadata map[string]string, dstOpts PutObjectOptions) (ObjectInfo, error) {
+ metadata map[string]string, srcOpts CopySrcOptions, dstOpts PutObjectOptions) (ObjectInfo, error) {
// Build headers.
headers := make(http.Header)
// Set the source header
headers.Set("x-amz-copy-source", s3utils.EncodePath(srcBucket+"/"+srcObject))
-
+ if srcOpts.VersionID != "" {
+ headers.Set("x-amz-copy-source", s3utils.EncodePath(srcBucket+"/"+srcObject)+"?versionId="+srcOpts.VersionID)
+ }
// Send upload-part-copy request
resp, err := c.executeMethod(ctx, http.MethodPut, reqMetadata)
defer closeResponse(resp)
--- /dev/null
+/*
+ * MinIO Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2017, 2018 MinIO, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package minio
+
+import (
+ "context"
+ "io"
+ "io/ioutil"
+ "net/http"
+)
+
+// CopyObject - copy a source object into a new object
+func (c Client) CopyObject(ctx context.Context, dst CopyDestOptions, src CopySrcOptions) (UploadInfo, error) {
+ if err := src.validate(); err != nil {
+ return UploadInfo{}, err
+ }
+
+ if err := dst.validate(); err != nil {
+ return UploadInfo{}, err
+ }
+
+ header := make(http.Header)
+ dst.Marshal(header)
+ src.Marshal(header)
+
+ resp, err := c.executeMethod(ctx, http.MethodPut, requestMetadata{
+ bucketName: dst.Bucket,
+ objectName: dst.Object,
+ customHeader: header,
+ })
+ if err != nil {
+ return UploadInfo{}, err
+ }
+ defer closeResponse(resp)
+
+ if resp.StatusCode != http.StatusOK {
+ return UploadInfo{}, httpRespToErrorResponse(resp, dst.Bucket, dst.Object)
+ }
+
+ // Update the progress properly after successful copy.
+ if dst.Progress != nil {
+ io.Copy(ioutil.Discard, io.LimitReader(dst.Progress, dst.Size))
+ }
+
+ cpObjRes := copyObjectResult{}
+ if err = xmlDecoder(resp.Body, &cpObjRes); err != nil {
+ return UploadInfo{}, err
+ }
+
+ // extract lifecycle expiry date and rule ID
+ expTime, ruleID := amzExpirationToExpiryDateRuleID(resp.Header.Get(amzExpiration))
+
+ return UploadInfo{
+ Bucket: dst.Bucket,
+ Key: dst.Object,
+ LastModified: cpObjRes.LastModified,
+ ETag: trimEtag(resp.Header.Get("ETag")),
+ VersionID: resp.Header.Get(amzVersionID),
+ Expiration: expTime,
+ ExpirationRuleID: ruleID,
+ }, nil
+}
// reached our EOF.
size, err := readFull(httpReader, req.Buffer)
if size > 0 && err == io.ErrUnexpectedEOF {
- // If an EOF happens after reading some but not
- // all the bytes ReadFull returns ErrUnexpectedEOF
- err = io.EOF
+ if int64(size) < objectInfo.Size {
+ // In situations when returned size
+ // is less than the expected content
+ // length set by the server, make sure
+ // we return io.ErrUnexpectedEOF
+ err = io.ErrUnexpectedEOF
+ } else {
+ // If an EOF happens after reading some but not
+ // all the bytes ReadFull returns ErrUnexpectedEOF
+ err = io.EOF
+ }
+ } else if size == 0 && err == io.EOF && objectInfo.Size > 0 {
+ // Special cases when server writes more data
+ // than the content-length, net/http response
+ // body returns an error, instead of converting
+ // it to io.EOF - return unexpected EOF.
+ err = io.ErrUnexpectedEOF
}
// Send back the first response.
resCh <- getResponse{
//AdvancedGetOptions for internal use by MinIO server - not intended for client use.
type AdvancedGetOptions struct {
ReplicationDeleteMarker bool
- ReplicationProxyRequest bool
+ ReplicationProxyRequest string
}
// GetObjectOptions are used to specify additional headers or options
}
// this header is set for active-active replication scenario where GET/HEAD
// to site A is proxy'd to site B if object/version missing on site A.
- if o.Internal.ReplicationProxyRequest {
- headers.Set(minIOBucketReplicationProxyRequest, "true")
+ if o.Internal.ReplicationProxyRequest != "" {
+ headers.Set(minIOBucketReplicationProxyRequest, o.Internal.ReplicationProxyRequest)
}
return headers
}
+++ /dev/null
-/*
- * MinIO Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017, 2018 MinIO, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package minio
-
-import (
- "context"
- "io"
- "io/ioutil"
- "net/http"
-)
-
-// CopyObject - copy a source object into a new object
-func (c Client) CopyObject(ctx context.Context, dst CopyDestOptions, src CopySrcOptions) (UploadInfo, error) {
- if err := src.validate(); err != nil {
- return UploadInfo{}, err
- }
-
- if err := dst.validate(); err != nil {
- return UploadInfo{}, err
- }
-
- header := make(http.Header)
- dst.Marshal(header)
- src.Marshal(header)
-
- resp, err := c.executeMethod(ctx, http.MethodPut, requestMetadata{
- bucketName: dst.Bucket,
- objectName: dst.Object,
- customHeader: header,
- })
- if err != nil {
- return UploadInfo{}, err
- }
- defer closeResponse(resp)
-
- if resp.StatusCode != http.StatusOK {
- return UploadInfo{}, httpRespToErrorResponse(resp, dst.Bucket, dst.Object)
- }
-
- // Update the progress properly after successful copy.
- if dst.Progress != nil {
- io.Copy(ioutil.Discard, io.LimitReader(dst.Progress, dst.Size))
- }
-
- cpObjRes := copyObjectResult{}
- if err = xmlDecoder(resp.Body, &cpObjRes); err != nil {
- return UploadInfo{}, err
- }
-
- // extract lifecycle expiry date and rule ID
- expTime, ruleID := amzExpirationToExpiryDateRuleID(resp.Header.Get(amzExpiration))
-
- return UploadInfo{
- Bucket: dst.Bucket,
- Key: dst.Object,
- LastModified: cpObjRes.LastModified,
- ETag: trimEtag(resp.Header.Get("ETag")),
- VersionID: resp.Header.Get(amzVersionID),
- Expiration: expTime,
- ExpirationRuleID: ruleID,
- }, nil
-}
// Global constants.
const (
libraryName = "minio-go"
- libraryVersion = "v7.0.7"
+ libraryVersion = "v7.0.9"
)
// User Agent should always following the below style.
}
// CopyObject - copies an object from source object to destination object on server side.
-func (c Core) CopyObject(ctx context.Context, sourceBucket, sourceObject, destBucket, destObject string, metadata map[string]string, dstOpts PutObjectOptions) (ObjectInfo, error) {
- return c.copyObjectDo(ctx, sourceBucket, sourceObject, destBucket, destObject, metadata, dstOpts)
+func (c Core) CopyObject(ctx context.Context, sourceBucket, sourceObject, destBucket, destObject string, metadata map[string]string, srcOpts CopySrcOptions, dstOpts PutObjectOptions) (ObjectInfo, error) {
+ return c.copyObjectDo(ctx, sourceBucket, sourceObject, destBucket, destObject, metadata, srcOpts, dstOpts)
}
// CopyObjectPart - creates a part in a multipart upload by copying (a
go 1.12
require (
- github.com/cheggaaa/pb v1.0.29 // indirect
- github.com/dustin/go-humanize v1.0.0 // indirect
github.com/google/uuid v1.1.1
github.com/json-iterator/go v1.1.10
github.com/klauspost/cpuid v1.3.1 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/minio/md5-simd v1.1.0
github.com/minio/sha256-simd v0.1.1
- github.com/minio/sio v0.2.1 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/rs/xid v1.2.1
- github.com/sirupsen/logrus v1.7.0 // indirect
- github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect
+ github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.4.0 // indirect
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
golang.org/x/net v0.0.0-20200707034311-ab3426394381
-github.com/cheggaaa/pb v1.0.29 h1:FckUN5ngEk2LpvuG0fw1GEFx6LtyY2pWI/Z2QgCnEYo=
-github.com/cheggaaa/pb v1.0.29/go.mod h1:W40334L7FMC5JKWldsTWbdGjLo0RxUKK73K+TuPxX30=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
-github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
-github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
-github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
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/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
-github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
-github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
-github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
-github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
-github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
-github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4=
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
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/sio v0.2.1 h1:NjzKiIMSMcHediVQR0AFVx2tp7Wxh9tKPfDI3kH7aHQ=
-github.com/minio/sio v0.2.1/go.mod h1:8b0yPp2avGThviy/+OCJBI6OMpvxoUuiLvE6F1lebhw=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rs/xid v1.2.1 h1:mhH9Nq+C1fY2l1XIpgxIiUOfNpRBYH1kKcr+qfKgjRc=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
-github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
-github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
-github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs=
-github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
+github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA0mnthyA/nZ00AqCUo7vHg=
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
// If Credentials.Expire() was called the credentials Value will be force
// expired, and the next call to Get() will cause them to be refreshed.
func (c *Credentials) Get() (Value, error) {
+ if c == nil {
+ return Value{}, nil
+ }
+
c.Lock()
defer c.Unlock()
"net/url"
"os"
"path"
+ "strings"
"time"
jsoniter "github.com/json-iterator/go"
case len(os.Getenv("AWS_WEB_IDENTITY_TOKEN_FILE")) > 0:
if len(endpoint) == 0 {
if len(os.Getenv("AWS_REGION")) > 0 {
- endpoint = "https://sts." + os.Getenv("AWS_REGION") + ".amazonaws.com"
+ if strings.HasPrefix(os.Getenv("AWS_REGION"), "cn-") {
+ endpoint = "https://sts." + os.Getenv("AWS_REGION") + ".amazonaws.com.cn"
+ } else {
+ endpoint = "https://sts." + os.Getenv("AWS_REGION") + ".amazonaws.com"
+ }
} else {
endpoint = defaultSTSRoleEndpoint
}
return e.EncodeElement(expireDeleteMarkerWrapper(b), startElement)
}
+// IsEnabled returns true if the auto delete-marker expiration is enabled
+func (b ExpireDeleteMarker) IsEnabled() bool {
+ return bool(b)
+}
+
// Expiration structure - expiration details of lifecycle configuration
type Expiration struct {
XMLName xml.Name `xml:"Expiration,omitempty" json:"-"`
return e.Date.Time.IsZero()
}
+// IsDeleteMarkerExpirationEnabled returns true if the auto-expiration of delete marker is enabled
+func (e Expiration) IsDeleteMarkerExpirationEnabled() bool {
+ return e.DeleteMarker.IsEnabled()
+}
+
// IsNull returns true if both date and days fields are null
func (e Expiration) IsNull() bool {
- return e.IsDaysNull() && e.IsDateNull()
+ return e.IsDaysNull() && e.IsDateNull() && !e.IsDeleteMarkerExpirationEnabled()
}
// MarshalXML is expiration is non null
// amazonS3ChinaHost - regular expression used to determine if the arg is s3 china host.
var amazonS3ChinaHost = regexp.MustCompile(`^s3.(cn.*?).amazonaws.com.cn$`)
+// amazonS3ChinaHostDualStack - regular expression used to determine if the arg is s3 china host dualstack.
+var amazonS3ChinaHostDualStack = regexp.MustCompile(`^s3.dualstack.(cn.*?).amazonaws.com.cn$`)
+
// Regular expression used to determine if the arg is elb host.
var elbAmazonRegex = regexp.MustCompile(`elb(.*?).amazonaws.com$`)
if len(parts) > 1 {
return parts[1]
}
+ parts = amazonS3ChinaHostDualStack.FindStringSubmatch(endpointURL.Host)
+ if len(parts) > 1 {
+ return parts[1]
+ }
parts = amazonS3HostDot.FindStringSubmatch(endpointURL.Host)
if len(parts) > 1 {
return parts[1]
}
func (tags tagSet) String() string {
- s := []string{}
+ vals := make(url.Values)
for key, value := range tags.tagMap {
- s = append(s, key+"="+value)
+ vals.Set(key, value)
}
-
- return strings.Join(s, "&")
+ return vals.Encode()
}
func (tags *tagSet) remove(key string) {
"sa-east-1": "s3.dualstack.sa-east-1.amazonaws.com",
"us-gov-west-1": "s3.dualstack.us-gov-west-1.amazonaws.com",
"us-gov-east-1": "s3.dualstack.us-gov-east-1.amazonaws.com",
- "cn-north-1": "s3.cn-north-1.amazonaws.com.cn",
- "cn-northwest-1": "s3.cn-northwest-1.amazonaws.com.cn",
+ "cn-north-1": "s3.dualstack.cn-north-1.amazonaws.com.cn",
+ "cn-northwest-1": "s3.dualstack.cn-northwest-1.amazonaws.com.cn",
}
// getS3Endpoint get Amazon S3 endpoint based on the bucket location.
+++ /dev/null
-checks = ["all", "-ST1005", "-ST1017", "-SA9004", "-ST1000", "-S1021"]
\ No newline at end of file
import (
"errors"
+ "fmt"
+ "io/ioutil"
"os"
+ "strconv"
+ "strings"
)
type processCollector struct {
}
ch <- NewInvalidMetric(desc, err)
}
+
+// NewPidFileFn returns a function that retrieves a pid from the specified file.
+// It is meant to be used for the PidFn field in ProcessCollectorOpts.
+func NewPidFileFn(pidFilePath string) func() (int, error) {
+ return func() (int, error) {
+ content, err := ioutil.ReadFile(pidFilePath)
+ if err != nil {
+ return 0, fmt.Errorf("can't read pid file %q: %+v", pidFilePath, err)
+ }
+ pid, err := strconv.Atoi(strings.TrimSpace(string(content)))
+ if err != nil {
+ return 0, fmt.Errorf("can't parse pid file %q: %+v", pidFilePath, err)
+ }
+
+ return pid, nil
+ }
+}
inFlightSem = make(chan struct{}, opts.MaxRequestsInFlight)
}
if opts.Registry != nil {
- // Initialize all possibilites that can occur below.
+ // Initialize all possibilities that can occur below.
errCnt.WithLabelValues("gathering")
errCnt.WithLabelValues("encoding")
if err := opts.Registry.Register(errCnt); err != nil {
// HandlerOpts specifies options how to serve metrics via an http.Handler. The
// zero value of HandlerOpts is a reasonable default.
type HandlerOpts struct {
- // ErrorLog specifies an optional logger for errors collecting and
- // serving metrics. If nil, errors are not logged at all.
+ // ErrorLog specifies an optional Logger for errors collecting and
+ // serving metrics. If nil, errors are not logged at all. Note that the
+ // type of a reported error is often prometheus.MultiError, which
+ // formats into a multi-line error string. If you want to avoid the
+ // latter, create a Logger implementation that detects a
+ // prometheus.MultiError and formats the contained errors into one line.
ErrorLog Logger
// ErrorHandling defines how errors are handled. Note that errors are
// logged regardless of the configured ErrorHandling provided ErrorLog
// InstrumentHandlerDuration is a middleware that wraps the provided
// http.Handler to observe the request duration with the provided ObserverVec.
-// The ObserverVec must have zero, one, or two non-const non-curried labels. For
-// those, the only allowed label names are "code" and "method". The function
-// panics otherwise. The Observe method of the Observer in the ObserverVec is
-// called with the request duration in seconds. Partitioning happens by HTTP
-// status code and/or HTTP method if the respective instance label names are
-// present in the ObserverVec. For unpartitioned observations, use an
-// ObserverVec with zero labels. Note that partitioning of Histograms is
-// expensive and should be used judiciously.
+// The ObserverVec must have valid metric and label names and must have zero,
+// one, or two non-const non-curried labels. For those, the only allowed label
+// names are "code" and "method". The function panics otherwise. The Observe
+// method of the Observer in the ObserverVec is called with the request duration
+// in seconds. Partitioning happens by HTTP status code and/or HTTP method if
+// the respective instance label names are present in the ObserverVec. For
+// unpartitioned observations, use an ObserverVec with zero labels. Note that
+// partitioning of Histograms is expensive and should be used judiciously.
//
// If the wrapped Handler does not set a status code, a status code of 200 is assumed.
//
}
// InstrumentHandlerCounter is a middleware that wraps the provided http.Handler
-// to observe the request result with the provided CounterVec. The CounterVec
-// must have zero, one, or two non-const non-curried labels. For those, the only
-// allowed label names are "code" and "method". The function panics
-// otherwise. Partitioning of the CounterVec happens by HTTP status code and/or
-// HTTP method if the respective instance label names are present in the
-// CounterVec. For unpartitioned counting, use a CounterVec with zero labels.
+// to observe the request result with the provided CounterVec. The CounterVec
+// must have valid metric and label names and must have zero, one, or two
+// non-const non-curried labels. For those, the only allowed label names are
+// "code" and "method". The function panics otherwise. Partitioning of the
+// CounterVec happens by HTTP status code and/or HTTP method if the respective
+// instance label names are present in the CounterVec. For unpartitioned
+// counting, use a CounterVec with zero labels.
//
// If the wrapped Handler does not set a status code, a status code of 200 is assumed.
//
// InstrumentHandlerTimeToWriteHeader is a middleware that wraps the provided
// http.Handler to observe with the provided ObserverVec the request duration
-// until the response headers are written. The ObserverVec must have zero, one,
-// or two non-const non-curried labels. For those, the only allowed label names
-// are "code" and "method". The function panics otherwise. The Observe method of
-// the Observer in the ObserverVec is called with the request duration in
-// seconds. Partitioning happens by HTTP status code and/or HTTP method if the
-// respective instance label names are present in the ObserverVec. For
-// unpartitioned observations, use an ObserverVec with zero labels. Note that
-// partitioning of Histograms is expensive and should be used judiciously.
+// until the response headers are written. The ObserverVec must have valid
+// metric and label names and must have zero, one, or two non-const non-curried
+// labels. For those, the only allowed label names are "code" and "method". The
+// function panics otherwise. The Observe method of the Observer in the
+// ObserverVec is called with the request duration in seconds. Partitioning
+// happens by HTTP status code and/or HTTP method if the respective instance
+// label names are present in the ObserverVec. For unpartitioned observations,
+// use an ObserverVec with zero labels. Note that partitioning of Histograms is
+// expensive and should be used judiciously.
//
// If the wrapped Handler panics before calling WriteHeader, no value is
// reported.
}
// InstrumentHandlerRequestSize is a middleware that wraps the provided
-// http.Handler to observe the request size with the provided ObserverVec. The
-// ObserverVec must have zero, one, or two non-const non-curried labels. For
-// those, the only allowed label names are "code" and "method". The function
-// panics otherwise. The Observe method of the Observer in the ObserverVec is
-// called with the request size in bytes. Partitioning happens by HTTP status
-// code and/or HTTP method if the respective instance label names are present in
-// the ObserverVec. For unpartitioned observations, use an ObserverVec with zero
-// labels. Note that partitioning of Histograms is expensive and should be used
-// judiciously.
+// http.Handler to observe the request size with the provided ObserverVec. The
+// ObserverVec must have valid metric and label names and must have zero, one,
+// or two non-const non-curried labels. For those, the only allowed label names
+// are "code" and "method". The function panics otherwise. The Observe method of
+// the Observer in the ObserverVec is called with the request size in
+// bytes. Partitioning happens by HTTP status code and/or HTTP method if the
+// respective instance label names are present in the ObserverVec. For
+// unpartitioned observations, use an ObserverVec with zero labels. Note that
+// partitioning of Histograms is expensive and should be used judiciously.
//
// If the wrapped Handler does not set a status code, a status code of 200 is assumed.
//
}
// InstrumentHandlerResponseSize is a middleware that wraps the provided
-// http.Handler to observe the response size with the provided ObserverVec. The
-// ObserverVec must have zero, one, or two non-const non-curried labels. For
-// those, the only allowed label names are "code" and "method". The function
-// panics otherwise. The Observe method of the Observer in the ObserverVec is
-// called with the response size in bytes. Partitioning happens by HTTP status
-// code and/or HTTP method if the respective instance label names are present in
-// the ObserverVec. For unpartitioned observations, use an ObserverVec with zero
-// labels. Note that partitioning of Histograms is expensive and should be used
-// judiciously.
+// http.Handler to observe the response size with the provided ObserverVec. The
+// ObserverVec must have valid metric and label names and must have zero, one,
+// or two non-const non-curried labels. For those, the only allowed label names
+// are "code" and "method". The function panics otherwise. The Observe method of
+// the Observer in the ObserverVec is called with the response size in
+// bytes. Partitioning happens by HTTP status code and/or HTTP method if the
+// respective instance label names are present in the ObserverVec. For
+// unpartitioned observations, use an ObserverVec with zero labels. Note that
+// partitioning of Histograms is expensive and should be used judiciously.
//
// If the wrapped Handler does not set a status code, a status code of 200 is assumed.
//
})
}
+// checkLabels returns whether the provided Collector has a non-const,
+// non-curried label named "code" and/or "method". It panics if the provided
+// Collector does not have a Desc or has more than one Desc or its Desc is
+// invalid. It also panics if the Collector has any non-const, non-curried
+// labels that are not named "code" or "method".
func checkLabels(c prometheus.Collector) (code bool, method bool) {
// TODO(beorn7): Remove this hacky way to check for instance labels
// once Descriptors can have their dimensionality queried.
close(descc)
+ // Make sure the Collector has a valid Desc by registering it with a
+ // temporary registry.
+ prometheus.NewRegistry().MustRegister(c)
+
// Create a ConstMetric with the Desc. Since we don't know how many
// variable labels there are, try for as long as it needs.
for err := errors.New("dummy"); err != nil; lvs = append(lvs, magicString) {
// by a Gatherer to report multiple errors during MetricFamily gathering.
type MultiError []error
+// Error formats the contained errors as a bullet point list, preceded by the
+// total number of errors. Note that this results in a multi-line string.
func (errs MultiError) Error() string {
if len(errs) == 0 {
return ""
p.parseError(fmt.Sprintf("expected '=' after label name, found %q", p.currentByte))
return nil
}
+ // Check for duplicate label names.
+ labels := make(map[string]struct{})
+ for _, l := range p.currentMetric.Label {
+ lName := l.GetName()
+ if _, exists := labels[lName]; !exists {
+ labels[lName] = struct{}{}
+ } else {
+ p.parseError(fmt.Sprintf("duplicate label names for metric %q", p.currentMF.GetName()))
+ return nil
+ }
+ }
return p.startLabelValue
}
+++ /dev/null
-language: go
-
-arch:
- - amd64
- - ppc64le
-
-go:
- - 1.13.x
- - 1.14.x
- - 1.x
- - master
-
-before_install:
- - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/v1.35.0/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.35.0
-
-script:
- - golangci-lint run
- - go test -v
-
-matrix:
- allow_failures:
- - go: master
- fast_finish: true
+++ /dev/null
-go-github CHANGELOG
-===================
-
-0.6.0
------
-- Add support for the V4 Gitlab API. This means the older V3 API is no longer fully supported
- with this version. If you still need that version, please use the `f-api-v3` branch.
-
-0.4.0
------
-- Add support to use [`sudo`](https://docs.gitlab.com/ce/api/README.html#sudo) for all API calls.
-- Add support for the Notification Settings API.
-- Add support for the Time Tracking API.
-- Make sure that the error response correctly outputs any returned errors.
-- And a reasonable number of smaller enhanchements and bugfixes.
-
-0.3.0
------
-- Moved the tags related API calls to their own service, following the Gitlab API structure.
-
-0.2.0
------
-- Convert all Option structs to use pointers for their fields.
-
-0.1.0
------
-- Initial release.
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
+ boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright [yyyy] [name of copyright owner]
+ Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
A GitLab API client enabling Go programs to interact with GitLab in a simple and uniform way
-[![Build Status](https://travis-ci.org/xanzy/go-gitlab.svg?branch=master)](https://travis-ci.org/xanzy/go-gitlab)
-[![GitHub license](https://img.shields.io/github/license/xanzy/go-gitlab.svg)](https://github.com/xanzy/go-gitlab/blob/master/LICENSE)
+[![Build Status](https://github.com/xanzy/go-gitlab/workflows/Lint%20and%20Test/badge.svg)](https://github.com/xanzy/go-gitlab/actions?workflow=Lint%20and%20Test)
[![Sourcegraph](https://sourcegraph.com/github.com/xanzy/go-gitlab/-/badge.svg)](https://sourcegraph.com/github.com/xanzy/go-gitlab?badge)
[![GoDoc](https://godoc.org/github.com/xanzy/go-gitlab?status.svg)](https://godoc.org/github.com/xanzy/go-gitlab)
[![Go Report Card](https://goreportcard.com/badge/github.com/xanzy/go-gitlab)](https://goreportcard.com/report/github.com/xanzy/go-gitlab)
-[![GitHub issues](https://img.shields.io/github/issues/xanzy/go-gitlab.svg)](https://github.com/xanzy/go-gitlab/issues)
## NOTE
- [x] Group Issue Boards
- [x] Group Members
- [x] Group Milestones
+- [x] Group Wikis
- [x] Group-Level Variables
- [x] Groups
- [x] Instance Clusters
+- [x] Invites
- [x] Issue Boards
- [x] Issues
- [x] Jobs
- [x] Project-Level Variables
- [x] Projects (including setting Webhooks)
- [x] Protected Branches
+- [x] Protected Environments
- [x] Protected Tags
- [x] Repositories
- [x] Repository Files
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/access_requests", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/access_requests", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/access_requests", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/access_requests", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/access_requests/%d/approve", pathEscape(project), user)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/access_requests/%d/approve", pathEscape(group), user)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/access_requests/%d", pathEscape(project), user)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("groups/%s/access_requests/%d", pathEscape(group), user)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package gitlab
-import "fmt"
+import (
+ "fmt"
+ "net/http"
+)
// ApplicationsService handles communication with administrables applications
// of the Gitlab API.
//
// Gitlab API docs : https://docs.gitlab.com/ce/api/applications.html#create-an-application
func (s *ApplicationsService) CreateApplication(opt *CreateApplicationOptions, options ...RequestOptionFunc) (*Application, *Response, error) {
- req, err := s.client.NewRequest("POST", "applications", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "applications", opt, options)
if err != nil {
return nil, nil, err
}
//
// Gitlab API docs : https://docs.gitlab.com/ce/api/applications.html#list-all-applications
func (s *ApplicationsService) ListApplications(opt *ListApplicationsOptions, options ...RequestOptionFunc) ([]*Application, *Response, error) {
- req, err := s.client.NewRequest("GET", "applications", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "applications", opt, options)
if err != nil {
return nil, nil, err
}
func (s *ApplicationsService) DeleteApplication(application int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("applications/%d", application)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
--- /dev/null
+package gitlab
+
+import (
+ "fmt"
+ "net/http"
+ "time"
+)
+
+// AuditEvent represents an audit event for a group or project.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
+type AuditEvent struct {
+ ID int `json:"id"`
+ AuthorID int `json:"author_id"`
+ EntityID int `json:"entity_id"`
+ EntityType string `json:"entity_type"`
+ Details AuditEventDetails `json:"details"`
+ CreatedAt *time.Time `json:"created_at"`
+}
+
+// AuditEventDetails represents the details portion of an audit event for
+// a group or project. The exact fields that are returned for an audit event
+// depend on the action being recorded.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
+type AuditEventDetails struct {
+ With string `json:"with"`
+ Add string `json:"add"`
+ As string `json:"as"`
+ Change string `json:"change"`
+ From string `json:"from"`
+ To string `json:"to"`
+ Remove string `json:"remove"`
+ CustomMessage string `json:"custom_message"`
+ AuthorName string `json:"author_name"`
+ TargetID interface{} `json:"target_id"`
+ TargetType string `json:"target_type"`
+ TargetDetails string `json:"target_details"`
+ IPAddress string `json:"ip_address"`
+ EntityPath string `json:"entity_path"`
+}
+
+// AuditEventsService handles communication with the project/group audit
+// event related methods of the GitLab API.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
+type AuditEventsService struct {
+ client *Client
+}
+
+// ListAuditEventsOptions represents the available ListProjectAuditEvents()
+// or ListGroupAuditEvents() options.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
+type ListAuditEventsOptions struct {
+ ListOptions
+ CreatedAfter *time.Time `url:"created_after,omitempty" json:"created_after,omitempty"`
+ CreatedBefore *time.Time `url:"created_before,omitempty" json:"created_before,omitempty"`
+}
+
+// ListGroupAuditEvents gets a list of audit events for the specified group
+// viewable by the authenticated user.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
+func (s *AuditEventsService) ListGroupAuditEvents(gid interface{}, opt *ListAuditEventsOptions, options ...RequestOptionFunc) ([]*AuditEvent, *Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("groups/%s/audit_events", pathEscape(group))
+
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var aes []*AuditEvent
+ resp, err := s.client.Do(req, &aes)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return aes, resp, err
+}
+
+// GetGroupAuditEvent gets a specific group audit event.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
+func (s *AuditEventsService) GetGroupAuditEvent(gid interface{}, event int, options ...RequestOptionFunc) (*AuditEvent, *Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("groups/%s/audit_events/%d", pathEscape(group), event)
+
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ ae := new(AuditEvent)
+ resp, err := s.client.Do(req, ae)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return ae, resp, err
+}
+
+// ListProjectAuditEvents gets a list of audit events for the specified project
+// viewable by the authenticated user.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
+func (s *AuditEventsService) ListProjectAuditEvents(pid interface{}, opt *ListAuditEventsOptions, options ...RequestOptionFunc) ([]*AuditEvent, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/audit_events", pathEscape(project))
+
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var aes []*AuditEvent
+ resp, err := s.client.Do(req, &aes)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return aes, resp, err
+}
+
+// GetProjectAuditEvent gets a specific project audit event.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/audit_events.html
+func (s *AuditEventsService) GetProjectAuditEvent(pid interface{}, event int, options ...RequestOptionFunc) (*AuditEvent, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/audit_events/%d", pathEscape(project), event)
+
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ ae := new(AuditEvent)
+ resp, err := s.client.Do(req, ae)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return ae, resp, err
+}
//
-// Copyright 2017, Arkbriar
+// Copyright 2021, Arkbriar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
resourceID,
)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
awardID,
)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
resourceID,
)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/%s/%d/award_emoji/%d", pathEscape(project), resource,
resourceID, awardID)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/%s/%d/notes/%d/award_emoji", pathEscape(project), resources,
ressourceID, noteID)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
awardID,
)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
noteID,
)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
awardID,
)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2015, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
)
// IssueBoardsService handles communication with the issue board related
}
u := fmt.Sprintf("projects/%s/boards", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/boards/%d", pathEscape(project), board)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/boards/%d", pathEscape(project), board)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/boards", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/boards/%d", pathEscape(project), board)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/boards/%d/lists", pathEscape(project), board)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
list,
)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/boards/%d/lists", pathEscape(project), board)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
list,
)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
list,
)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"net/url"
)
}
u := fmt.Sprintf("projects/%s/repository/branches", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opts, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/branches/%s", pathEscape(project), url.PathEscape(branch))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/branches/%s/protect", pathEscape(project), url.PathEscape(branch))
- req, err := s.client.NewRequest("PUT", u, opts, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opts, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/branches/%s/unprotect", pathEscape(project), url.PathEscape(branch))
- req, err := s.client.NewRequest("PUT", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/branches", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/branches/%s", pathEscape(project), url.PathEscape(branch))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/merged_branches", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2018, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
// GitLab API docs:
// https://docs.gitlab.com/ce/api/broadcast_messages.html#get-all-broadcast-messages
func (s *BroadcastMessagesService) ListBroadcastMessages(opt *ListBroadcastMessagesOptions, options ...RequestOptionFunc) ([]*BroadcastMessage, *Response, error) {
- req, err := s.client.NewRequest("GET", "broadcast_messages", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "broadcast_messages", opt, options)
if err != nil {
return nil, nil, err
}
func (s *BroadcastMessagesService) GetBroadcastMessage(broadcast int, options ...RequestOptionFunc) (*BroadcastMessage, *Response, error) {
u := fmt.Sprintf("broadcast_messages/%d", broadcast)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/broadcast_messages.html#create-a-broadcast-message
func (s *BroadcastMessagesService) CreateBroadcastMessage(opt *CreateBroadcastMessageOptions, options ...RequestOptionFunc) (*BroadcastMessage, *Response, error) {
- req, err := s.client.NewRequest("POST", "broadcast_messages", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "broadcast_messages", opt, options)
if err != nil {
return nil, nil, err
}
func (s *BroadcastMessagesService) UpdateBroadcastMessage(broadcast int, opt *UpdateBroadcastMessageOptions, options ...RequestOptionFunc) (*BroadcastMessage, *Response, error) {
u := fmt.Sprintf("broadcast_messages/%d", broadcast)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *BroadcastMessagesService) DeleteBroadcastMessage(broadcast int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("broadcast_messages/%d", broadcast)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
)
// CIYMLTemplatesService handles communication with the gitlab
// GitLab API docs:
// https://docs.gitlab.com/ce/api/templates/gitlab_ci_ymls.html#list-gitlab-ci-yml-templates
func (s *CIYMLTemplatesService) ListAllTemplates(opt *ListCIYMLTemplatesOptions, options ...RequestOptionFunc) ([]*CIYMLTemplate, *Response, error) {
- req, err := s.client.NewRequest("GET", "templates/gitlab_ci_ymls", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "templates/gitlab_ci_ymls", opt, options)
if err != nil {
return nil, nil, err
}
func (s *CIYMLTemplatesService) GetTemplate(key string, options ...RequestOptionFunc) (*CIYMLTemplate, *Response, error) {
u := fmt.Sprintf("templates/gitlab_ci_ymls/%s", pathEscape(key))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"net/url"
"time"
)
}
u := fmt.Sprintf("projects/%s/repository/commits", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/refs", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/commits/%s", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
type CommitActionOptions struct {
- Action *FileAction `url:"action,omitempty" json:"action,omitempty"`
- FilePath *string `url:"file_path,omitempty" json:"file_path,omitempty"`
- PreviousPath *string `url:"previous_path,omitempty" json:"previous_path,omitempty"`
- Content *string `url:"content,omitempty" json:"content,omitempty"`
- Encoding *string `url:"encoding,omitempty" json:"encoding,omitempty"`
- LastCommitID *string `url:"last_commit_id,omitempty" json:"last_commit_id,omitempty"`
- ExecuteFilemode *bool `url:"execute_filemode,omitempty" json:"execute_filemode,omitempty"`
+ Action *FileActionValue `url:"action,omitempty" json:"action,omitempty"`
+ FilePath *string `url:"file_path,omitempty" json:"file_path,omitempty"`
+ PreviousPath *string `url:"previous_path,omitempty" json:"previous_path,omitempty"`
+ Content *string `url:"content,omitempty" json:"content,omitempty"`
+ Encoding *string `url:"encoding,omitempty" json:"encoding,omitempty"`
+ LastCommitID *string `url:"last_commit_id,omitempty" json:"last_commit_id,omitempty"`
+ ExecuteFilemode *bool `url:"execute_filemode,omitempty" json:"execute_filemode,omitempty"`
}
// CreateCommit creates a commit with multiple files and actions.
}
u := fmt.Sprintf("projects/%s/repository/commits", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/diff", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/comments", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/comments", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/statuses", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/statuses/%s", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/merge_requests", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/cherry_pick", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/revert", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/signature", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
)
// CustomAttributesService handles communication with the group, project and
func (s *CustomAttributesService) listCustomAttributes(resource string, id int, options ...RequestOptionFunc) ([]*CustomAttribute, *Response, error) {
u := fmt.Sprintf("%s/%d/custom_attributes", resource, id)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
func (s *CustomAttributesService) getCustomAttribute(resource string, id int, key string, options ...RequestOptionFunc) (*CustomAttribute, *Response, error) {
u := fmt.Sprintf("%s/%d/custom_attributes/%s", resource, id, key)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
func (s *CustomAttributesService) setCustomAttribute(resource string, id int, c CustomAttribute, options ...RequestOptionFunc) (*CustomAttribute, *Response, error) {
u := fmt.Sprintf("%s/%d/custom_attributes/%s", resource, id, c.Key)
- req, err := s.client.NewRequest("PUT", u, c, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, c, options)
if err != nil {
return nil, nil, err
}
func (s *CustomAttributesService) deleteCustomAttribute(resource string, id int, key string, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("%s/%d/custom_attributes/%s", resource, id, key)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
// GitLab API docs:
// https://docs.gitlab.com/ce/api/deploy_keys.html#list-all-deploy-keys
func (s *DeployKeysService) ListAllDeployKeys(options ...RequestOptionFunc) ([]*DeployKey, *Response, error) {
- req, err := s.client.NewRequest("GET", "deploy_keys", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "deploy_keys", nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/deploy_keys", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/deploy_keys/%d", pathEscape(project), deployKey)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/deploy_keys", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/deploy_keys/%d", pathEscape(project), deployKey)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/deploy_keys/%d/enable", pathEscape(project), deployKey)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/deploy_keys/%d", pathEscape(project), deployKey)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
"time"
)
// GitLab API docs:
// https://docs.gitlab.com/ce/api/deploy_tokens.html#list-all-deploy-tokens
func (s *DeployTokensService) ListAllDeployTokens(options ...RequestOptionFunc) ([]*DeployToken, *Response, error) {
- req, err := s.client.NewRequest("GET", "deploy_tokens", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "deploy_tokens", nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/deploy_tokens", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/deploy_tokens", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/deploy_tokens/%d", pathEscape(project), deployToken)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("groups/%s/deploy_tokens", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/deploy_tokens", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/deploy_tokens/%d", pathEscape(group), deployToken)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2018, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/deployments", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opts, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/deployments/%d", pathEscape(project), deployment)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/deployments", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/deployments/%d", pathEscape(project), deployment)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2018, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/issues/%d/discussions", pathEscape(project), issue)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
discussion,
)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d/discussions", pathEscape(project), issue)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
discussion,
)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
note,
)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
note,
)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets/%d/discussions", pathEscape(project), snippet)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
discussion,
)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets/%d/discussions", pathEscape(project), snippet)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
discussion,
)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
note,
)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
note,
)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
epic,
)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
discussion,
)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
epic,
)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
discussion,
)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
note,
)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
note,
)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
mergeRequest,
)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
discussion,
)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
mergeRequest,
)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
discussion,
)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
discussion,
)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
note,
)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
note,
)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
commit,
)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
discussion,
)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
commit,
)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
discussion,
)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
note,
)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
note,
)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
)
// EnvironmentsService handles communication with the environment related methods
}
u := fmt.Sprintf("projects/%s/environments", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opts, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/environments/%d", pathEscape(project), environment)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/environments", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/environments/%d", pathEscape(project), environment)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/environments/%d", pathEscape(project), environment)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/environments/%d/stop", pathEscape(project), environmentID)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
-import "fmt"
+import (
+ "fmt"
+ "net/http"
+)
// EpicIssuesService handles communication with the epic issue related methods
// of the GitLab API.
}
u := fmt.Sprintf("groups/%s/epics/%d/issues", pathEscape(group), epic)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", pathEscape(group), epic, issue)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", pathEscape(group), epic, epicIssue)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", pathEscape(group), epic, epicIssue)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("groups/%s/epics", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d", pathEscape(group), epic)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d/epics", pathEscape(group), epic)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d", pathEscape(group), epic)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d", pathEscape(group), epic)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
// systemHookEvent is used to pre-process events to determine the
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"updated_by_id"`
+ TotalTimeSpent struct {
+ Previous int `json:"previous"`
+ Current int `json:"current"`
+ } `json:"total_time_spent"`
} `json:"changes"`
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("users/%s/events", user)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/events.html#list-currently-authenticated-user-39-s-events
func (s *EventsService) ListCurrentUserContributionEvents(opt *ListContributionEventsOptions, options ...RequestOptionFunc) ([]*ContributionEvent, *Response, error) {
- req, err := s.client.NewRequest("GET", "events", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "events", opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/events", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
"net/url"
)
// GitLab API docs:
// https://docs.gitlab.com/ce/api/features.html#list-all-features
func (s *FeaturesService) ListFeatures(options ...RequestOptionFunc) ([]*Feature, *Response, error) {
- req, err := s.client.NewRequest("GET", "features", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "features", nil, options)
if err != nil {
return nil, nil, err
}
value,
}
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2020 Paul Cioanca
+// Copyright 2021 Paul Cioanca
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/freeze_periods", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/freeze_periods/%d", pathEscape(project), freezePeriod)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/freeze_periods", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/freeze_periods/%d", pathEscape(project), freezePeriod)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/freeze_periods/%d", pathEscape(project), freezePeriod)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2018, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"net/url"
)
// GitLab API docs:
// https://docs.gitlab.com/ce/api/templates/gitignores.html#list-gitignore-templates
func (s *GitIgnoreTemplatesService) ListTemplates(opt *ListTemplatesOptions, options ...RequestOptionFunc) ([]*GitIgnoreTemplate, *Response, error) {
- req, err := s.client.NewRequest("GET", "templates/gitignores", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "templates/gitignores", opt, options)
if err != nil {
return nil, nil, err
}
func (s *GitIgnoreTemplatesService) GetTemplate(key string, options ...RequestOptionFunc) (*GitIgnoreTemplate, *Response, error) {
u := fmt.Sprintf("templates/gitignores/%s", url.PathEscape(key))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// Services used for talking to different parts of the GitLab API.
AccessRequests *AccessRequestsService
Applications *ApplicationsService
+ AuditEvents *AuditEventsService
AwardEmoji *AwardEmojiService
Boards *IssueBoardsService
Branches *BranchesService
GroupMembers *GroupMembersService
GroupMilestones *GroupMilestonesService
GroupVariables *GroupVariablesService
+ GroupWikis *GroupWikisService
Groups *GroupsService
InstanceCluster *InstanceClustersService
InstanceVariables *InstanceVariablesService
+ Invites *InvitesService
IssueLinks *IssueLinksService
Issues *IssuesService
IssuesStatistics *IssuesStatisticsService
Namespaces *NamespacesService
Notes *NotesService
NotificationSettings *NotificationSettingsService
+ Packages *PackagesService
PagesDomains *PagesDomainsService
PipelineSchedules *PipelineSchedulesService
PipelineTriggers *PipelineTriggersService
ProjectVariables *ProjectVariablesService
Projects *ProjectsService
ProtectedBranches *ProtectedBranchesService
+ ProtectedEnvironments *ProtectedEnvironmentsService
ProtectedTags *ProtectedTagsService
ReleaseLinks *ReleaseLinksService
Releases *ReleasesService
Repositories *RepositoriesService
RepositoryFiles *RepositoryFilesService
ResourceLabelEvents *ResourceLabelEventsService
+ ResourceStateEvents *ResourceStateEventsService
Runners *RunnersService
Search *SearchService
Services *ServicesService
// Create all the public services.
c.AccessRequests = &AccessRequestsService{client: c}
c.Applications = &ApplicationsService{client: c}
+ c.AuditEvents = &AuditEventsService{client: c}
c.AwardEmoji = &AwardEmojiService{client: c}
c.Boards = &IssueBoardsService{client: c}
c.Branches = &BranchesService{client: c}
c.GroupMembers = &GroupMembersService{client: c}
c.GroupMilestones = &GroupMilestonesService{client: c}
c.GroupVariables = &GroupVariablesService{client: c}
+ c.GroupWikis = &GroupWikisService{client: c}
c.Groups = &GroupsService{client: c}
c.InstanceCluster = &InstanceClustersService{client: c}
c.InstanceVariables = &InstanceVariablesService{client: c}
+ c.Invites = &InvitesService{client: c}
c.IssueLinks = &IssueLinksService{client: c}
c.Issues = &IssuesService{client: c, timeStats: timeStats}
c.IssuesStatistics = &IssuesStatisticsService{client: c}
c.Namespaces = &NamespacesService{client: c}
c.Notes = &NotesService{client: c}
c.NotificationSettings = &NotificationSettingsService{client: c}
+ c.Packages = &PackagesService{client: c}
c.PagesDomains = &PagesDomainsService{client: c}
c.PipelineSchedules = &PipelineSchedulesService{client: c}
c.PipelineTriggers = &PipelineTriggersService{client: c}
c.ProjectVariables = &ProjectVariablesService{client: c}
c.Projects = &ProjectsService{client: c}
c.ProtectedBranches = &ProtectedBranchesService{client: c}
+ c.ProtectedEnvironments = &ProtectedEnvironmentsService{client: c}
c.ProtectedTags = &ProtectedTagsService{client: c}
c.ReleaseLinks = &ReleaseLinksService{client: c}
c.Releases = &ReleasesService{client: c}
c.Repositories = &RepositoriesService{client: c}
c.RepositoryFiles = &RepositoryFilesService{client: c}
c.ResourceLabelEvents = &ResourceLabelEventsService{client: c}
+ c.ResourceStateEvents = &ResourceStateEventsService{client: c}
c.Runners = &RunnersService{client: c}
c.Search = &SearchService{client: c}
c.Services = &ServicesService{client: c}
}
// configureLimiter configures the rate limiter.
-func (c *Client) configureLimiter() error {
+func (c *Client) configureLimiter(ctx context.Context) error {
// Set default values for when rate limiting is disabled.
limit := rate.Inf
burst := 0
}()
// Create a new request.
- req, err := http.NewRequest("GET", c.baseURL.String(), nil)
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL.String(), nil)
if err != nil {
return err
}
var body interface{}
switch {
- case method == "POST" || method == "PUT":
+ case method == http.MethodPost || method == http.MethodPut:
reqHeaders.Set("Content-Type", "application/json")
if opt != nil {
func (c *Client) Do(req *retryablehttp.Request, v interface{}) (*Response, error) {
// If not yet configured, try to configure the rate limiter. Fail
// silently as the limiter will be disabled in case of an error.
- c.configureLimiterOnce.Do(func() { c.configureLimiter() })
+ c.configureLimiterOnce.Do(func() { c.configureLimiter(req.Context()) })
// Wait will block until the limiter can obtain a new token.
err := c.limiter.Wait(req.Context())
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
)
// GroupBadgesService handles communication with the group badges
}
u := fmt.Sprintf("groups/%s/badges", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/badges/%d", pathEscape(group), badge)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/badges", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/badges/%d", pathEscape(group), badge)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/badges/%d", pathEscape(group), badge)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("groups/%s/badges/render", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2018, Patrick Webster
+// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
)
// GroupIssueBoardsService handles communication with the group issue board
}
u := fmt.Sprintf("groups/%s/boards", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/boards", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/boards/%d", pathEscape(group), board)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/boards/%d", pathEscape(group), board)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/boards/%d", pathEscape(group), board)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("groups/%s/boards/%d/lists", pathEscape(group), board)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
list,
)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/boards/%d/lists", pathEscape(group), board)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
list,
)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
list,
)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2019, Paul Shoemaker
+// Copyright 2021, Paul Shoemaker
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("groups/%s/clusters", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/clusters/%d", pathEscape(group), cluster)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/clusters/user", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/clusters/%d", pathEscape(group), cluster)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/clusters/%d", pathEscape(group), cluster)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2020, Eric Stevens
+// Copyright 2021, Eric Stevens
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("groups/%s/hooks", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, nil, nil)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, nil)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/hooks/%d", pathEscape(group), hook)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/hooks", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/hooks/%d", pathEscape(group), hook)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/hooks/%d", pathEscape(group), hook)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
)
// GroupLabelsService handles communication with the label related methods of the
}
u := fmt.Sprintf("groups/%s/labels", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/labels/%s", pathEscape(group), label)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/labels", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/labels", pathEscape(group))
- req, err := s.client.NewRequest("DELETE", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("groups/%s/labels", pathEscape(group))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/labels/%s/subscribe", pathEscape(group), label)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/labels/%s/unsubscribe", pathEscape(group), label)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
)
// GroupMembersService handles communication with the group members
}
u := fmt.Sprintf("groups/%s/members", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/members/all", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/members/%d", pathEscape(group), user)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
return gm, resp, err
}
+// BillableGroupMember represents a GitLab billable group member.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/members.html#list-all-billable-members-of-a-group
+type BillableGroupMember struct {
+ ID int `json:"id"`
+ Username string `json:"username"`
+ Name string `json:"name"`
+ State string `json:"state"`
+ AvatarURL string `json:"avatar_url"`
+ WebURL string `json:"web_url"`
+ Email string `json:"email"`
+ LastActivityOn ISOTime `json:"last_activity_on"`
+}
+
+// ListBillableGroupMembersOptions represents the available ListBillableGroupMembers() options.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/members.html#list-all-billable-members-of-a-group
+type ListBillableGroupMembersOptions struct {
+ ListOptions
+ Search *string `url:"search,omitempty" json:"search,omitempty"`
+ Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
+}
+
+// ListBillableGroupMembers Gets a list of group members that count as billable.
+// The list includes members in the subgroup or subproject.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/members.html#list-all-billable-members-of-a-group
+func (s *GroupsService) ListBillableGroupMembers(gid interface{}, opt *ListBillableGroupMembersOptions, options ...RequestOptionFunc) ([]*BillableGroupMember, *Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("groups/%s/billable_members", pathEscape(group))
+
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var bgm []*BillableGroupMember
+ resp, err := s.client.Do(req, &bgm)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return bgm, resp, err
+}
+
// AddGroupMember adds a user to the list of group members.
//
// GitLab API docs:
}
u := fmt.Sprintf("groups/%s/members", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/share", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/share/%d", pathEscape(group), groupID)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("groups/%s/members/%d", pathEscape(group), user)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/members/%d", pathEscape(group), user)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2018, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("groups/%s/milestones", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/milestones/%d", pathEscape(group), milestone)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/milestones", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/milestones/%d", pathEscape(group), milestone)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/milestones/%d/issues", pathEscape(group), milestone)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/milestones/%d/merge_requests", pathEscape(group), milestone)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/milestones/%d/burndown_events", pathEscape(group), milestone)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2018, Patrick Webster
+// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"net/url"
)
}
u := fmt.Sprintf("groups/%s/variables", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/variables/%s", pathEscape(group), url.PathEscape(key))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/variables", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/variables/%s", pathEscape(group), url.PathEscape(key))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/variables/%s", pathEscape(group), url.PathEscape(key))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
--- /dev/null
+//
+// Copyright 2021, Markus Lackner
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package gitlab
+
+import (
+ "fmt"
+ "net/http"
+ "net/url"
+)
+
+// GroupWikisService handles communication with the group wikis related methods of
+// the Gitlab API.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/group_wikis.html
+type GroupWikisService struct {
+ client *Client
+}
+
+// GroupWiki represents a GitLab groups wiki.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/group_wikis.html
+type GroupWiki struct {
+ Content string `json:"content"`
+ Format WikiFormatValue `json:"format"`
+ Slug string `json:"slug"`
+ Title string `json:"title"`
+}
+
+func (w GroupWiki) String() string {
+ return Stringify(w)
+}
+
+// ListGroupWikisOptions represents the available ListGroupWikis options.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/group_wikis.html#list-wiki-pages
+type ListGroupWikisOptions struct {
+ WithContent *bool `url:"with_content,omitempty" json:"with_content,omitempty"`
+}
+
+// ListGroupWikis lists all pages of the wiki of the given group id.
+// When with_content is set, it also returns the content of the pages.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/group_wikis.html#list-wiki-pages
+func (s *GroupWikisService) ListGroupWikis(gid interface{}, opt *ListGroupWikisOptions, options ...RequestOptionFunc) ([]*GroupWiki, *Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("groups/%s/wikis", pathEscape(group))
+
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var gws []*GroupWiki
+ resp, err := s.client.Do(req, &gws)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return gws, resp, err
+}
+
+// GetGroupWikiPage gets a wiki page for a given group.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/group_wikis.html#get-a-wiki-page
+func (s *GroupWikisService) GetGroupWikiPage(gid interface{}, slug string, options ...RequestOptionFunc) (*GroupWiki, *Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("groups/%s/wikis/%s", pathEscape(group), url.PathEscape(slug))
+
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ gw := new(GroupWiki)
+ resp, err := s.client.Do(req, gw)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return gw, resp, err
+}
+
+// CreateGroupWikiPageOptions represents options to CreateGroupWikiPage.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/group_wikis.html#create-a-new-wiki-page
+type CreateGroupWikiPageOptions struct {
+ Content *string `url:"content,omitempty" json:"content,omitempty"`
+ Title *string `url:"title,omitempty" json:"title,omitempty"`
+ Format *WikiFormatValue `url:"format,omitempty" json:"format,omitempty"`
+}
+
+// CreateGroupWikiPage creates a new wiki page for the given group with
+// the given title, slug, and content.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/13.8/ee/api/group_wikis.html#create-a-new-wiki-page
+func (s *GroupWikisService) CreateGroupWikiPage(gid interface{}, opt *CreateGroupWikiPageOptions, options ...RequestOptionFunc) (*GroupWiki, *Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("groups/%s/wikis", pathEscape(group))
+
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ w := new(GroupWiki)
+ resp, err := s.client.Do(req, w)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return w, resp, err
+}
+
+// EditGroupWikiPageOptions represents options to EditGroupWikiPage.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/group_wikis.html#edit-an-existing-wiki-page
+type EditGroupWikiPageOptions struct {
+ Content *string `url:"content,omitempty" json:"content,omitempty"`
+ Title *string `url:"title,omitempty" json:"title,omitempty"`
+ Format *WikiFormatValue `url:"format,omitempty" json:"format,omitempty"`
+}
+
+// EditGroupWikiPage Updates an existing wiki page. At least one parameter is
+// required to update the wiki page.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/group_wikis.html#edit-an-existing-wiki-page
+func (s *GroupWikisService) EditGroupWikiPage(gid interface{}, slug string, opt *EditGroupWikiPageOptions, options ...RequestOptionFunc) (*GroupWiki, *Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("groups/%s/wikis/%s", pathEscape(group), url.PathEscape(slug))
+
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ w := new(GroupWiki)
+ resp, err := s.client.Do(req, w)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return w, resp, err
+}
+
+// DeleteGroupWikiPage deletes a wiki page with a given slug.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/group_wikis.html#delete-a-wiki-page
+func (s *GroupWikisService) DeleteGroupWikiPage(gid interface{}, slug string, options ...RequestOptionFunc) (*Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, err
+ }
+ u := fmt.Sprintf("groups/%s/wikis/%s", pathEscape(group), url.PathEscape(slug))
+
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
+ if err != nil {
+ return nil, err
+ }
+
+ return s.client.Do(req, nil)
+}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
// GitLab API docs:
// https://docs.gitlab.com/ce/api/groups.html#list-project-groups
func (s *GroupsService) ListGroups(opt *ListGroupsOptions, options ...RequestOptionFunc) ([]*Group, *Response, error) {
- req, err := s.client.NewRequest("GET", "groups", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "groups", opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#new-group
func (s *GroupsService) CreateGroup(opt *CreateGroupOptions, options ...RequestOptionFunc) (*Group, *Response, error) {
- req, err := s.client.NewRequest("POST", "groups", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "groups", opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/projects/%s", pathEscape(group), pathEscape(project))
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s", pathEscape(group))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s", pathEscape(group))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("groups/%s/restore", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
q.Search = query
- req, err := s.client.NewRequest("GET", "groups", &q, options)
+ req, err := s.client.NewRequest(http.MethodGet, "groups", &q, options)
if err != nil {
return nil, nil, err
}
// https://docs.gitlab.com/ce/api/groups.html#list-a-group-39-s-projects
type ListGroupProjectsOptions struct {
ListOptions
- Archived *bool `url:"archived,omitempty" json:"archived,omitempty"`
- Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
- OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
- Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
- Search *string `url:"search,omitempty" json:"search,omitempty"`
- Simple *bool `url:"simple,omitempty" json:"simple,omitempty"`
- Owned *bool `url:"owned,omitempty" json:"owned,omitempty"`
- Starred *bool `url:"starred,omitempty" json:"starred,omitempty"`
- WithIssuesEnabled *bool `url:"with_issues_enabled,omitempty" json:"with_issues_enabled,omitempty"`
- WithMergeRequestsEnabled *bool `url:"with_merge_requests_enabled,omitempty" json:"with_merge_requests_enabled,omitempty"`
- WithShared *bool `url:"with_shared,omitempty" json:"with_shared,omitempty"`
- IncludeSubgroups *bool `url:"include_subgroups,omitempty" json:"include_subgroups,omitempty"`
- WithCustomAttributes *bool `url:"with_custom_attributes,omitempty" json:"with_custom_attributes,omitempty"`
+ Archived *bool `url:"archived,omitempty" json:"archived,omitempty"`
+ Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
+ OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
+ Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
+ Search *string `url:"search,omitempty" json:"search,omitempty"`
+ Simple *bool `url:"simple,omitempty" json:"simple,omitempty"`
+ Owned *bool `url:"owned,omitempty" json:"owned,omitempty"`
+ Starred *bool `url:"starred,omitempty" json:"starred,omitempty"`
+ WithIssuesEnabled *bool `url:"with_issues_enabled,omitempty" json:"with_issues_enabled,omitempty"`
+ WithMergeRequestsEnabled *bool `url:"with_merge_requests_enabled,omitempty" json:"with_merge_requests_enabled,omitempty"`
+ WithShared *bool `url:"with_shared,omitempty" json:"with_shared,omitempty"`
+ IncludeSubgroups *bool `url:"include_subgroups,omitempty" json:"include_subgroups,omitempty"`
+ MinAccessLevel *AccessLevelValue `url:"min_access_level,omitempty" json:"min_access_level,omitempty"`
+ WithCustomAttributes *bool `url:"with_custom_attributes,omitempty" json:"with_custom_attributes,omitempty"`
+ WithSecurityReports *bool `url:"with_security_reports,omitempty" json:"with_security_reports,omitempty"`
}
// ListGroupProjects get a list of group projects
}
u := fmt.Sprintf("groups/%s/projects", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/subgroups", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/descendant_groups", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/ldap_group_links", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/ldap_group_links", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/ldap_group_links/%s", pathEscape(group), pathEscape(cn))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
pathEscape(cn),
)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
+ if err != nil {
+ return nil, err
+ }
+
+ return s.client.Do(req, nil)
+}
+
+// ShareGroupWithGroupOptions represents the available ShareGroupWithGroup() options.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/groups.html#share-groups-with-groups
+type ShareGroupWithGroupOptions struct {
+ GroupID *int `url:"group_id,omitempty" json:"group_id,omitempty"`
+ GroupAccess *AccessLevelValue `url:"group_access,omitempty" json:"group_access,omitempty"`
+ ExpiresAt *ISOTime `url:"expires_at,omitempty" json:"expires_at,omitempty"`
+}
+
+// ShareGroupWithGroup shares a group with another group.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/groups.html#create-a-link-to-share-a-group-with-another-group
+func (s *GroupsService) ShareGroupWithGroup(gid interface{}, opt *ShareGroupWithGroupOptions, options ...RequestOptionFunc) (*Group, *Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("groups/%s/share", pathEscape(group))
+
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ g := new(Group)
+ resp, err := s.client.Do(req, g)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return g, resp, err
+}
+
+// UnshareGroupFromGroup unshares a group from another group.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/groups.html#delete-link-sharing-group-with-another-group
+func (s *GroupsService) UnshareGroupFromGroup(gid interface{}, groupID int, options ...RequestOptionFunc) (*Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, err
+ }
+ u := fmt.Sprintf("groups/%s/share/%d", pathEscape(group), groupID)
+
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("groups/%s/push_rule", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/push_rule", pathEscape(group))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/push_rule", pathEscape(group))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/push_rule", pathEscape(group))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2020, Serena Fang
+// Copyright 2021, Serena Fang
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
func (s *InstanceClustersService) ListClusters(options ...RequestOptionFunc) ([]*InstanceCluster, *Response, error) {
u := "admin/clusters"
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
func (s *InstanceClustersService) GetCluster(cluster int, options ...RequestOptionFunc) (*InstanceCluster, *Response, error) {
u := fmt.Sprintf("admin/clusters/%d", cluster)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
func (s *InstanceClustersService) AddCluster(opt *AddClusterOptions, options ...RequestOptionFunc) (*InstanceCluster, *Response, error) {
u := "admin/clusters/add"
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *InstanceClustersService) EditCluster(cluster int, opt *EditClusterOptions, options ...RequestOptionFunc) (*InstanceCluster, *Response, error) {
u := fmt.Sprintf("admin/clusters/%d", cluster)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *InstanceClustersService) DeleteCluster(cluster int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("admin/clusters/%d", cluster)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2018, Patrick Webster
+// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"net/url"
)
func (s *InstanceVariablesService) ListVariables(opt *ListInstanceVariablesOptions, options ...RequestOptionFunc) ([]*InstanceVariable, *Response, error) {
u := "admin/ci/variables"
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *InstanceVariablesService) GetVariable(key string, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) {
u := fmt.Sprintf("admin/ci/variables/%s", url.PathEscape(key))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
func (s *InstanceVariablesService) CreateVariable(opt *CreateInstanceVariableOptions, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) {
u := "admin/ci/variables"
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *InstanceVariablesService) UpdateVariable(key string, opt *UpdateInstanceVariableOptions, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) {
u := fmt.Sprintf("admin/ci/variables/%s", url.PathEscape(key))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *InstanceVariablesService) RemoveVariable(key string, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("admin/ci/variables/%s", url.PathEscape(key))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
--- /dev/null
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package gitlab
+
+import (
+ "fmt"
+ "net/http"
+ "time"
+)
+
+// InvitesService handles communication with the invitation related
+// methods of the GitLab API.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/invitations.html
+type InvitesService struct {
+ client *Client
+}
+
+// PendingInvite represents a pending invite.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/invitations.html
+type PendingInvite struct {
+ ID int `json:"id"`
+ InviteEmail string `json:"invite_email"`
+ CreatedAt *time.Time `json:"created_at"`
+ AccessLevel AccessLevelValue `json:"access_level"`
+ ExpiresAt *time.Time `json:"expires_at"`
+ UserName string `json:"user_name"`
+ CreatedByName string `json:"created_by_name"`
+}
+
+// ListPendingInvitationsOptions represents the available
+// ListPendingInvitations() options.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/invitations.html#list-all-invitations-pending-for-a-group-or-project
+type ListPendingInvitationsOptions struct {
+ ListOptions
+ Query *string `url:"query,omitempty" json:"query,omitempty"`
+}
+
+// ListPendingGroupInvitations gets a list of invited group members.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/invitations.html#list-all-invitations-pending-for-a-group-or-project
+func (s *InvitesService) ListPendingGroupInvitations(gid interface{}, opt *ListPendingInvitationsOptions, options ...RequestOptionFunc) ([]*PendingInvite, *Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("groups/%s/invitations", pathEscape(group))
+
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var pis []*PendingInvite
+ resp, err := s.client.Do(req, &pis)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return pis, resp, err
+}
+
+// ListPendingProjectInvitations gets a list of invited project members.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/invitations.html#list-all-invitations-pending-for-a-group-or-project
+func (s *InvitesService) ListPendingProjectInvitations(pid interface{}, opt *ListPendingInvitationsOptions, options ...RequestOptionFunc) ([]*PendingInvite, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/invitations", pathEscape(project))
+
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var pis []*PendingInvite
+ resp, err := s.client.Do(req, &pis)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return pis, resp, err
+}
+
+// InvitesOptions represents the available GroupInvites() and ProjectInvites()
+// options.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/invitations.html#invite-by-email-to-group-or-project
+type InvitesOptions struct {
+ ID interface{} `url:"id,omitempty" json:"id,omitempty"`
+ Email *string `url:"email,omitempty" json:"email,omitempty"`
+ AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
+ ExpiresAt *ISOTime `url:"expires_at,omitempty" json:"expires_at,omitempty"`
+}
+
+// InvitesResult represents an invitations result.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/invitations.html#invite-by-email-to-group-or-project
+type InvitesResult struct {
+ Status string `json:"status"`
+ Message map[string]string `json:"message,omitempty"`
+}
+
+// GroupInvites invites new users by email to join a group.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/invitations.html#invite-by-email-to-group-or-project
+func (s *InvitesService) GroupInvites(gid interface{}, opt *InvitesOptions, options ...RequestOptionFunc) (*InvitesResult, *Response, error) {
+ group, err := parseID(gid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("groups/%s/invitations", pathEscape(group))
+
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ ir := new(InvitesResult)
+ resp, err := s.client.Do(req, ir)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return ir, resp, err
+}
+
+// ProjectInvites invites new users by email to join a project.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/invitations.html#invite-by-email-to-group-or-project
+func (s *InvitesService) ProjectInvites(pid interface{}, opt *InvitesOptions, options ...RequestOptionFunc) (*InvitesResult, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/invitations", pathEscape(project))
+
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ ir := new(InvitesResult)
+ resp, err := s.client.Do(req, ir)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return ir, resp, err
+}
//
-// Copyright 2017, Arkbriar
+// Copyright 2021, Arkbriar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
)
// IssueLinksService handles communication with the issue relations related methods
}
u := fmt.Sprintf("projects/%s/issues/%d/links", pathEscape(project), issueIID)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d/links", pathEscape(project), issueIID)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
issueIID,
issueLinkID)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
"bytes"
"encoding/json"
"fmt"
+ "net/http"
"net/url"
"strings"
"time"
//
// GitLab API docs: https://docs.gitlab.com/ce/api/issues.html#list-issues
func (s *IssuesService) ListIssues(opt *ListIssuesOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) {
- req, err := s.client.NewRequest("GET", "issues", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "issues", opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/issues", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
In *string `url:"in,omitempty" json:"in,omitempty"`
CreatedAfter *time.Time `url:"created_after,omitempty" json:"created_after,omitempty"`
CreatedBefore *time.Time `url:"created_before,omitempty" json:"created_before,omitempty"`
+ DueDate *string `url:"due_date,omitempty" json:"due_date,omitempty"`
UpdatedAfter *time.Time `url:"updated_after,omitempty" json:"updated_after,omitempty"`
UpdatedBefore *time.Time `url:"updated_before,omitempty" json:"updated_before,omitempty"`
Confidential *bool `url:"confidential,omitempty" json:"confidential,omitempty"`
}
u := fmt.Sprintf("projects/%s/issues", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d", pathEscape(project), issue)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d", pathEscape(project), issue)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d", pathEscape(project), issue)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d/move", pathEscape(project), issue)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d/subscribe", pathEscape(project), issue)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d/unsubscribe", pathEscape(project), issue)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("/projects/%s/issues/%d/closed_by", pathEscape(project), issue)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
issue,
)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d/participants", pathEscape(project), issue)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
// GitLab API docs:
// https://docs.gitlab.com/ee/api/issues_statistics.html#get-issues-statistics
func (s *IssuesStatisticsService) GetIssuesStatistics(opt *GetIssuesStatisticsOptions, options ...RequestOptionFunc) (*IssuesStatistics, *Response, error) {
- req, err := s.client.NewRequest("GET", "issues_statistics", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "issues_statistics", opt, options)
if err != nil {
return nil, nil, err
}
type GetGroupIssuesStatisticsOptions struct {
Labels Labels `url:"labels,omitempty" json:"labels,omitempty"`
IIDs []int `url:"iids,omitempty" json:"iids,omitempty"`
- Milestone *Milestone `url:"milestone,omitempty" json:"milestone,omitempty"`
+ Milestone *string `url:"milestone,omitempty" json:"milestone,omitempty"`
Scope *string `url:"scope,omitempty" json:"scope,omitempty"`
AuthorID *int `url:"author_id,omitempty" json:"author_id,omitempty"`
AuthorUsername *string `url:"author_username,omitempty" json:"author_username,omitempty"`
}
u := fmt.Sprintf("groups/%s/issues_statistics", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues_statistics", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Arkbriar
+// Copyright 2021, Arkbriar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"bytes"
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/jobs", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opts, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipelines/%d/jobs", pathEscape(project), pipelineID)
- req, err := s.client.NewRequest("GET", u, opts, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipelines/%d/bridges", pathEscape(project), pipelineID)
- req, err := s.client.NewRequest("GET", u, opts, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/jobs/%d", pathEscape(project), jobID)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/jobs/%d/artifacts", pathEscape(project), jobID)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/jobs/artifacts/%s/download", pathEscape(project), refName)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
artifactPath,
)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/jobs/%d/trace", pathEscape(project), jobID)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/jobs/%d/cancel", pathEscape(project), jobID)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/jobs/%d/retry", pathEscape(project), jobID)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/jobs/%d/erase", pathEscape(project), jobID)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/jobs/%d/artifacts/keep", pathEscape(project), jobID)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/jobs/%d/play", pathEscape(project), jobID)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/jobs/%d/artifacts", pathEscape(project), jobID)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2018, Patrick Webster
+// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
func (s *KeysService) GetKeyWithUser(key int, options ...RequestOptionFunc) (*Key, *Response, error) {
u := fmt.Sprintf("keys/%d", key)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"encoding/json"
"fmt"
+ "net/http"
)
// LabelsService handles communication with the label related methods of the
}
u := fmt.Sprintf("projects/%s/labels", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/labels/%s", pathEscape(project), label)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/labels", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/labels", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/labels", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/labels/%s/subscribe", pathEscape(project), label)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/labels/%s/unsubscribe", pathEscape(project), label)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/labels/%s/promote", pathEscape(project), label)
- req, err := s.client.NewRequest("PUT", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2018, Patrick Webster
+// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package gitlab
-import "time"
+import (
+ "net/http"
+ "time"
+)
// LicenseService handles communication with the license
// related methods of the GitLab API.
// GitLab API docs:
// https://docs.gitlab.com/ee/api/license.html#retrieve-information-about-the-current-license
func (s *LicenseService) GetLicense() (*License, *Response, error) {
- req, err := s.client.NewRequest("GET", "license", nil, nil)
+ req, err := s.client.NewRequest(http.MethodGet, "license", nil, nil)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ee/api/license.html#add-a-new-license
func (s *LicenseService) AddLicense(opt *AddLicenseOptions, options ...RequestOptionFunc) (*License, *Response, error) {
- req, err := s.client.NewRequest("POST", "license", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "license", opt, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
)
// LicenseTemplate represents a license template.
// GitLab API docs:
// https://docs.gitlab.com/ce/api/templates/licenses.html#list-license-templates
func (s *LicenseTemplatesService) ListLicenseTemplates(opt *ListLicenseTemplatesOptions, options ...RequestOptionFunc) ([]*LicenseTemplate, *Response, error) {
- req, err := s.client.NewRequest("GET", "templates/licenses", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "templates/licenses", opt, options)
if err != nil {
return nil, nil, err
}
func (s *LicenseTemplatesService) GetLicenseTemplate(template string, opt *GetLicenseTemplateOptions, options ...RequestOptionFunc) (*LicenseTemplate, *Response, error) {
u := fmt.Sprintf("templates/licenses/%s", template)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approve", pathEscape(project), mr)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/unapprove", pathEscape(project), mr)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approvals", pathEscape(project), mr)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approvals", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approvers", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_state", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules/%d", pathEscape(project), mergeRequest, approvalRule)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules/%d", pathEscape(project), mergeRequest, approvalRule)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
Author *BasicUser `json:"author"`
Assignee *BasicUser `json:"assignee"`
Assignees []*BasicUser `json:"assignees"`
+ Reviewers []*BasicUser `json:"reviewers"`
SourceProjectID int `json:"source_project_id"`
TargetProjectID int `json:"target_project_id"`
Labels Labels `json:"labels"`
ChangesCount string `json:"changes_count"`
ShouldRemoveSourceBranch bool `json:"should_remove_source_branch"`
ForceRemoveSourceBranch bool `json:"force_remove_source_branch"`
+ AllowCollaboration bool `json:"allow_collaboration"`
WebURL string `json:"web_url"`
DiscussionLocked bool `json:"discussion_locked"`
Changes []struct {
Count int `json:"count"`
CompletedCount int `json:"completed_count"`
} `json:"task_completion_status"`
- HasConflicts bool `json:"has_conflicts"`
+ HasConflicts bool `json:"has_conflicts"`
+ BlockingDiscussionsResolved bool `json:"blocking_discussions_resolved"`
+ Overflow bool `json:"overflow"`
}
func (m MergeRequest) String() string {
Scope *string `url:"scope,omitempty" json:"scope,omitempty"`
AuthorID *int `url:"author_id,omitempty" json:"author_id,omitempty"`
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"`
+ ReviewerID *int `url:"reviewer_id,omitempty" json:"reviewer_id,omitempty"`
+ ReviewerUsername *string `url:"reviewer_username,omitempty" json:"reviewer_username,omitempty"`
MyReactionEmoji *string `url:"my_reaction_emoji,omitempty" json:"my_reaction_emoji,omitempty"`
SourceBranch *string `url:"source_branch,omitempty" json:"source_branch,omitempty"`
TargetBranch *string `url:"target_branch,omitempty" json:"target_branch,omitempty"`
// GitLab API docs:
// https://docs.gitlab.com/ce/api/merge_requests.html#list-merge-requests
func (s *MergeRequestsService) ListMergeRequests(opt *ListMergeRequestsOptions, options ...RequestOptionFunc) ([]*MergeRequest, *Response, error) {
- req, err := s.client.NewRequest("GET", "merge_requests", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "merge_requests", opt, options)
if err != nil {
return nil, nil, err
}
Scope *string `url:"scope,omitempty" json:"scope,omitempty"`
AuthorID *int `url:"author_id,omitempty" json:"author_id,omitempty"`
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"`
+ ReviewerID *int `url:"reviewer_id,omitempty" json:"reviewer_id,omitempty"`
+ ReviewerUsername *string `url:"reviewer_username,omitempty" json:"reviewer_username,omitempty"`
MyReactionEmoji *string `url:"my_reaction_emoji,omitempty" json:"my_reaction_emoji,omitempty"`
SourceBranch *string `url:"source_branch,omitempty" json:"source_branch,omitempty"`
TargetBranch *string `url:"target_branch,omitempty" json:"target_branch,omitempty"`
}
u := fmt.Sprintf("groups/%s/merge_requests", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
Scope *string `url:"scope,omitempty" json:"scope,omitempty"`
AuthorID *int `url:"author_id,omitempty" json:"author_id,omitempty"`
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"`
+ ReviewerID *int `url:"reviewer_id,omitempty" json:"reviewer_id,omitempty"`
+ ReviewerUsername *string `url:"reviewer_username,omitempty" json:"reviewer_username,omitempty"`
MyReactionEmoji *string `url:"my_reaction_emoji,omitempty" json:"my_reaction_emoji,omitempty"`
SourceBranch *string `url:"source_branch,omitempty" json:"source_branch,omitempty"`
TargetBranch *string `url:"target_branch,omitempty" json:"target_branch,omitempty"`
}
u := fmt.Sprintf("projects/%s/merge_requests", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/approvals", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/commits", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
return c, resp, err
}
+// GetMergeRequestChangesOptions represents the available GetMergeRequestChanges()
+// options.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ce/api/merge_requests.html#get-single-mr-changes
+type GetMergeRequestChangesOptions struct {
+ AccessRawDiffs *bool `url:"access_raw_diffs,omitempty" json:"access_raw_diffs,omitempty"`
+}
+
// GetMergeRequestChanges shows information about the merge request including
// its files and changes.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/merge_requests.html#get-single-mr-changes
-func (s *MergeRequestsService) GetMergeRequestChanges(pid interface{}, mergeRequest int, options ...RequestOptionFunc) (*MergeRequest, *Response, error) {
+func (s *MergeRequestsService) GetMergeRequestChanges(pid interface{}, mergeRequest int, opt *GetMergeRequestChangesOptions, options ...RequestOptionFunc) (*MergeRequest, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/changes", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/participants", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/pipelines", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/pipelines", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/closes_issues", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
Labels Labels `url:"labels,comma,omitempty" json:"labels,omitempty"`
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"`
AssigneeIDs []int `url:"assignee_ids,omitempty" json:"assignee_ids,omitempty"`
+ ReviewerIDs []int `url:"reviewer_ids,omitempty" json:"reviewer_ids,omitempty"`
TargetProjectID *int `url:"target_project_id,omitempty" json:"target_project_id,omitempty"`
MilestoneID *int `url:"milestone_id,omitempty" json:"milestone_id,omitempty"`
RemoveSourceBranch *bool `url:"remove_source_branch,omitempty" json:"remove_source_branch,omitempty"`
}
u := fmt.Sprintf("projects/%s/merge_requests", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
TargetBranch *string `url:"target_branch,omitempty" json:"target_branch,omitempty"`
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"`
AssigneeIDs []int `url:"assignee_ids,omitempty" json:"assignee_ids,omitempty"`
+ ReviewerIDs []int `url:"reviewer_ids,omitempty" json:"reviewer_ids,omitempty"`
Labels Labels `url:"labels,comma,omitempty" json:"labels,omitempty"`
AddLabels Labels `url:"add_labels,comma,omitempty" json:"add_labels,omitempty"`
RemoveLabels Labels `url:"remove_labels,comma,omitempty" json:"remove_labels,omitempty"`
}
u := fmt.Sprintf("projects/%s/merge_requests/%d", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/merge", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/cancel_merge_when_pipeline_succeeds", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("PUT", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/rebase", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("PUT", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/versions", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/versions/%d", pathEscape(project), mergeRequest, version)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/subscribe", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/unsubscribe", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/todo", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/milestones", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/milestones/%d", pathEscape(project), milestone)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/milestones", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/milestones/%d", pathEscape(project), milestone)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/milestones/%d", pathEscape(project), milestone)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/milestones/%d/issues", pathEscape(project), milestone)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/milestones/%d/merge_requests", pathEscape(project), milestone)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
)
// NamespacesService handles communication with the namespace related methods
//
// GitLab API docs: https://docs.gitlab.com/ce/api/namespaces.html#list-namespaces
func (s *NamespacesService) ListNamespaces(opt *ListNamespacesOptions, options ...RequestOptionFunc) ([]*Namespace, *Response, error) {
- req, err := s.client.NewRequest("GET", "namespaces", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "namespaces", opt, options)
if err != nil {
return nil, nil, err
}
}
q.Search = query
- req, err := s.client.NewRequest("GET", "namespaces", &q, options)
+ req, err := s.client.NewRequest(http.MethodGet, "namespaces", &q, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("namespaces/%s", namespace)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/issues/%d/notes", pathEscape(project), issue)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d/notes/%d", pathEscape(project), issue, note)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d/notes", pathEscape(project), issue)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d/notes/%d", pathEscape(project), issue, note)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d/notes/%d", pathEscape(project), issue, note)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets/%d/notes", pathEscape(project), snippet)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets/%d/notes/%d", pathEscape(project), snippet, note)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets/%d/notes", pathEscape(project), snippet)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets/%d/notes/%d", pathEscape(project), snippet, note)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets/%d/notes/%d", pathEscape(project), snippet, note)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/notes", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/notes/%d", pathEscape(project), mergeRequest, note)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/notes", pathEscape(project), mergeRequest)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf(
"projects/%s/merge_requests/%d/notes/%d", pathEscape(project), mergeRequest, note)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf(
"projects/%s/merge_requests/%d/notes/%d", pathEscape(project), mergeRequest, note)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d/notes", pathEscape(group), epic)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d/notes/%d", pathEscape(group), epic, note)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d/notes", pathEscape(group), epic)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d/notes/%d", pathEscape(group), epic, note)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d/notes/%d", pathEscape(group), epic, note)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"errors"
"fmt"
+ "net/http"
)
// NotificationSettingsService handles communication with the notification settings
func (s *NotificationSettingsService) GetGlobalSettings(options ...RequestOptionFunc) (*NotificationSettings, *Response, error) {
u := "notification_settings"
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
u := "notification_settings"
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/notification_settings", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/notification_settings", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/notification_settings", pathEscape(group))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/notification_settings", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
--- /dev/null
+//
+// Copyright 2021, Kordian Bruck
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package gitlab
+
+import (
+ "fmt"
+ "net/http"
+ "time"
+)
+
+// PackagesService handles communication with the packages related methods
+// of the GitLab API.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/packages.html
+type PackagesService struct {
+ client *Client
+}
+
+// Package represents a GitLab single package.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/packages.html
+type Package struct {
+ ID int `json:"id"`
+ Name string `json:"name"`
+ Version string `json:"version"`
+ PackageType string `json:"package_type"`
+ Links *PackageLinks `json:"_links"`
+ CreatedAt *time.Time `json:"created_at"`
+}
+
+func (s Package) String() string {
+ return Stringify(s)
+}
+
+// PackageLinks holds links for itself and deleting.
+type PackageLinks struct {
+ WebPath string `json:"web_path"`
+ DeleteAPIPath string `json:"delete_api_path"`
+}
+
+func (s PackageLinks) String() string {
+ return Stringify(s)
+}
+
+// PackageFile represents one file contained within a package.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/packages.html
+type PackageFile struct {
+ ID int `json:"id"`
+ PackageID int `json:"package_id"`
+ CreatedAt *time.Time `json:"created_at"`
+ FileName string `json:"file_name"`
+ Size int `json:"size"`
+ FileMD5 string `json:"file_md5"`
+ FileSHA1 string `json:"file_sha1"`
+ Pipeline *[]Pipeline `json:"pipelines"`
+}
+
+func (s PackageFile) String() string {
+ return Stringify(s)
+}
+
+// ListProjectPackagesOptions are the parameters available in a ListProjectPackages() Operation.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/packages.html#within-a-project
+type ListProjectPackagesOptions struct {
+ ListOptions
+ OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
+ Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
+ PackageType *string `url:"package_type,omitempty" json:"package_type,omitempty"`
+ PackageName *string `url:"package_name,omitempty" json:"package_name,omitempty"`
+ IncludeVersionless *bool `url:"include_versionless,omitempty" json:"include_versionless,omitempty"`
+}
+
+// ListProjectPackages gets a list of packages in a project.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/packages.html#within-a-project
+func (s *PackagesService) ListProjectPackages(pid interface{}, opt *ListProjectPackagesOptions, options ...RequestOptionFunc) ([]*Package, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/packages", pathEscape(project))
+
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var ps []*Package
+ resp, err := s.client.Do(req, &ps)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return ps, resp, err
+}
+
+// ListPackageFilesOptions represents the available
+// ListPackageFiles() options.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/packages.html#list-package-files
+type ListPackageFilesOptions ListOptions
+
+// ListPackageFiles gets a list of files that are within a package
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/packages.html#list-package-files
+func (s *PackagesService) ListPackageFiles(pid interface{}, pkg int, opt *ListPackageFilesOptions, options ...RequestOptionFunc) ([]*PackageFile, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf(
+ "projects/%s/packages/%d/package_files",
+ pathEscape(project),
+ pkg,
+ )
+
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var pfs []*PackageFile
+ resp, err := s.client.Do(req, &pfs)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return pfs, resp, err
+}
+
+// DeleteProjectPackage deletes a package in a project.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/packages.html#delete-a-project-package
+func (s *PackagesService) DeleteProjectPackage(pid interface{}, pkg int, options ...RequestOptionFunc) (*Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, err
+ }
+ u := fmt.Sprintf("projects/%s/packages/%d", pathEscape(project), pkg)
+
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
+ if err != nil {
+ return nil, err
+ }
+
+ return s.client.Do(req, nil)
+}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/pages/domains", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/pages_domains.html#list-all-pages-domains
func (s *PagesDomainsService) ListAllPagesDomains(options ...RequestOptionFunc) ([]*PagesDomain, *Response, error) {
- req, err := s.client.NewRequest("GET", "pages/domains", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "pages/domains", nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pages/domains/%s", pathEscape(project), domain)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pages/domains", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pages/domains/%s", pathEscape(project), domain)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pages/domains/%s", pathEscape(project), domain)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2018, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/pipeline_schedules", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d", pathEscape(project), schedule)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipeline_schedules", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d", pathEscape(project), schedule)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/take_ownership", pathEscape(project), schedule)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d", pathEscape(project), schedule)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/play", pathEscape(project), schedule)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/variables", pathEscape(project), schedule)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/variables/%s", pathEscape(project), schedule, key)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/variables/%s", pathEscape(project), schedule, key)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/triggers", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/triggers/%d", pathEscape(project), trigger)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/triggers", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/triggers/%d", pathEscape(project), trigger)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/triggers/%d/take_ownership", pathEscape(project), trigger)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/triggers/%d", pathEscape(project), trigger)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/trigger/pipeline", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Igor Varavko
+// Copyright 2021, Igor Varavko
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/pipelines", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipelines/%d", pathEscape(project), pipeline)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipelines/%d/variables", pathEscape(project), pipeline)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipelines/%d/test_report", pathEscape(project), pipeline)
- req, err := s.client.NewRequest("GET", u, nil, nil)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, nil)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipeline", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipelines/%d/retry", pathEscape(project), pipeline)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipelines/%d/cancel", pathEscape(project), pipeline)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/pipelines/%d", pathEscape(project), pipeline)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
)
// ProjectBadge represents a project badge.
}
u := fmt.Sprintf("projects/%s/badges", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/badges/%d", pathEscape(project), badge)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/badges", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/badges/%d", pathEscape(project), badge)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/badges/%d", pathEscape(project), badge)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/badges/render", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2019, Matej Velikonja
+// Copyright 2021, Matej Velikonja
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/clusters", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/clusters/%d", pathEscape(project), cluster)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/clusters/user", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/clusters/%d", pathEscape(project), cluster)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/clusters/%d", pathEscape(project), cluster)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"bytes"
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/export", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/export", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/export/download", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/project_import_export.html#import-a-file
func (s *ProjectImportExportService) ImportFile(opt *ImportFileOptions, options ...RequestOptionFunc) (*ImportStatus, *Response, error) {
- req, err := s.client.NewRequest("POST", "projects/import", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "projects/import", opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/import", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
)
// ProjectMembersService handles communication with the project members
}
u := fmt.Sprintf("projects/%s/members", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/members/all", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/members/%d", pathEscape(project), user)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/members/all/%d", pathEscape(project), user)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/members.html#add-a-member-to-a-group-or-project
type AddProjectMemberOptions struct {
- UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"`
+ UserID interface{} `url:"user_id,omitempty" json:"user_id,omitempty"`
AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
ExpiresAt *string `url:"expires_at,omitempty" json:"expires_at"`
}
}
u := fmt.Sprintf("projects/%s/members", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/members/%d", pathEscape(project), user)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/members/%d", pathEscape(project), user)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/remote_mirrors", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/remote_mirrors", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/remote_mirrors/%d", pathEscape(project), mirror)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"bytes"
"fmt"
+ "net/http"
)
// ProjectSnippetsService handles communication with the project snippets
}
u := fmt.Sprintf("projects/%s/snippets", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets/%d", pathEscape(project), snippet)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets/%d", pathEscape(project), snippet)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets/%d", pathEscape(project), snippet)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/snippets/%d/raw", pathEscape(project), snippet)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2018, Patrick Webster
+// Copyright 2021, Patrick Webster
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"net/url"
)
}
u := fmt.Sprintf("projects/%s/variables", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/variables/%s", pathEscape(project), url.PathEscape(key))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/variables", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/variables/%s", pathEscape(project), url.PathEscape(key))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/variables/%s", pathEscape(project), url.PathEscape(key))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
"io"
"io/ioutil"
"mime/multipart"
+ "net/http"
"os"
"time"
)
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html
type Project struct {
- ID int `json:"id"`
- Description string `json:"description"`
- DefaultBranch string `json:"default_branch"`
- Public bool `json:"public"`
- Visibility VisibilityValue `json:"visibility"`
- SSHURLToRepo string `json:"ssh_url_to_repo"`
- HTTPURLToRepo string `json:"http_url_to_repo"`
- WebURL string `json:"web_url"`
- ReadmeURL string `json:"readme_url"`
- TagList []string `json:"tag_list"`
- Owner *User `json:"owner"`
- Name string `json:"name"`
- NameWithNamespace string `json:"name_with_namespace"`
- Path string `json:"path"`
- PathWithNamespace string `json:"path_with_namespace"`
- IssuesEnabled bool `json:"issues_enabled"`
- OpenIssuesCount int `json:"open_issues_count"`
- MergeRequestsEnabled bool `json:"merge_requests_enabled"`
- ApprovalsBeforeMerge int `json:"approvals_before_merge"`
- JobsEnabled bool `json:"jobs_enabled"`
- WikiEnabled bool `json:"wiki_enabled"`
- SnippetsEnabled bool `json:"snippets_enabled"`
- ResolveOutdatedDiffDiscussions bool `json:"resolve_outdated_diff_discussions"`
- ContainerRegistryEnabled bool `json:"container_registry_enabled"`
- CreatedAt *time.Time `json:"created_at,omitempty"`
- LastActivityAt *time.Time `json:"last_activity_at,omitempty"`
- CreatorID int `json:"creator_id"`
- Namespace *ProjectNamespace `json:"namespace"`
- ImportStatus string `json:"import_status"`
- ImportError string `json:"import_error"`
- Permissions *Permissions `json:"permissions"`
- MarkedForDeletionAt *ISOTime `json:"marked_for_deletion_at"`
- Archived bool `json:"archived"`
- AvatarURL string `json:"avatar_url"`
- SharedRunnersEnabled bool `json:"shared_runners_enabled"`
- ForksCount int `json:"forks_count"`
- StarCount int `json:"star_count"`
- RunnersToken string `json:"runners_token"`
- PublicBuilds bool `json:"public_builds"`
- AllowMergeOnSkippedPipeline bool `json:"allow_merge_on_skipped_pipeline"`
- OnlyAllowMergeIfPipelineSucceeds bool `json:"only_allow_merge_if_pipeline_succeeds"`
- OnlyAllowMergeIfAllDiscussionsAreResolved bool `json:"only_allow_merge_if_all_discussions_are_resolved"`
- RemoveSourceBranchAfterMerge bool `json:"remove_source_branch_after_merge"`
- LFSEnabled bool `json:"lfs_enabled"`
- RequestAccessEnabled bool `json:"request_access_enabled"`
- MergeMethod MergeMethodValue `json:"merge_method"`
- ForkedFromProject *ForkParent `json:"forked_from_project"`
- Mirror bool `json:"mirror"`
- MirrorUserID int `json:"mirror_user_id"`
- MirrorTriggerBuilds bool `json:"mirror_trigger_builds"`
- OnlyMirrorProtectedBranches bool `json:"only_mirror_protected_branches"`
- MirrorOverwritesDivergedBranches bool `json:"mirror_overwrites_diverged_branches"`
- PackagesEnabled bool `json:"packages_enabled"`
- ServiceDeskEnabled bool `json:"service_desk_enabled"`
- ServiceDeskAddress string `json:"service_desk_address"`
- IssuesAccessLevel AccessControlValue `json:"issues_access_level"`
- RepositoryAccessLevel AccessControlValue `json:"repository_access_level"`
- MergeRequestsAccessLevel AccessControlValue `json:"merge_requests_access_level"`
- ForkingAccessLevel AccessControlValue `json:"forking_access_level"`
- WikiAccessLevel AccessControlValue `json:"wiki_access_level"`
- BuildsAccessLevel AccessControlValue `json:"builds_access_level"`
- SnippetsAccessLevel AccessControlValue `json:"snippets_access_level"`
- PagesAccessLevel AccessControlValue `json:"pages_access_level"`
- AutocloseReferencedIssues bool `json:"autoclose_referenced_issues"`
- CIForwardDeploymentEnabled bool `json:"ci_forward_deployment_enabled"`
+ ID int `json:"id"`
+ Description string `json:"description"`
+ DefaultBranch string `json:"default_branch"`
+ Public bool `json:"public"`
+ Visibility VisibilityValue `json:"visibility"`
+ SSHURLToRepo string `json:"ssh_url_to_repo"`
+ HTTPURLToRepo string `json:"http_url_to_repo"`
+ WebURL string `json:"web_url"`
+ ReadmeURL string `json:"readme_url"`
+ TagList []string `json:"tag_list"`
+ Owner *User `json:"owner"`
+ Name string `json:"name"`
+ NameWithNamespace string `json:"name_with_namespace"`
+ Path string `json:"path"`
+ PathWithNamespace string `json:"path_with_namespace"`
+ IssuesEnabled bool `json:"issues_enabled"`
+ OpenIssuesCount int `json:"open_issues_count"`
+ MergeRequestsEnabled bool `json:"merge_requests_enabled"`
+ ApprovalsBeforeMerge int `json:"approvals_before_merge"`
+ JobsEnabled bool `json:"jobs_enabled"`
+ WikiEnabled bool `json:"wiki_enabled"`
+ SnippetsEnabled bool `json:"snippets_enabled"`
+ ResolveOutdatedDiffDiscussions bool `json:"resolve_outdated_diff_discussions"`
+ ContainerExpirationPolicy *ContainerExpirationPolicy `json:"container_expiration_policy,omitempty"`
+ ContainerRegistryEnabled bool `json:"container_registry_enabled"`
+ CreatedAt *time.Time `json:"created_at,omitempty"`
+ LastActivityAt *time.Time `json:"last_activity_at,omitempty"`
+ CreatorID int `json:"creator_id"`
+ Namespace *ProjectNamespace `json:"namespace"`
+ ImportStatus string `json:"import_status"`
+ ImportError string `json:"import_error"`
+ Permissions *Permissions `json:"permissions"`
+ MarkedForDeletionAt *ISOTime `json:"marked_for_deletion_at"`
+ EmptyRepo bool `json:"empty_repo"`
+ Archived bool `json:"archived"`
+ AvatarURL string `json:"avatar_url"`
+ SharedRunnersEnabled bool `json:"shared_runners_enabled"`
+ ForksCount int `json:"forks_count"`
+ StarCount int `json:"star_count"`
+ RunnersToken string `json:"runners_token"`
+ PublicBuilds bool `json:"public_builds"`
+ AllowMergeOnSkippedPipeline bool `json:"allow_merge_on_skipped_pipeline"`
+ OnlyAllowMergeIfPipelineSucceeds bool `json:"only_allow_merge_if_pipeline_succeeds"`
+ OnlyAllowMergeIfAllDiscussionsAreResolved bool `json:"only_allow_merge_if_all_discussions_are_resolved"`
+ RemoveSourceBranchAfterMerge bool `json:"remove_source_branch_after_merge"`
+ LFSEnabled bool `json:"lfs_enabled"`
+ RequestAccessEnabled bool `json:"request_access_enabled"`
+ MergeMethod MergeMethodValue `json:"merge_method"`
+ ForkedFromProject *ForkParent `json:"forked_from_project"`
+ Mirror bool `json:"mirror"`
+ MirrorUserID int `json:"mirror_user_id"`
+ MirrorTriggerBuilds bool `json:"mirror_trigger_builds"`
+ OnlyMirrorProtectedBranches bool `json:"only_mirror_protected_branches"`
+ MirrorOverwritesDivergedBranches bool `json:"mirror_overwrites_diverged_branches"`
+ PackagesEnabled bool `json:"packages_enabled"`
+ ServiceDeskEnabled bool `json:"service_desk_enabled"`
+ ServiceDeskAddress string `json:"service_desk_address"`
+ IssuesAccessLevel AccessControlValue `json:"issues_access_level"`
+ RepositoryAccessLevel AccessControlValue `json:"repository_access_level"`
+ MergeRequestsAccessLevel AccessControlValue `json:"merge_requests_access_level"`
+ ForkingAccessLevel AccessControlValue `json:"forking_access_level"`
+ WikiAccessLevel AccessControlValue `json:"wiki_access_level"`
+ BuildsAccessLevel AccessControlValue `json:"builds_access_level"`
+ SnippetsAccessLevel AccessControlValue `json:"snippets_access_level"`
+ PagesAccessLevel AccessControlValue `json:"pages_access_level"`
+ OperationsAccessLevel AccessControlValue `json:"operations_access_level"`
+ AutocloseReferencedIssues bool `json:"autoclose_referenced_issues"`
+ CIForwardDeploymentEnabled bool `json:"ci_forward_deployment_enabled"`
SharedWithGroups []struct {
GroupID int `json:"group_id"`
GroupName string `json:"group_name"`
ComplianceFrameworks []string `json:"compliance_frameworks"`
}
+// ContainerExpirationPolicy represents the container expiration policy.
+type ContainerExpirationPolicy struct {
+ Cadence string `json:"cadence"`
+ KeepN int `json:"keep_n"`
+ OlderThan string `json:"older_than"`
+ NameRegexDelete string `json:"name_regex_delete"`
+ NameRegexKeep string `json:"name_regex_keep"`
+ Enabled bool `json:"enabled"`
+ NextRunAt *time.Time `json:"next_run_at"`
+}
+
// Repository represents a repository.
type Repository struct {
Name string `json:"name"`
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#list-projects
func (s *ProjectsService) ListProjects(opt *ListProjectsOptions, options ...RequestOptionFunc) ([]*Project, *Response, error) {
- req, err := s.client.NewRequest("GET", "projects", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "projects", opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("users/%s/projects", user)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/users", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/languages", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/events", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
//
// GitLab API docs: https://docs.gitlab.com/ee/api/projects.html#create-project
type CreateProjectOptions struct {
- Name *string `url:"name,omitempty" json:"name,omitempty"`
- Path *string `url:"path,omitempty" json:"path,omitempty"`
- NamespaceID *int `url:"namespace_id,omitempty" json:"namespace_id,omitempty"`
- DefaultBranch *string `url:"default_branch,omitempty" json:"default_branch,omitempty"`
- Description *string `url:"description,omitempty" json:"description,omitempty"`
- IssuesAccessLevel *AccessControlValue `url:"issues_access_level,omitempty" json:"issues_access_level,omitempty"`
- RepositoryAccessLevel *AccessControlValue `url:"repository_access_level,omitempty" json:"repository_access_level,omitempty"`
- MergeRequestsAccessLevel *AccessControlValue `url:"merge_requests_access_level,omitempty" json:"merge_requests_access_level,omitempty"`
- ForkingAccessLevel *AccessControlValue `url:"forking_access_level,omitempty" json:"forking_access_level,omitempty"`
- BuildsAccessLevel *AccessControlValue `url:"builds_access_level,omitempty" json:"builds_access_level,omitempty"`
- WikiAccessLevel *AccessControlValue `url:"wiki_access_level,omitempty" json:"wiki_access_level,omitempty"`
- SnippetsAccessLevel *AccessControlValue `url:"snippets_access_level,omitempty" json:"snippets_access_level,omitempty"`
- PagesAccessLevel *AccessControlValue `url:"pages_access_level,omitempty" json:"pages_access_level,omitempty"`
- EmailsDisabled *bool `url:"emails_disabled,omitempty" json:"emails_disabled,omitempty"`
- ResolveOutdatedDiffDiscussions *bool `url:"resolve_outdated_diff_discussions,omitempty" json:"resolve_outdated_diff_discussions,omitempty"`
- ContainerRegistryEnabled *bool `url:"container_registry_enabled,omitempty" json:"container_registry_enabled,omitempty"`
- SharedRunnersEnabled *bool `url:"shared_runners_enabled,omitempty" json:"shared_runners_enabled,omitempty"`
- Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
- ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
- PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"`
- AllowMergeOnSkippedPipeline *bool `url:"allow_merge_on_skipped_pipeline,omitempty" json:"allow_merge_on_skipped_pipeline,omitempty"`
- OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"`
- OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"`
- MergeMethod *MergeMethodValue `url:"merge_method,omitempty" json:"merge_method,omitempty"`
- RemoveSourceBranchAfterMerge *bool `url:"remove_source_branch_after_merge,omitempty" json:"remove_source_branch_after_merge,omitempty"`
- LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"`
- RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"`
- TagList *[]string `url:"tag_list,omitempty" json:"tag_list,omitempty"`
- PrintingMergeRequestLinkEnabled *bool `url:"printing_merge_request_link_enabled,omitempty" json:"printing_merge_request_link_enabled,omitempty"`
- BuildGitStrategy *string `url:"build_git_strategy,omitempty" json:"build_git_strategy,omitempty"`
- BuildTimeout *int `url:"build_timeout,omitempty" json:"build_timeout,omitempty"`
- AutoCancelPendingPipelines *string `url:"auto_cancel_pending_pipelines,omitempty" json:"auto_cancel_pending_pipelines,omitempty"`
- BuildCoverageRegex *string `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"`
- CIConfigPath *string `url:"ci_config_path,omitempty" json:"ci_config_path,omitempty"`
- CIForwardDeploymentEnabled *bool `url:"ci_forward_deployment_enabled,omitempty" json:"ci_forward_deployment_enabled,omitempty"`
- AutoDevopsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"`
- AutoDevopsDeployStrategy *string `url:"auto_devops_deploy_strategy,omitempty" json:"auto_devops_deploy_strategy,omitempty"`
- ApprovalsBeforeMerge *int `url:"approvals_before_merge,omitempty" json:"approvals_before_merge,omitempty"`
- ExternalAuthorizationClassificationLabel *string `url:"external_authorization_classification_label,omitempty" json:"external_authorization_classification_label,omitempty"`
- Mirror *bool `url:"mirror,omitempty" json:"mirror,omitempty"`
- MirrorTriggerBuilds *bool `url:"mirror_trigger_builds,omitempty" json:"mirror_trigger_builds,omitempty"`
- InitializeWithReadme *bool `url:"initialize_with_readme,omitempty" json:"initialize_with_readme,omitempty"`
- TemplateName *string `url:"template_name,omitempty" json:"template_name,omitempty"`
- TemplateProjectID *int `url:"template_project_id,omitempty" json:"template_project_id,omitempty"`
- UseCustomTemplate *bool `url:"use_custom_template,omitempty" json:"use_custom_template,omitempty"`
- GroupWithProjectTemplatesID *int `url:"group_with_project_templates_id,omitempty" json:"group_with_project_templates_id,omitempty"`
- PackagesEnabled *bool `url:"packages_enabled,omitempty" json:"packages_enabled,omitempty"`
- ServiceDeskEnabled *bool `url:"service_desk_enabled,omitempty" json:"service_desk_enabled,omitempty"`
- AutocloseReferencedIssues *bool `url:"autoclose_referenced_issues,omitempty" json:"autoclose_referenced_issues,omitempty"`
+ Name *string `url:"name,omitempty" json:"name,omitempty"`
+ Path *string `url:"path,omitempty" json:"path,omitempty"`
+ NamespaceID *int `url:"namespace_id,omitempty" json:"namespace_id,omitempty"`
+ DefaultBranch *string `url:"default_branch,omitempty" json:"default_branch,omitempty"`
+ Description *string `url:"description,omitempty" json:"description,omitempty"`
+ IssuesAccessLevel *AccessControlValue `url:"issues_access_level,omitempty" json:"issues_access_level,omitempty"`
+ RepositoryAccessLevel *AccessControlValue `url:"repository_access_level,omitempty" json:"repository_access_level,omitempty"`
+ MergeRequestsAccessLevel *AccessControlValue `url:"merge_requests_access_level,omitempty" json:"merge_requests_access_level,omitempty"`
+ ForkingAccessLevel *AccessControlValue `url:"forking_access_level,omitempty" json:"forking_access_level,omitempty"`
+ BuildsAccessLevel *AccessControlValue `url:"builds_access_level,omitempty" json:"builds_access_level,omitempty"`
+ WikiAccessLevel *AccessControlValue `url:"wiki_access_level,omitempty" json:"wiki_access_level,omitempty"`
+ SnippetsAccessLevel *AccessControlValue `url:"snippets_access_level,omitempty" json:"snippets_access_level,omitempty"`
+ PagesAccessLevel *AccessControlValue `url:"pages_access_level,omitempty" json:"pages_access_level,omitempty"`
+ OperationsAccessLevel *AccessControlValue `url:"operations_access_level,omitempty" json:"operations_access_level,omitempty"`
+ EmailsDisabled *bool `url:"emails_disabled,omitempty" json:"emails_disabled,omitempty"`
+ ResolveOutdatedDiffDiscussions *bool `url:"resolve_outdated_diff_discussions,omitempty" json:"resolve_outdated_diff_discussions,omitempty"`
+ ContainerExpirationPolicyAttributes *ContainerExpirationPolicyAttributes `url:"container_expiration_policy_attributes,omitempty" json:"container_expiration_policy_attributes,omitempty"`
+ ContainerRegistryEnabled *bool `url:"container_registry_enabled,omitempty" json:"container_registry_enabled,omitempty"`
+ SharedRunnersEnabled *bool `url:"shared_runners_enabled,omitempty" json:"shared_runners_enabled,omitempty"`
+ Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
+ ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
+ PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"`
+ AllowMergeOnSkippedPipeline *bool `url:"allow_merge_on_skipped_pipeline,omitempty" json:"allow_merge_on_skipped_pipeline,omitempty"`
+ OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"`
+ OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"`
+ MergeMethod *MergeMethodValue `url:"merge_method,omitempty" json:"merge_method,omitempty"`
+ RemoveSourceBranchAfterMerge *bool `url:"remove_source_branch_after_merge,omitempty" json:"remove_source_branch_after_merge,omitempty"`
+ LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"`
+ RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"`
+ TagList *[]string `url:"tag_list,omitempty" json:"tag_list,omitempty"`
+ PrintingMergeRequestLinkEnabled *bool `url:"printing_merge_request_link_enabled,omitempty" json:"printing_merge_request_link_enabled,omitempty"`
+ BuildGitStrategy *string `url:"build_git_strategy,omitempty" json:"build_git_strategy,omitempty"`
+ BuildTimeout *int `url:"build_timeout,omitempty" json:"build_timeout,omitempty"`
+ AutoCancelPendingPipelines *string `url:"auto_cancel_pending_pipelines,omitempty" json:"auto_cancel_pending_pipelines,omitempty"`
+ BuildCoverageRegex *string `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"`
+ CIConfigPath *string `url:"ci_config_path,omitempty" json:"ci_config_path,omitempty"`
+ CIForwardDeploymentEnabled *bool `url:"ci_forward_deployment_enabled,omitempty" json:"ci_forward_deployment_enabled,omitempty"`
+ AutoDevopsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"`
+ AutoDevopsDeployStrategy *string `url:"auto_devops_deploy_strategy,omitempty" json:"auto_devops_deploy_strategy,omitempty"`
+ ApprovalsBeforeMerge *int `url:"approvals_before_merge,omitempty" json:"approvals_before_merge,omitempty"`
+ ExternalAuthorizationClassificationLabel *string `url:"external_authorization_classification_label,omitempty" json:"external_authorization_classification_label,omitempty"`
+ Mirror *bool `url:"mirror,omitempty" json:"mirror,omitempty"`
+ MirrorTriggerBuilds *bool `url:"mirror_trigger_builds,omitempty" json:"mirror_trigger_builds,omitempty"`
+ InitializeWithReadme *bool `url:"initialize_with_readme,omitempty" json:"initialize_with_readme,omitempty"`
+ TemplateName *string `url:"template_name,omitempty" json:"template_name,omitempty"`
+ TemplateProjectID *int `url:"template_project_id,omitempty" json:"template_project_id,omitempty"`
+ UseCustomTemplate *bool `url:"use_custom_template,omitempty" json:"use_custom_template,omitempty"`
+ GroupWithProjectTemplatesID *int `url:"group_with_project_templates_id,omitempty" json:"group_with_project_templates_id,omitempty"`
+ PackagesEnabled *bool `url:"packages_enabled,omitempty" json:"packages_enabled,omitempty"`
+ ServiceDeskEnabled *bool `url:"service_desk_enabled,omitempty" json:"service_desk_enabled,omitempty"`
+ AutocloseReferencedIssues *bool `url:"autoclose_referenced_issues,omitempty" json:"autoclose_referenced_issues,omitempty"`
// Deprecated members
IssuesEnabled *bool `url:"issues_enabled,omitempty" json:"issues_enabled,omitempty"`
SnippetsEnabled *bool `url:"snippets_enabled,omitempty" json:"snippets_enabled,omitempty"`
}
+// ContainerExpirationPolicyAttributes represents the available container
+// expiration policy attributes.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/projects.html#create-project
+type ContainerExpirationPolicyAttributes struct {
+ Cadence *string `url:"cadence,omitempty" json:"cadence,omitempty"`
+ KeepN *int `url:"keep_n,omitempty" json:"keep_n,omitempty"`
+ OlderThan *string `url:"older_than,omitempty" json:"older_than,omitempty"`
+ NameRegexDelete *string `url:"name_regex_delete,omitempty" json:"name_regex_delete,omitempty"`
+ NameRegexKeep *string `url:"name_regex_keep,omitempty" json:"name_regex_keep,omitempty"`
+ Enabled *bool `url:"enabled,omitempty" json:"enabled,omitempty"`
+
+ // Deprecated members
+ NameRegex *string `url:"name_regex,omitempty" json:"name_regex,omitempty"`
+}
+
// CreateProject creates a new project owned by the authenticated user.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#create-project
func (s *ProjectsService) CreateProject(opt *CreateProjectOptions, options ...RequestOptionFunc) (*Project, *Response, error) {
- req, err := s.client.NewRequest("POST", "projects", opt, options)
+ if opt.ContainerExpirationPolicyAttributes != nil {
+ // This is needed to satisfy the API. Should be deleted
+ // when NameRegex is removed (it's now deprecated).
+ opt.ContainerExpirationPolicyAttributes.NameRegex =
+ opt.ContainerExpirationPolicyAttributes.NameRegexDelete
+ }
+
+ req, err := s.client.NewRequest(http.MethodPost, "projects", opt, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/projects.html#create-project-for-user
func (s *ProjectsService) CreateProjectForUser(user int, opt *CreateProjectForUserOptions, options ...RequestOptionFunc) (*Project, *Response, error) {
- u := fmt.Sprintf("projects/user/%d", user)
+ if opt.ContainerExpirationPolicyAttributes != nil {
+ // This is needed to satisfy the API. Should be deleted
+ // when NameRegex is removed (it's now deprecated).
+ opt.ContainerExpirationPolicyAttributes.NameRegex =
+ opt.ContainerExpirationPolicyAttributes.NameRegexDelete
+ }
- req, err := s.client.NewRequest("POST", u, opt, options)
+ u := fmt.Sprintf("projects/user/%d", user)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#edit-project
type EditProjectOptions struct {
- Name *string `url:"name,omitempty" json:"name,omitempty"`
- Path *string `url:"path,omitempty" json:"path,omitempty"`
- DefaultBranch *string `url:"default_branch,omitempty" json:"default_branch,omitempty"`
- Description *string `url:"description,omitempty" json:"description,omitempty"`
- IssuesAccessLevel *AccessControlValue `url:"issues_access_level,omitempty" json:"issues_access_level,omitempty"`
- RepositoryAccessLevel *AccessControlValue `url:"repository_access_level,omitempty" json:"repository_access_level,omitempty"`
- MergeRequestsAccessLevel *AccessControlValue `url:"merge_requests_access_level,omitempty" json:"merge_requests_access_level,omitempty"`
- ForkingAccessLevel *AccessControlValue `url:"forking_access_level,omitempty" json:"forking_access_level,omitempty"`
- BuildsAccessLevel *AccessControlValue `url:"builds_access_level,omitempty" json:"builds_access_level,omitempty"`
- WikiAccessLevel *AccessControlValue `url:"wiki_access_level,omitempty" json:"wiki_access_level,omitempty"`
- SnippetsAccessLevel *AccessControlValue `url:"snippets_access_level,omitempty" json:"snippets_access_level,omitempty"`
- PagesAccessLevel *AccessControlValue `url:"pages_access_level,omitempty" json:"pages_access_level,omitempty"`
- EmailsDisabled *bool `url:"emails_disabled,omitempty" json:"emails_disabled,omitempty"`
- ResolveOutdatedDiffDiscussions *bool `url:"resolve_outdated_diff_discussions,omitempty" json:"resolve_outdated_diff_discussions,omitempty"`
- ContainerRegistryEnabled *bool `url:"container_registry_enabled,omitempty" json:"container_registry_enabled,omitempty"`
- SharedRunnersEnabled *bool `url:"shared_runners_enabled,omitempty" json:"shared_runners_enabled,omitempty"`
- Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
- ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
- PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"`
- AllowMergeOnSkippedPipeline *bool `url:"allow_merge_on_skipped_pipeline,omitempty" json:"allow_merge_on_skipped_pipeline,omitempty"`
- OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"`
- OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"`
- MergeMethod *MergeMethodValue `url:"merge_method,omitempty" json:"merge_method,omitempty"`
- RemoveSourceBranchAfterMerge *bool `url:"remove_source_branch_after_merge,omitempty" json:"remove_source_branch_after_merge,omitempty"`
- LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"`
- RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"`
- TagList *[]string `url:"tag_list,omitempty" json:"tag_list,omitempty"`
- BuildGitStrategy *string `url:"build_git_strategy,omitempty" json:"build_git_strategy,omitempty"`
- BuildTimeout *int `url:"build_timeout,omitempty" json:"build_timeout,omitempty"`
- AutoCancelPendingPipelines *string `url:"auto_cancel_pending_pipelines,omitempty" json:"auto_cancel_pending_pipelines,omitempty"`
- BuildCoverageRegex *string `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"`
- CIConfigPath *string `url:"ci_config_path,omitempty" json:"ci_config_path,omitempty"`
- CIForwardDeploymentEnabled *bool `url:"ci_forward_deployment_enabled,omitempty" json:"ci_forward_deployment_enabled,omitempty"`
- CIDefaultGitDepth *int `url:"ci_default_git_depth,omitempty" json:"ci_default_git_depth,omitempty"`
- AutoDevopsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"`
- AutoDevopsDeployStrategy *string `url:"auto_devops_deploy_strategy,omitempty" json:"auto_devops_deploy_strategy,omitempty"`
- ApprovalsBeforeMerge *int `url:"approvals_before_merge,omitempty" json:"approvals_before_merge,omitempty"`
- ExternalAuthorizationClassificationLabel *string `url:"external_authorization_classification_label,omitempty" json:"external_authorization_classification_label,omitempty"`
- Mirror *bool `url:"mirror,omitempty" json:"mirror,omitempty"`
- MirrorUserID *int `url:"mirror_user_id,omitempty" json:"mirror_user_id,omitempty"`
- MirrorTriggerBuilds *bool `url:"mirror_trigger_builds,omitempty" json:"mirror_trigger_builds,omitempty"`
- OnlyMirrorProtectedBranches *bool `url:"only_mirror_protected_branches,omitempty" json:"only_mirror_protected_branches,omitempty"`
- MirrorOverwritesDivergedBranches *bool `url:"mirror_overwrites_diverged_branches,omitempty" json:"mirror_overwrites_diverged_branches,omitempty"`
- PackagesEnabled *bool `url:"packages_enabled,omitempty" json:"packages_enabled,omitempty"`
- ServiceDeskEnabled *bool `url:"service_desk_enabled,omitempty" json:"service_desk_enabled,omitempty"`
- AutocloseReferencedIssues *bool `url:"autoclose_referenced_issues,omitempty" json:"autoclose_referenced_issues,omitempty"`
+ Name *string `url:"name,omitempty" json:"name,omitempty"`
+ Path *string `url:"path,omitempty" json:"path,omitempty"`
+ DefaultBranch *string `url:"default_branch,omitempty" json:"default_branch,omitempty"`
+ Description *string `url:"description,omitempty" json:"description,omitempty"`
+ IssuesAccessLevel *AccessControlValue `url:"issues_access_level,omitempty" json:"issues_access_level,omitempty"`
+ RepositoryAccessLevel *AccessControlValue `url:"repository_access_level,omitempty" json:"repository_access_level,omitempty"`
+ MergeRequestsAccessLevel *AccessControlValue `url:"merge_requests_access_level,omitempty" json:"merge_requests_access_level,omitempty"`
+ ForkingAccessLevel *AccessControlValue `url:"forking_access_level,omitempty" json:"forking_access_level,omitempty"`
+ BuildsAccessLevel *AccessControlValue `url:"builds_access_level,omitempty" json:"builds_access_level,omitempty"`
+ WikiAccessLevel *AccessControlValue `url:"wiki_access_level,omitempty" json:"wiki_access_level,omitempty"`
+ SnippetsAccessLevel *AccessControlValue `url:"snippets_access_level,omitempty" json:"snippets_access_level,omitempty"`
+ PagesAccessLevel *AccessControlValue `url:"pages_access_level,omitempty" json:"pages_access_level,omitempty"`
+ OperationsAccessLevel *AccessControlValue `url:"operations_access_level,omitempty" json:"operations_access_level,omitempty"`
+ EmailsDisabled *bool `url:"emails_disabled,omitempty" json:"emails_disabled,omitempty"`
+ ResolveOutdatedDiffDiscussions *bool `url:"resolve_outdated_diff_discussions,omitempty" json:"resolve_outdated_diff_discussions,omitempty"`
+ ContainerExpirationPolicyAttributes *ContainerExpirationPolicyAttributes `url:"container_expiration_policy_attributes,omitempty" json:"container_expiration_policy_attributes,omitempty"`
+ ContainerRegistryEnabled *bool `url:"container_registry_enabled,omitempty" json:"container_registry_enabled,omitempty"`
+ SharedRunnersEnabled *bool `url:"shared_runners_enabled,omitempty" json:"shared_runners_enabled,omitempty"`
+ Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
+ ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
+ PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"`
+ AllowMergeOnSkippedPipeline *bool `url:"allow_merge_on_skipped_pipeline,omitempty" json:"allow_merge_on_skipped_pipeline,omitempty"`
+ OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"`
+ OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"`
+ MergeMethod *MergeMethodValue `url:"merge_method,omitempty" json:"merge_method,omitempty"`
+ RemoveSourceBranchAfterMerge *bool `url:"remove_source_branch_after_merge,omitempty" json:"remove_source_branch_after_merge,omitempty"`
+ LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"`
+ RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"`
+ TagList *[]string `url:"tag_list,omitempty" json:"tag_list,omitempty"`
+ BuildGitStrategy *string `url:"build_git_strategy,omitempty" json:"build_git_strategy,omitempty"`
+ BuildTimeout *int `url:"build_timeout,omitempty" json:"build_timeout,omitempty"`
+ AutoCancelPendingPipelines *string `url:"auto_cancel_pending_pipelines,omitempty" json:"auto_cancel_pending_pipelines,omitempty"`
+ BuildCoverageRegex *string `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"`
+ CIConfigPath *string `url:"ci_config_path,omitempty" json:"ci_config_path,omitempty"`
+ CIForwardDeploymentEnabled *bool `url:"ci_forward_deployment_enabled,omitempty" json:"ci_forward_deployment_enabled,omitempty"`
+ CIDefaultGitDepth *int `url:"ci_default_git_depth,omitempty" json:"ci_default_git_depth,omitempty"`
+ AutoDevopsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"`
+ AutoDevopsDeployStrategy *string `url:"auto_devops_deploy_strategy,omitempty" json:"auto_devops_deploy_strategy,omitempty"`
+ ApprovalsBeforeMerge *int `url:"approvals_before_merge,omitempty" json:"approvals_before_merge,omitempty"`
+ ExternalAuthorizationClassificationLabel *string `url:"external_authorization_classification_label,omitempty" json:"external_authorization_classification_label,omitempty"`
+ Mirror *bool `url:"mirror,omitempty" json:"mirror,omitempty"`
+ MirrorUserID *int `url:"mirror_user_id,omitempty" json:"mirror_user_id,omitempty"`
+ MirrorTriggerBuilds *bool `url:"mirror_trigger_builds,omitempty" json:"mirror_trigger_builds,omitempty"`
+ OnlyMirrorProtectedBranches *bool `url:"only_mirror_protected_branches,omitempty" json:"only_mirror_protected_branches,omitempty"`
+ MirrorOverwritesDivergedBranches *bool `url:"mirror_overwrites_diverged_branches,omitempty" json:"mirror_overwrites_diverged_branches,omitempty"`
+ PackagesEnabled *bool `url:"packages_enabled,omitempty" json:"packages_enabled,omitempty"`
+ ServiceDeskEnabled *bool `url:"service_desk_enabled,omitempty" json:"service_desk_enabled,omitempty"`
+ AutocloseReferencedIssues *bool `url:"autoclose_referenced_issues,omitempty" json:"autoclose_referenced_issues,omitempty"`
// Deprecated members
IssuesEnabled *bool `url:"issues_enabled,omitempty" json:"issues_enabled,omitempty"`
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#edit-project
func (s *ProjectsService) EditProject(pid interface{}, opt *EditProjectOptions, options ...RequestOptionFunc) (*Project, *Response, error) {
+ if opt.ContainerExpirationPolicyAttributes != nil {
+ // This is needed to satisfy the API. Should be deleted
+ // when NameRegex is removed (it's now deprecated).
+ opt.ContainerExpirationPolicyAttributes.NameRegex =
+ opt.ContainerExpirationPolicyAttributes.NameRegexDelete
+ }
+
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/fork", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/star", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/unstar", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/archive", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/unarchive", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/share", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/share/%d", pathEscape(project), groupID)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/hooks", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/hooks/%d", pathEscape(project), hook)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/hooks", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/hooks/%d", pathEscape(project), hook)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/hooks/%d", pathEscape(project), hook)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
func (s *ProjectsService) CreateProjectForkRelation(pid int, fork int, options ...RequestOptionFunc) (*ProjectForkRelation, *Response, error) {
u := fmt.Sprintf("projects/%d/fork/%d", pid, fork)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
func (s *ProjectsService) DeleteProjectForkRelation(pid int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("projects/%d/fork", pid)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
req.Body = ioutil.NopCloser(b)
req.ContentLength = int64(b.Len())
req.Header.Set("Content-Type", w.FormDataContentType())
- req.Method = "POST"
+ req.Method = http.MethodPost
uf := &ProjectFile{}
resp, err := s.client.Do(req, uf)
}
u := fmt.Sprintf("projects/%s/forks", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/push_rule", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/push_rule", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/push_rule", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/push_rule", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/approvals", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/approvals", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/approval_rules", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/approval_rules", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/approval_rules/%d", pathEscape(project), approvalRule)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/approval_rules/%d", pathEscape(project), approvalRule)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/approvers", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/mirror/pull", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/transfer", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen, Michael Lihs
+// Copyright 2021, Sander van Harmelen, Michael Lihs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"net/url"
)
client *Client
}
-// BranchAccessDescription represents the access description for a protected
-// branch.
-//
-// GitLab API docs:
-// https://docs.gitlab.com/ce/api/protected_branches.html#protected-branches-api
-type BranchAccessDescription struct {
- AccessLevel AccessLevelValue `json:"access_level"`
- UserID int `json:"user_id"`
- GroupID int `json:"group_id"`
- AccessLevelDescription string `json:"access_level_description"`
-}
-
// ProtectedBranch represents a protected branch.
//
// GitLab API docs:
CodeOwnerApprovalRequired bool `json:"code_owner_approval_required"`
}
+// BranchAccessDescription represents the access description for a protected
+// branch.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ce/api/protected_branches.html#protected-branches-api
+type BranchAccessDescription struct {
+ AccessLevel AccessLevelValue `json:"access_level"`
+ AccessLevelDescription string `json:"access_level_description"`
+ UserID int `json:"user_id"`
+ GroupID int `json:"group_id"`
+}
+
// ListProtectedBranchesOptions represents the available ListProtectedBranches()
// options.
//
}
u := fmt.Sprintf("projects/%s/protected_branches", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/protected_branches.html#protect-repository-branches
type ProtectRepositoryBranchesOptions struct {
- Name *string `url:"name,omitempty" json:"name,omitempty"`
- PushAccessLevel *AccessLevelValue `url:"push_access_level,omitempty" json:"push_access_level,omitempty"`
- MergeAccessLevel *AccessLevelValue `url:"merge_access_level,omitempty" json:"merge_access_level,omitempty"`
- UnprotectAccessLevel *AccessLevelValue `url:"unprotect_access_level,omitempty" json:"unprotect_access_level,omitempty"`
- AllowedToPush []*ProtectBranchPermissionOptions `url:"allowed_to_push,omitempty" json:"allowed_to_push,omitempty"`
- AllowedToMerge []*ProtectBranchPermissionOptions `url:"allowed_to_merge,omitempty" json:"allowed_to_merge,omitempty"`
- AllowedToUnprotect []*ProtectBranchPermissionOptions `url:"allowed_to_unprotect,omitempty" json:"allowed_to_unprotect,omitempty"`
- CodeOwnerApprovalRequired *bool `url:"code_owner_approval_required,omitempty" json:"code_owner_approval_required,omitempty"`
+ Name *string `url:"name,omitempty" json:"name,omitempty"`
+ PushAccessLevel *AccessLevelValue `url:"push_access_level,omitempty" json:"push_access_level,omitempty"`
+ MergeAccessLevel *AccessLevelValue `url:"merge_access_level,omitempty" json:"merge_access_level,omitempty"`
+ UnprotectAccessLevel *AccessLevelValue `url:"unprotect_access_level,omitempty" json:"unprotect_access_level,omitempty"`
+ AllowedToPush []*BranchPermissionOptions `url:"allowed_to_push,omitempty" json:"allowed_to_push,omitempty"`
+ AllowedToMerge []*BranchPermissionOptions `url:"allowed_to_merge,omitempty" json:"allowed_to_merge,omitempty"`
+ AllowedToUnprotect []*BranchPermissionOptions `url:"allowed_to_unprotect,omitempty" json:"allowed_to_unprotect,omitempty"`
+ CodeOwnerApprovalRequired *bool `url:"code_owner_approval_required,omitempty" json:"code_owner_approval_required,omitempty"`
}
-// ProtectBranchPermissionOptions represents a branch permission option.
+// BranchPermissionOptions represents a branch permission option.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/protected_branches.html#protect-repository-branches
-type ProtectBranchPermissionOptions struct {
+type BranchPermissionOptions struct {
UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"`
GroupID *int `url:"group_id,omitempty" json:"group_id,omitempty"`
AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
}
u := fmt.Sprintf("projects/%s/protected_branches", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch))
- req, err := s.client.NewRequest("PATCH", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPatch, u, opt, options)
if err != nil {
return nil, err
}
--- /dev/null
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package gitlab
+
+import (
+ "fmt"
+ "net/http"
+)
+
+// ProtectedEnvironmentsService handles communication with the protected
+// environment methods of the GitLab API.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/protected_environments.html
+type ProtectedEnvironmentsService struct {
+ client *Client
+}
+
+// ProtectedEnvironment represents a protected environment.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/protected_environments.html
+type ProtectedEnvironment struct {
+ Name string `json:"name"`
+ DeployAccessLevels []*EnvironmentAccessDescription `json:"deploy_access_levels"`
+}
+
+// EnvironmentAccessDescription represents the access decription for a protected
+// environment.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/protected_environments.html
+type EnvironmentAccessDescription struct {
+ AccessLevel AccessLevelValue `json:"access_level"`
+ AccessLevelDescription string `json:"access_level_description"`
+ UserID int `json:"user_id"`
+ GroupID int `json:"group_id"`
+}
+
+// ListProtectedEnvironmentsOptions represents the available
+// ListProtectedEnvironments() options.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/protected_environments.html#list-protected-environments
+type ListProtectedEnvironmentsOptions ListOptions
+
+// ListProtectedEnvironments returns a list of protected environments from a project.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/protected_environments.html#list-protected-environments
+func (s *ProtectedEnvironmentsService) ListProtectedEnvironments(pid interface{}, opt *ListProtectedEnvironmentsOptions, options ...RequestOptionFunc) ([]*ProtectedEnvironment, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/protected_environments", pathEscape(project))
+
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var pes []*ProtectedEnvironment
+ resp, err := s.client.Do(req, &pes)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return pes, resp, err
+}
+
+// GetProtectedEnvironment returns a single protected environment or wildcard protected environment.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/protected_environments.html#get-a-single-protected-environment-or-wildcard-protected-environment
+func (s *ProtectedEnvironmentsService) GetProtectedEnvironment(pid interface{}, environment string, options ...RequestOptionFunc) (*ProtectedEnvironment, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/protected_environments/%s", pathEscape(project), pathEscape(environment))
+
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ pe := new(ProtectedEnvironment)
+ resp, err := s.client.Do(req, pe)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return pe, resp, err
+}
+
+// ProtectRepositoryEnvironmentsOptions represents the available
+// ProtectRepositoryEnvironments() options.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/protected_environments.html#protect-repository-environments
+type ProtectRepositoryEnvironmentsOptions struct {
+ Name *string `url:"name,omitempty" json:"name,omitempty"`
+ DeployAccessLevels []*EnvironmentAccessOptions `url:"deploy_access_levels,omitempty" json:"deploy_access_levels,omitempty"`
+}
+
+// EnvironmentAccessOptions represents the options for an access decription for
+// a protected environment.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/protected_environments.html#protect-repository-environments
+type EnvironmentAccessOptions struct {
+ AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
+ UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"`
+ GroupID *int `url:"group_id,omitempty" json:"group_id,omitempty"`
+}
+
+// ProtectRepositoryEnvironments protects a single repository environment or several project
+// repository environments using a wildcard protected environment.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/protected_environments.html#protect-repository-environments
+func (s *ProtectedEnvironmentsService) ProtectRepositoryEnvironments(pid interface{}, opt *ProtectRepositoryEnvironmentsOptions, options ...RequestOptionFunc) (*ProtectedEnvironment, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/protected_environments", pathEscape(project))
+
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ pe := new(ProtectedEnvironment)
+ resp, err := s.client.Do(req, pe)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return pe, resp, err
+}
+
+// UnprotectEnvironment unprotects the given protected environment or wildcard
+// protected environment.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/protected_environments.html#unprotect-repository-environments
+func (s *ProtectedEnvironmentsService) UnprotectEnvironment(pid interface{}, environment string, options ...RequestOptionFunc) (*Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, err
+ }
+ u := fmt.Sprintf("projects/%s/protected_environments/%s", pathEscape(project), pathEscape(environment))
+
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
+ if err != nil {
+ return nil, err
+ }
+
+ return s.client.Do(req, nil)
+}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
)
// ProtectedTagsService handles communication with the protected tag methods
}
u := fmt.Sprintf("projects/%s/protected_tags", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/protected_tags/%s", pathEscape(project), pathEscape(tag))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/protected_tags", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/protected_tags/%s", pathEscape(project), pathEscape(tag))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
"time"
)
//
// GitLab API docs: https://docs.gitlab.com/ee/api/container_registry.html
type RegistryRepository struct {
- ID int `json:"id"`
- Name string `json:"name"`
- Path string `json:"path"`
- Location string `json:"location"`
- CreatedAt *time.Time `json:"created_at"`
+ ID int `json:"id"`
+ Name string `json:"name"`
+ Path string `json:"path"`
+ Location string `json:"location"`
+ CreatedAt *time.Time `json:"created_at"`
+ CreatePolicyStartedAt *time.Time `json:"cleanup_policy_started_at"`
+ TagsCount int `json:"tags_count"`
+ Tags []*RegistryRepositoryTag `json:"tags"`
}
func (s RegistryRepository) String() string {
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#list-registry-repositories
-type ListRegistryRepositoriesOptions ListOptions
+type ListRegistryRepositoriesOptions struct {
+ ListOptions
+ Tags *bool `url:"tags,omitempty" json:"tags,omitempty"`
+ TagsCount *bool `url:"tags_count,omitempty" json:"tags_count,omitempty"`
+}
// ListRegistryRepositories gets a list of registry repositories in a project.
//
}
u := fmt.Sprintf("projects/%s/registry/repositories", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/registry/repositories/%d", pathEscape(project), repository)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
repository,
)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
tagName,
)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
tagName,
)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
repository,
)
- req, err := s.client.NewRequest("DELETE", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, opt, options)
if err != nil {
return nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
)
// ReleaseLinksService handles communication with the release link methods
}
u := fmt.Sprintf("projects/%s/releases/%s/assets/links", pathEscape(project), tagName)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
tagName,
link)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/releases/%s/assets/links", pathEscape(project), tagName)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
tagName,
link)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
link,
)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/releases", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/releases/%s", pathEscape(project), tagName)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/releases", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opts, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opts, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/releases/%s", pathEscape(project), tagName)
- req, err := s.client.NewRequest("PUT", u, opts, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opts, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/releases/%s", pathEscape(project), tagName)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
"bytes"
"fmt"
"io"
+ "net/http"
"net/url"
)
}
u := fmt.Sprintf("projects/%s/repository/tree", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/blobs/%s", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/blobs/%s/raw", pathEscape(project), url.PathEscape(sha))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
u = fmt.Sprintf("%s.%s", u, *opt.Format)
}
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
u = fmt.Sprintf("%s.%s", u, *opt.Format)
}
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/compare", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/contributors", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/merge_base", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"bytes"
"fmt"
+ "net/http"
"net/url"
"strconv"
"time"
url.PathEscape(fileName),
)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
url.PathEscape(fileName),
)
- req, err := s.client.NewRequest("HEAD", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodHead, u, opt, options)
if err != nil {
return nil, nil, err
}
url.PathEscape(file),
)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
url.PathEscape(fileName),
)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
url.PathEscape(fileName),
)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
url.PathEscape(fileName),
)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
url.PathEscape(fileName),
)
- req, err := s.client.NewRequest("DELETE", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, opt, options)
if err != nil {
return nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
}
u := fmt.Sprintf("projects/%s/issues/%d/resource_label_events", pathEscape(project), issue)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/issues/%d/resource_label_events/%d", pathEscape(project), issue, event)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d/resource_label_events", pathEscape(group), epic)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("groups/%s/epics/%d/resource_label_events/%d", pathEscape(group), epic, event)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/resource_label_events", pathEscape(project), request)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/resource_label_events/%d", pathEscape(project), request, event)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
--- /dev/null
+//
+// Copyright 2021, Matthias Simon
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package gitlab
+
+import (
+ "fmt"
+ "net/http"
+ "time"
+)
+
+// ResourceStateEventsService handles communication with the event related
+// methods of the GitLab API.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/resource_state_events.html
+type ResourceStateEventsService struct {
+ client *Client
+}
+
+// StateEvent represents a resource state event.
+//
+// GitLab API docs: https://docs.gitlab.com/ee/api/resource_state_events.html
+type StateEvent struct {
+ ID int `json:"id"`
+ User *BasicUser `json:"user"`
+ CreatedAt *time.Time `json:"created_at"`
+ ResourceType string `json:"resource_type"`
+ ResourceID int `json:"resource_id"`
+ State EventTypeValue `json:"state"`
+}
+
+// ListStateEventsOptions represents the options for all resource state events
+// list methods.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/resource_state_events.html#list-project-issue-state-events
+type ListStateEventsOptions struct {
+ ListOptions
+}
+
+// ListIssueStateEvents retrieves resource state events for the specified
+// project and issue.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/resource_state_events.html#list-project-issue-state-events
+func (s *ResourceStateEventsService) ListIssueStateEvents(pid interface{}, issue int, opt *ListStateEventsOptions, options ...RequestOptionFunc) ([]*StateEvent, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/issues/%d/resource_state_events", pathEscape(project), issue)
+
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var ses []*StateEvent
+ resp, err := s.client.Do(req, &ses)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return ses, resp, err
+}
+
+// GetIssueStateEvent gets a single issue-state-event.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/resource_state_events.html#get-single-issue-state-event
+func (s *ResourceStateEventsService) GetIssueStateEvent(pid interface{}, issue int, event int, options ...RequestOptionFunc) (*StateEvent, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/issues/%d/resource_state_events/%d", pathEscape(project), issue, event)
+
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ se := new(StateEvent)
+ resp, err := s.client.Do(req, se)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return se, resp, err
+}
+
+// ListMergeStateEvents retrieves resource state events for the specified
+// project and merge request.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/resource_state_events.html#list-project-merge-request-state-events
+func (s *ResourceStateEventsService) ListMergeStateEvents(pid interface{}, request int, opt *ListStateEventsOptions, options ...RequestOptionFunc) ([]*StateEvent, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/merge_requests/%d/resource_state_events", pathEscape(project), request)
+
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var ses []*StateEvent
+ resp, err := s.client.Do(req, &ses)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return ses, resp, err
+}
+
+// GetMergeRequestStateEvent gets a single merge request state event.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/resource_state_events.html#get-single-merge-request-state-event
+func (s *ResourceStateEventsService) GetMergeRequestStateEvent(pid interface{}, request int, event int, options ...RequestOptionFunc) (*StateEvent, *Response, error) {
+ project, err := parseID(pid)
+ if err != nil {
+ return nil, nil, err
+ }
+ u := fmt.Sprintf("projects/%s/merge_requests/%d/resource_state_events/%d", pathEscape(project), request, event)
+
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ se := new(StateEvent)
+ resp, err := s.client.Do(req, se)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return se, resp, err
+}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#list-owned-runners
func (s *RunnersService) ListRunners(opt *ListRunnersOptions, options ...RequestOptionFunc) ([]*Runner, *Response, error) {
- req, err := s.client.NewRequest("GET", "runners", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "runners", opt, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#list-all-runners
func (s *RunnersService) ListAllRunners(opt *ListRunnersOptions, options ...RequestOptionFunc) ([]*Runner, *Response, error) {
- req, err := s.client.NewRequest("GET", "runners/all", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "runners/all", opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("runners/%s", runner)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("runners/%s", runner)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("runners/%s", runner)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("runners/%s/jobs", runner)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/runners", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/runners", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/runners/%d", pathEscape(project), runner)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("groups/%s/runners", pathEscape(group))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#register-a-new-runner
func (s *RunnersService) RegisterNewRunner(opt *RegisterNewRunnerOptions, options ...RequestOptionFunc) (*Runner, *Response, error) {
- req, err := s.client.NewRequest("POST", "runners", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "runners", opt, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#delete-a-runner-by-authentication-token
func (s *RunnersService) DeleteRegisteredRunner(opt *DeleteRegisteredRunnerOptions, options ...RequestOptionFunc) (*Response, error) {
- req, err := s.client.NewRequest("DELETE", "runners", opt, options)
+ req, err := s.client.NewRequest(http.MethodDelete, "runners", opt, options)
if err != nil {
return nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#delete-a-runner-by-id
func (s *RunnersService) DeleteRegisteredRunnerByID(rid int, options ...RequestOptionFunc) (*Response, error) {
- req, err := s.client.NewRequest("DELETE", fmt.Sprintf("runners/%d", rid), nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, fmt.Sprintf("runners/%d", rid), nil, options)
if err != nil {
return nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#verify-authentication-for-a-registered-runner
func (s *RunnersService) VerifyRegisteredRunner(opt *VerifyRegisteredRunnerOptions, options ...RequestOptionFunc) (*Response, error) {
- req, err := s.client.NewRequest("POST", "runners/verify", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "runners/verify", opt, options)
if err != nil {
return nil, err
}
//
-// Copyright 2018, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
)
// SearchService handles communication with the search related methods of the
func (s *SearchService) search(scope, query string, result interface{}, opt *SearchOptions, options ...RequestOptionFunc) (*Response, error) {
opts := &searchOptions{SearchOptions: *opt, Scope: scope, Search: query}
- req, err := s.client.NewRequest("GET", "search", opts, options)
+ req, err := s.client.NewRequest(http.MethodGet, "search", opts, options)
if err != nil {
return nil, err
}
opts := &searchOptions{SearchOptions: *opt, Scope: scope, Search: query}
- req, err := s.client.NewRequest("GET", u, opts, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, err
}
opts := &searchOptions{SearchOptions: *opt, Scope: scope, Search: query}
- req, err := s.client.NewRequest("GET", u, opts, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opts, options)
if err != nil {
return nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"encoding/json"
"fmt"
+ "net/http"
"strconv"
"time"
)
}
u := fmt.Sprintf("projects/%s/services", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/services/drone-ci", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/services/drone-ci", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/drone-ci", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/external-wiki", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/services/external-wiki", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/external-wiki", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/github", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/services/github", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/github", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/gitlab-ci", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/gitlab-ci", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/hipchat", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/hipchat", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/jenkins", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/services/jenkins", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/jenkins", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/jira", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/services/jira", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/jira", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/microsoft-teams", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/services/microsoft-teams", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/microsoft-teams", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/pipelines-email", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/services/pipelines-email", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/pipelines-email", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/slack", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/services/slack", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/slack", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", pathEscape(project))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", pathEscape(project))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package gitlab
-import "time"
+import (
+ "net/http"
+ "time"
+)
// SettingsService handles communication with the application SettingsService
// related methods of the GitLab API.
// GitLab API docs:
// https://docs.gitlab.com/ce/api/settings.html#get-current-application.settings
func (s *SettingsService) GetSettings(options ...RequestOptionFunc) (*Settings, *Response, error) {
- req, err := s.client.NewRequest("GET", "application/settings", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "application/settings", nil, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/settings.html#change-application.settings
func (s *SettingsService) UpdateSettings(opt *UpdateSettingsOptions, options ...RequestOptionFunc) (*Settings, *Response, error) {
- req, err := s.client.NewRequest("PUT", "application/settings", opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, "application/settings", opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2018, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package gitlab
-import "time"
+import (
+ "net/http"
+ "time"
+)
// SidekiqService handles communication with the sidekiq service
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/sidekiq_metrics.html#get-the-current-queue-metrics
func (s *SidekiqService) GetQueueMetrics(options ...RequestOptionFunc) (*QueueMetrics, *Response, error) {
- req, err := s.client.NewRequest("GET", "/sidekiq/queue_metrics", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/queue_metrics", nil, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/sidekiq_metrics.html#get-the-current-process-metrics
func (s *SidekiqService) GetProcessMetrics(options ...RequestOptionFunc) (*ProcessMetrics, *Response, error) {
- req, err := s.client.NewRequest("GET", "/sidekiq/process_metrics", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/process_metrics", nil, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/sidekiq_metrics.html#get-the-current-job-statistics
func (s *SidekiqService) GetJobStats(options ...RequestOptionFunc) (*JobStats, *Response, error) {
- req, err := s.client.NewRequest("GET", "/sidekiq/job_stats", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/job_stats", nil, options)
if err != nil {
return nil, nil, err
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/sidekiq_metrics.html#get-the-current-job-statistics
func (s *SidekiqService) GetCompoundMetrics(options ...RequestOptionFunc) (*CompoundMetrics, *Response, error) {
- req, err := s.client.NewRequest("GET", "/sidekiq/compound_metrics", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/compound_metrics", nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"bytes"
"fmt"
+ "net/http"
"time"
)
//
// GitLab API docs: https://docs.gitlab.com/ce/api/snippets.html#list-snippets
func (s *SnippetsService) ListSnippets(opt *ListSnippetsOptions, options ...RequestOptionFunc) ([]*Snippet, *Response, error) {
- req, err := s.client.NewRequest("GET", "snippets", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "snippets", opt, options)
if err != nil {
return nil, nil, err
}
func (s *SnippetsService) GetSnippet(snippet int, options ...RequestOptionFunc) (*Snippet, *Response, error) {
u := fmt.Sprintf("snippets/%d", snippet)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/snippets.html#create-new-snippet
func (s *SnippetsService) CreateSnippet(opt *CreateSnippetOptions, options ...RequestOptionFunc) (*Snippet, *Response, error) {
- req, err := s.client.NewRequest("POST", "snippets", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "snippets", opt, options)
if err != nil {
return nil, nil, err
}
func (s *SnippetsService) UpdateSnippet(snippet int, opt *UpdateSnippetOptions, options ...RequestOptionFunc) (*Snippet, *Response, error) {
u := fmt.Sprintf("snippets/%d", snippet)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *SnippetsService) DeleteSnippet(snippet int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("snippets/%d", snippet)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
func (s *SnippetsService) SnippetContent(snippet int, options ...RequestOptionFunc) ([]byte, *Response, error) {
u := fmt.Sprintf("snippets/%d/raw", snippet)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/snippets.html#explore-all-public-snippets
func (s *SnippetsService) ExploreSnippets(opt *ExploreSnippetsOptions, options ...RequestOptionFunc) ([]*Snippet, *Response, error) {
- req, err := s.client.NewRequest("GET", "snippets/public", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "snippets/public", nil, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"time"
)
// GitLab API docs:
// https://docs.gitlab.com/ce/api/system_hooks.html#list-system-hooks
func (s *SystemHooksService) ListHooks(options ...RequestOptionFunc) ([]*Hook, *Response, error) {
- req, err := s.client.NewRequest("GET", "hooks", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "hooks", nil, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/system_hooks.html#add-new-system-hook-hook
func (s *SystemHooksService) AddHook(opt *AddHookOptions, options ...RequestOptionFunc) (*Hook, *Response, error) {
- req, err := s.client.NewRequest("POST", "hooks", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "hooks", opt, options)
if err != nil {
return nil, nil, err
}
func (s *SystemHooksService) TestHook(hook int, options ...RequestOptionFunc) (*HookEvent, *Response, error) {
u := fmt.Sprintf("hooks/%d", hook)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
func (s *SystemHooksService) DeleteHook(hook int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("hooks/%d", hook)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"net/url"
)
}
u := fmt.Sprintf("projects/%s/repository/tags", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/tags/%s", pathEscape(project), url.PathEscape(tag))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/tags", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/tags/%s", pathEscape(project), url.PathEscape(tag))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/tags/%s/release", pathEscape(project), url.PathEscape(tag))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/repository/tags/%s/release", pathEscape(project), url.PathEscape(tag))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
"fmt"
+ "net/http"
)
// timeStatsService handles communication with the time tracking related
}
u := fmt.Sprintf("projects/%s/%s/%d/time_estimate", pathEscape(project), entity, issue)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/%s/%d/reset_time_estimate", pathEscape(project), entity, issue)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/%s/%d/add_spent_time", pathEscape(project), entity, issue)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/%s/%d/reset_spent_time", pathEscape(project), entity, issue)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/%s/%d/time_stats", pathEscape(project), entity, issue)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
-import "time"
-import "fmt"
+import (
+ "fmt"
+ "net/http"
+ "time"
+)
// TodosService handles communication with the todos related methods of
// the Gitlab API.
// GitLab API docs:
// https://docs.gitlab.com/ce/api/todos.html#get-a-list-of-todos
func (s *TodosService) ListTodos(opt *ListTodosOptions, options ...RequestOptionFunc) ([]*Todo, *Response, error) {
- req, err := s.client.NewRequest("GET", "todos", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "todos", opt, options)
if err != nil {
return nil, nil, err
}
func (s *TodosService) MarkTodoAsDone(id int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("todos/%d/mark_as_done", id)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return nil, err
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/todos.html#mark-all-todos-as-done
func (s *TodosService) MarkAllTodosAsDone(options ...RequestOptionFunc) (*Response, error) {
- req, err := s.client.NewRequest("POST", "todos/mark_as_done", nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, "todos/mark_as_done", nil, options)
if err != nil {
return nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
import (
return p
}
-// FileAction represents the available actions that can be performed on a file.
+// FileActionValue represents the available actions that can be performed on a file.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
-type FileAction string
+type FileActionValue string
// The available file actions.
const (
- FileCreate FileAction = "create"
- FileDelete FileAction = "delete"
- FileMove FileAction = "move"
- FileUpdate FileAction = "update"
+ FileCreate FileActionValue = "create"
+ FileDelete FileActionValue = "delete"
+ FileMove FileActionValue = "move"
+ FileUpdate FileActionValue = "update"
+ FileChmod FileActionValue = "chmod"
)
+// FileAction is a helper routine that allocates a new FileActionValue value
+// to store v and returns a pointer to it.
+func FileAction(v FileActionValue) *FileActionValue {
+ p := new(FileActionValue)
+ *p = v
+ return p
+}
+
// ISOTime represents an ISO 8601 formatted date
type ISOTime time.Time
return p
}
+// WikiFormatValue represents the available wiki formats.
+//
+// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html
+type WikiFormatValue string
+
+// The available wiki formats.
+const (
+ WikiFormatMarkdown WikiFormatValue = "markdown"
+ WikiFormatRDoc WikiFormatValue = "rdoc"
+ WikiFormatASCIIDoc WikiFormatValue = "asciidoc"
+ WikiFormatOrg WikiFormatValue = "org"
+)
+
+// WikiFormat is a helper routine that allocates a new WikiFormatValue
+// to store v and returns a pointer to it.
+func WikiFormat(v WikiFormatValue) *WikiFormatValue {
+ p := new(WikiFormatValue)
+ *p = v
+ return p
+}
+
// MergeMethodValue represents a project merge type within GitLab.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#project-merge-method
//
-// Copyright 2017, Sander van Harmelen
+// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"errors"
"fmt"
+ "net/http"
"time"
)
CreatedAfter *time.Time `url:"created_after,omitempty" json:"created_after,omitempty"`
OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
+ TwoFactor *string `url:"two_factor,omitempty" json:"two_factor,omitempty"`
+ Admins *bool `url:"admins,omitempty" json:"admins,omitempty"`
External *bool `url:"external,omitempty" json:"external,omitempty"`
+ WithoutProjects *bool `url:"without_projects,omitempty" json:"without_projects,omitempty"`
WithCustomAttributes *bool `url:"with_custom_attributes,omitempty" json:"with_custom_attributes,omitempty"`
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#list-users
func (s *UsersService) ListUsers(opt *ListUsersOptions, options ...RequestOptionFunc) ([]*User, *Response, error) {
- req, err := s.client.NewRequest("GET", "users", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "users", opt, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) GetUser(user int, options ...RequestOptionFunc) (*User, *Response, error) {
u := fmt.Sprintf("users/%d", user)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
SkipConfirmation *bool `url:"skip_confirmation,omitempty" json:"skip_confirmation,omitempty"`
External *bool `url:"external,omitempty" json:"external,omitempty"`
PrivateProfile *bool `url:"private_profile,omitempty" json:"private_profile,omitempty"`
+ Note *string `url:"note,omitempty" json:"note,omitempty"`
}
// CreateUser creates a new user. Note only administrators can create new users.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#user-creation
func (s *UsersService) CreateUser(opt *CreateUserOptions, options ...RequestOptionFunc) (*User, *Response, error) {
- req, err := s.client.NewRequest("POST", "users", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "users", opt, options)
if err != nil {
return nil, nil, err
}
SkipReconfirmation *bool `url:"skip_reconfirmation,omitempty" json:"skip_reconfirmation,omitempty"`
External *bool `url:"external,omitempty" json:"external,omitempty"`
PrivateProfile *bool `url:"private_profile,omitempty" json:"private_profile,omitempty"`
+ Note *string `url:"note,omitempty" json:"note,omitempty"`
}
// ModifyUser modifies an existing user. Only administrators can change attributes
func (s *UsersService) ModifyUser(user int, opt *ModifyUserOptions, options ...RequestOptionFunc) (*User, *Response, error) {
u := fmt.Sprintf("users/%d", user)
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) DeleteUser(user int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("users/%d", user)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#current-user
func (s *UsersService) CurrentUser(options ...RequestOptionFunc) (*User, *Response, error) {
- req, err := s.client.NewRequest("GET", "user", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "user", nil, options)
if err != nil {
return nil, nil, err
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#list-ssh-keys
func (s *UsersService) ListSSHKeys(options ...RequestOptionFunc) ([]*SSHKey, *Response, error) {
- req, err := s.client.NewRequest("GET", "user/keys", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "user/keys", nil, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) ListSSHKeysForUser(user int, opt *ListSSHKeysForUserOptions, options ...RequestOptionFunc) ([]*SSHKey, *Response, error) {
u := fmt.Sprintf("users/%d/keys", user)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) GetSSHKey(key int, options ...RequestOptionFunc) (*SSHKey, *Response, error) {
u := fmt.Sprintf("user/keys/%d", key)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#add-ssh-key
func (s *UsersService) AddSSHKey(opt *AddSSHKeyOptions, options ...RequestOptionFunc) (*SSHKey, *Response, error) {
- req, err := s.client.NewRequest("POST", "user/keys", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "user/keys", opt, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) AddSSHKeyForUser(user int, opt *AddSSHKeyOptions, options ...RequestOptionFunc) (*SSHKey, *Response, error) {
u := fmt.Sprintf("users/%d/keys", user)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) DeleteSSHKey(key int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("user/keys/%d", key)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
func (s *UsersService) DeleteSSHKeyForUser(user, key int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("users/%d/keys/%d", user, key)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
func (s *UsersService) BlockUser(user int, options ...RequestOptionFunc) error {
u := fmt.Sprintf("users/%d/block", user)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return err
}
func (s *UsersService) UnblockUser(user int, options ...RequestOptionFunc) error {
u := fmt.Sprintf("users/%d/unblock", user)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return err
}
func (s *UsersService) DeactivateUser(user int, options ...RequestOptionFunc) error {
u := fmt.Sprintf("users/%d/deactivate", user)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return err
}
func (s *UsersService) ActivateUser(user int, options ...RequestOptionFunc) error {
u := fmt.Sprintf("users/%d/activate", user)
- req, err := s.client.NewRequest("POST", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
if err != nil {
return err
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#list-emails
func (s *UsersService) ListEmails(options ...RequestOptionFunc) ([]*Email, *Response, error) {
- req, err := s.client.NewRequest("GET", "user/emails", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "user/emails", nil, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) ListEmailsForUser(user int, opt *ListEmailsForUserOptions, options ...RequestOptionFunc) ([]*Email, *Response, error) {
u := fmt.Sprintf("users/%d/emails", user)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) GetEmail(email int, options ...RequestOptionFunc) (*Email, *Response, error) {
u := fmt.Sprintf("user/emails/%d", email)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
//
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#add-email
func (s *UsersService) AddEmail(opt *AddEmailOptions, options ...RequestOptionFunc) (*Email, *Response, error) {
- req, err := s.client.NewRequest("POST", "user/emails", opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, "user/emails", opt, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) AddEmailForUser(user int, opt *AddEmailOptions, options ...RequestOptionFunc) (*Email, *Response, error) {
u := fmt.Sprintf("users/%d/emails", user)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) DeleteEmail(email int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("user/emails/%d", email)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
func (s *UsersService) DeleteEmailForUser(user, email int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("users/%d/emails/%d", user, email)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
func (s *UsersService) GetAllImpersonationTokens(user int, opt *GetAllImpersonationTokensOptions, options ...RequestOptionFunc) ([]*ImpersonationToken, *Response, error) {
u := fmt.Sprintf("users/%d/impersonation_tokens", user)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) GetImpersonationToken(user, token int, options ...RequestOptionFunc) (*ImpersonationToken, *Response, error) {
u := fmt.Sprintf("users/%d/impersonation_tokens/%d", user, token)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) CreateImpersonationToken(user int, opt *CreateImpersonationTokenOptions, options ...RequestOptionFunc) (*ImpersonationToken, *Response, error) {
u := fmt.Sprintf("users/%d/impersonation_tokens", user)
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) RevokeImpersonationToken(user, token int, options ...RequestOptionFunc) (*Response, error) {
u := fmt.Sprintf("users/%d/impersonation_tokens/%d", user, token)
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/users.html#get-user-activities-admin-only
func (s *UsersService) GetUserActivities(opt *GetUserActivitiesOptions, options ...RequestOptionFunc) ([]*UserActivity, *Response, error) {
- req, err := s.client.NewRequest("GET", "user/activities", opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, "user/activities", opt, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/users.html#user-status
func (s *UsersService) CurrentUserStatus(options ...RequestOptionFunc) (*UserStatus, *Response, error) {
- req, err := s.client.NewRequest("GET", "user/status", nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, "user/status", nil, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) GetUserStatus(user int, options ...RequestOptionFunc) (*UserStatus, *Response, error) {
u := fmt.Sprintf("users/%d/status", user)
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/users.html#set-user-status
func (s *UsersService) SetUserStatus(opt *UserStatusOptions, options ...RequestOptionFunc) (*UserStatus, *Response, error) {
- req, err := s.client.NewRequest("PUT", "user/status", opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, "user/status", opt, options)
if err != nil {
return nil, nil, err
}
func (s *UsersService) GetUserMemberships(user int, opt *GetUserMembershipOptions, options ...RequestOptionFunc) ([]*UserMembership, *Response, error) {
u := fmt.Sprintf("users/%d/memberships", user)
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
+//
+// Copyright 2021, Sander van Harmelen
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
package gitlab
-import "fmt"
+import (
+ "fmt"
+ "net/http"
+)
// ValidateService handles communication with the validation related methods of
// the GitLab API.
}
opts.Content = content
- req, err := s.client.NewRequest("POST", "ci/lint", &opts, options)
+ req, err := s.client.NewRequest(http.MethodPost, "ci/lint", &opts, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/ci/lint", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, &opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, &opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/ci/lint", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, &opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, &opt, options)
if err != nil {
return nil, nil, err
}
//
-// Copyright 2017, Andrea Funto'
+// Copyright 2021, Andrea Funto'
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package gitlab
+import "net/http"
+
// VersionService handles communication with the GitLab server instance to
// retrieve its version information via the GitLab API.
//
//
// GitLab API docs: https://docs.gitlab.com/ce/api/version.md
func (s *VersionService) GetVersion() (*Version, *Response, error) {
- req, err := s.client.NewRequest("GET", "version", nil, nil)
+ req, err := s.client.NewRequest(http.MethodGet, "version", nil, nil)
if err != nil {
return nil, nil, err
}
-// Copyright 2017, Stany MARCEL
+//
+// Copyright 2021, Stany MARCEL
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
import (
"fmt"
+ "net/http"
"net/url"
)
client *Client
}
-// WikiFormat represents the available wiki formats.
-//
-// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html
-type WikiFormat string
-
-// The available wiki formats.
-const (
- WikiFormatMarkdown WikiFormat = "markdown"
- WikiFormatRFoc WikiFormat = "rdoc"
- WikiFormatASCIIDoc WikiFormat = "asciidoc"
-)
-
// Wiki represents a GitLab wiki.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html
type Wiki struct {
- Content string `json:"content"`
- Format WikiFormat `json:"format"`
- Slug string `json:"slug"`
- Title string `json:"title"`
+ Content string `json:"content"`
+ Format WikiFormatValue `json:"format"`
+ Slug string `json:"slug"`
+ Title string `json:"title"`
}
func (w Wiki) String() string {
}
u := fmt.Sprintf("projects/%s/wikis", pathEscape(project))
- req, err := s.client.NewRequest("GET", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
- var w []*Wiki
- resp, err := s.client.Do(req, &w)
+ var ws []*Wiki
+ resp, err := s.client.Do(req, &ws)
if err != nil {
return nil, resp, err
}
- return w, resp, err
+ return ws, resp, err
}
// GetWikiPage gets a wiki page for a given project.
}
u := fmt.Sprintf("projects/%s/wikis/%s", pathEscape(project), url.PathEscape(slug))
- req, err := s.client.NewRequest("GET", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}
- var w *Wiki
- resp, err := s.client.Do(req, &w)
+ w := new(Wiki)
+ resp, err := s.client.Do(req, w)
if err != nil {
return nil, resp, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/wikis.html#create-a-new-wiki-page
type CreateWikiPageOptions struct {
- Content *string `url:"content" json:"content"`
- Title *string `url:"title" json:"title"`
- Format *string `url:"format,omitempty" json:"format,omitempty"`
+ Content *string `url:"content,omitempty" json:"content,omitempty"`
+ Title *string `url:"title,omitempty" json:"title,omitempty"`
+ Format *WikiFormatValue `url:"format,omitempty" json:"format,omitempty"`
}
// CreateWikiPage creates a new wiki page for the given repository with
}
u := fmt.Sprintf("projects/%s/wikis", pathEscape(project))
- req, err := s.client.NewRequest("POST", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
if err != nil {
return nil, nil, err
}
// GitLab API docs:
// https://docs.gitlab.com/ce/api/wikis.html#edit-an-existing-wiki-page
type EditWikiPageOptions struct {
- Content *string `url:"content" json:"content"`
- Title *string `url:"title" json:"title"`
- Format *string `url:"format,omitempty" json:"format,omitempty"`
+ Content *string `url:"content,omitempty" json:"content,omitempty"`
+ Title *string `url:"title,omitempty" json:"title,omitempty"`
+ Format *WikiFormatValue `url:"format,omitempty" json:"format,omitempty"`
}
// EditWikiPage Updates an existing wiki page. At least one parameter is
}
u := fmt.Sprintf("projects/%s/wikis/%s", pathEscape(project), url.PathEscape(slug))
- req, err := s.client.NewRequest("PUT", u, opt, options)
+ req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
return nil, nil, err
}
}
u := fmt.Sprintf("projects/%s/wikis/%s", pathEscape(project), url.PathEscape(slug))
- req, err := s.client.NewRequest("DELETE", u, nil, options)
+ req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
if err != nil {
return nil, err
}
[]byte("https:"),
}),
extension.WithLinkifyURLRegexp(
- xurls.Strict(),
+ xurls.Strict,
),
),
),
"github.com/yuin/goldmark/util"
)
-var wwwURLRegxp = regexp.MustCompile(`^www\.[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]+(?:[/#?][-a-zA-Z0-9@:%_\+.~#!?&/=\(\);,'">\^{}\[\]` + "`" + `]*)?`)
+var wwwURLRegxp = regexp.MustCompile(`^www\.[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]+(?:[/#?][-a-zA-Z0-9@:%_\+.~#!?&/=\(\);,'">\^{}\[\]` + "`" + `]*)?`)
-var urlRegexp = regexp.MustCompile(`^(?:http|https|ftp)://[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]+(?::\d+)?(?:[/#?][-a-zA-Z0-9@:%_+.~#$!?&/=\(\);,'">\^{}\[\]` + "`" + `]*)?`)
+var urlRegexp = regexp.MustCompile(`^(?:http|https|ftp)://[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]+(?::\d+)?(?:[/#?][-a-zA-Z0-9@:%_+.~#$!?&/=\(\);,'">\^{}\[\]` + "`" + `]*)?`)
// An LinkifyConfig struct is a data structure that holds configuration of the
// Linkify extension.
EmailRegexp *regexp.Regexp
}
-const optLinkifyAllowedProtocols parser.OptionName = "LinkifyAllowedProtocols"
-const optLinkifyURLRegexp parser.OptionName = "LinkifyURLRegexp"
-const optLinkifyWWWRegexp parser.OptionName = "LinkifyWWWRegexp"
-const optLinkifyEmailRegexp parser.OptionName = "LinkifyEmailRegexp"
+const (
+ optLinkifyAllowedProtocols parser.OptionName = "LinkifyAllowedProtocols"
+ optLinkifyURLRegexp parser.OptionName = "LinkifyURLRegexp"
+ optLinkifyWWWRegexp parser.OptionName = "LinkifyWWWRegexp"
+ optLinkifyEmailRegexp parser.OptionName = "LinkifyEmailRegexp"
+)
// SetOption implements SetOptioner.
func (c *LinkifyConfig) SetOption(name parser.OptionName, value interface{}) {
return []byte{' ', '*', '_', '~', '('}
}
-var protoHTTP = []byte("http:")
-var protoHTTPS = []byte("https:")
-var protoFTP = []byte("ftp:")
-var domainWWW = []byte("www.")
+var (
+ protoHTTP = []byte("http:")
+ protoHTTPS = []byte("https:")
+ protoFTP = []byte("ftp:")
+ domainWWW = []byte("www.")
+)
func (s *linkifyParser) Parse(parent ast.Node, block text.Reader, pc parser.Context) ast.Node {
if pc.IsInLinkLabel() {
}
reader.AdvanceAndSetPadding(pos, padding)
_, segment = reader.PeekLine()
+
+ // if code block line starts with a tab, keep a tab as it is.
+ if segment.Padding != 0 {
+ preserveLeadingTabInCodeBlock(&segment, reader)
+ }
+
node.Lines().Append(segment)
reader.Advance(segment.Len() - 1)
return Continue | NoChildren
func (b *codeBlockParser) CanAcceptIndentedLine() bool {
return true
}
+
+func preserveLeadingTabInCodeBlock(segment *text.Segment, reader text.Reader) {
+ offsetWithPadding := reader.LineOffset()
+ sl, ss := reader.Position()
+ reader.SetPosition(sl, text.NewSegment(ss.Start-1, ss.Stop))
+ if offsetWithPadding == reader.LineOffset() {
+ segment.Padding = 0
+ segment.Start--
+ }
+ reader.SetPosition(sl, ss)
+}
func (b *fencedCodeBlockParser) Continue(node ast.Node, reader text.Reader, pc Context) State {
line, segment := reader.PeekLine()
fdata := pc.Get(fencedCodeBlockInfoKey).(*fenceData)
+ // if code block line starts with a tab, keep a tab as it is.
+ if segment.Padding != 0 {
+ preserveLeadingTabInCodeBlock(&segment, reader)
+ }
w, pos := util.IndentWidth(line, reader.LineOffset())
if w < 4 {
i := pos
package externalaccount
import (
+ "context"
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
+ "encoding/json"
"errors"
"fmt"
+ "golang.org/x/oauth2"
"io"
"io/ioutil"
"net/http"
+ "net/url"
+ "os"
"path"
"sort"
"strings"
"time"
)
-// RequestSigner is a utility class to sign http requests using a AWS V4 signature.
+type awsSecurityCredentials struct {
+ AccessKeyID string `json:"AccessKeyID"`
+ SecretAccessKey string `json:"SecretAccessKey"`
+ SecurityToken string `json:"Token"`
+}
+
+// awsRequestSigner is a utility class to sign http requests using a AWS V4 signature.
type awsRequestSigner struct {
RegionName string
- AwsSecurityCredentials map[string]string
+ AwsSecurityCredentials awsSecurityCredentials
}
+// getenv aliases os.Getenv for testing
+var getenv = os.Getenv
+
const (
-// AWS Signature Version 4 signing algorithm identifier.
+ // AWS Signature Version 4 signing algorithm identifier.
awsAlgorithm = "AWS4-HMAC-SHA256"
-// The termination string for the AWS credential scope value as defined in
-// https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html
+ // The termination string for the AWS credential scope value as defined in
+ // https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html
awsRequestType = "aws4_request"
-// The AWS authorization header name for the security session token if available.
+ // The AWS authorization header name for the security session token if available.
awsSecurityTokenHeader = "x-amz-security-token"
-// The AWS authorization header name for the auto-generated date.
+ // The AWS authorization header name for the auto-generated date.
awsDateHeader = "x-amz-date"
- awsTimeFormatLong = "20060102T150405Z"
+ awsTimeFormatLong = "20060102T150405Z"
awsTimeFormatShort = "20060102"
)
signedRequest.Header.Add("host", requestHost(req))
- if securityToken, ok := rs.AwsSecurityCredentials["security_token"]; ok {
- signedRequest.Header.Add(awsSecurityTokenHeader, securityToken)
+ if rs.AwsSecurityCredentials.SecurityToken != "" {
+ signedRequest.Header.Add(awsSecurityTokenHeader, rs.AwsSecurityCredentials.SecurityToken)
}
if signedRequest.Header.Get("date") == "" {
}
func (rs *awsRequestSigner) generateAuthentication(req *http.Request, timestamp time.Time) (string, error) {
- secretAccessKey, ok := rs.AwsSecurityCredentials["secret_access_key"]
- if !ok {
- return "", errors.New("oauth2/google: missing secret_access_key header")
- }
- accessKeyId, ok := rs.AwsSecurityCredentials["access_key_id"]
- if !ok {
- return "", errors.New("oauth2/google: missing access_key_id header")
- }
-
canonicalHeaderColumns, canonicalHeaderData := canonicalHeaders(req)
dateStamp := timestamp.Format(awsTimeFormatShort)
serviceName = splitHost[0]
}
- credentialScope := fmt.Sprintf("%s/%s/%s/%s",dateStamp, rs.RegionName, serviceName, awsRequestType)
+ credentialScope := fmt.Sprintf("%s/%s/%s/%s", dateStamp, rs.RegionName, serviceName, awsRequestType)
requestString, err := canonicalRequest(req, canonicalHeaderColumns, canonicalHeaderData)
if err != nil {
return "", err
}
requestHash, err := getSha256([]byte(requestString))
- if err != nil{
+ if err != nil {
return "", err
}
stringToSign := fmt.Sprintf("%s\n%s\n%s\n%s", awsAlgorithm, timestamp.Format(awsTimeFormatLong), credentialScope, requestHash)
- signingKey := []byte("AWS4" + secretAccessKey)
+ signingKey := []byte("AWS4" + rs.AwsSecurityCredentials.SecretAccessKey)
for _, signingInput := range []string{
dateStamp, rs.RegionName, serviceName, awsRequestType, stringToSign,
} {
signingKey, err = getHmacSha256(signingKey, []byte(signingInput))
- if err != nil{
+ if err != nil {
+ return "", err
+ }
+ }
+
+ return fmt.Sprintf("%s Credential=%s/%s, SignedHeaders=%s, Signature=%s", awsAlgorithm, rs.AwsSecurityCredentials.AccessKeyID, credentialScope, canonicalHeaderColumns, hex.EncodeToString(signingKey)), nil
+}
+
+type awsCredentialSource struct {
+ EnvironmentID string
+ RegionURL string
+ RegionalCredVerificationURL string
+ CredVerificationURL string
+ TargetResource string
+ requestSigner *awsRequestSigner
+ region string
+ ctx context.Context
+ client *http.Client
+}
+
+type awsRequestHeader struct {
+ Key string `json:"key"`
+ Value string `json:"value"`
+}
+
+type awsRequest struct {
+ URL string `json:"url"`
+ Method string `json:"method"`
+ Headers []awsRequestHeader `json:"headers"`
+}
+
+func (cs awsCredentialSource) doRequest(req *http.Request) (*http.Response, error) {
+ if cs.client == nil {
+ cs.client = oauth2.NewClient(cs.ctx, nil)
+ }
+ return cs.client.Do(req.WithContext(cs.ctx))
+}
+
+func (cs awsCredentialSource) subjectToken() (string, error) {
+ if cs.requestSigner == nil {
+ awsSecurityCredentials, err := cs.getSecurityCredentials()
+ if err != nil {
return "", err
}
+
+ if cs.region, err = cs.getRegion(); err != nil {
+ return "", err
+ }
+
+ cs.requestSigner = &awsRequestSigner{
+ RegionName: cs.region,
+ AwsSecurityCredentials: awsSecurityCredentials,
+ }
+ }
+
+ // Generate the signed request to AWS STS GetCallerIdentity API.
+ // Use the required regional endpoint. Otherwise, the request will fail.
+ req, err := http.NewRequest("POST", strings.Replace(cs.RegionalCredVerificationURL, "{region}", cs.region, 1), nil)
+ if err != nil {
+ return "", err
+ }
+ // The full, canonical resource name of the workload identity pool
+ // provider, with or without the HTTPS prefix.
+ // Including this header as part of the signature is recommended to
+ // ensure data integrity.
+ if cs.TargetResource != "" {
+ req.Header.Add("x-goog-cloud-target-resource", cs.TargetResource)
+ }
+ cs.requestSigner.SignRequest(req)
+
+ /*
+ The GCP STS endpoint expects the headers to be formatted as:
+ # [
+ # {key: 'x-amz-date', value: '...'},
+ # {key: 'Authorization', value: '...'},
+ # ...
+ # ]
+ # And then serialized as:
+ # quote(json.dumps({
+ # url: '...',
+ # method: 'POST',
+ # headers: [{key: 'x-amz-date', value: '...'}, ...]
+ # }))
+ */
+
+ awsSignedReq := awsRequest{
+ URL: req.URL.String(),
+ Method: "POST",
+ }
+ for headerKey, headerList := range req.Header {
+ for _, headerValue := range headerList {
+ awsSignedReq.Headers = append(awsSignedReq.Headers, awsRequestHeader{
+ Key: headerKey,
+ Value: headerValue,
+ })
+ }
+ }
+ sort.Slice(awsSignedReq.Headers, func(i, j int) bool {
+ headerCompare := strings.Compare(awsSignedReq.Headers[i].Key, awsSignedReq.Headers[j].Key)
+ if headerCompare == 0 {
+ return strings.Compare(awsSignedReq.Headers[i].Value, awsSignedReq.Headers[j].Value) < 0
+ }
+ return headerCompare < 0
+ })
+
+ result, err := json.Marshal(awsSignedReq)
+ if err != nil {
+ return "", err
+ }
+ return url.QueryEscape(string(result)), nil
+}
+
+func (cs *awsCredentialSource) getRegion() (string, error) {
+ if envAwsRegion := getenv("AWS_REGION"); envAwsRegion != "" {
+ return envAwsRegion, nil
+ }
+
+ if cs.RegionURL == "" {
+ return "", errors.New("oauth2/google: unable to determine AWS region")
+ }
+
+ req, err := http.NewRequest("GET", cs.RegionURL, nil)
+ if err != nil {
+ return "", err
+ }
+
+ resp, err := cs.doRequest(req)
+ if err != nil {
+ return "", err
+ }
+ defer resp.Body.Close()
+
+ respBody, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20))
+ if err != nil {
+ return "", err
+ }
+
+ if resp.StatusCode != 200 {
+ return "", fmt.Errorf("oauth2/google: unable to retrieve AWS region - %s", string(respBody))
+ }
+
+ // This endpoint will return the region in format: us-east-2b.
+ // Only the us-east-2 part should be used.
+ respBodyEnd := 0
+ if len(respBody) > 1 {
+ respBodyEnd = len(respBody) - 1
+ }
+ return string(respBody[:respBodyEnd]), nil
+}
+
+func (cs *awsCredentialSource) getSecurityCredentials() (result awsSecurityCredentials, err error) {
+ if accessKeyID := getenv("AWS_ACCESS_KEY_ID"); accessKeyID != "" {
+ if secretAccessKey := getenv("AWS_SECRET_ACCESS_KEY"); secretAccessKey != "" {
+ return awsSecurityCredentials{
+ AccessKeyID: accessKeyID,
+ SecretAccessKey: secretAccessKey,
+ SecurityToken: getenv("AWS_SESSION_TOKEN"),
+ }, nil
+ }
+ }
+
+ roleName, err := cs.getMetadataRoleName()
+ if err != nil {
+ return
+ }
+
+ credentials, err := cs.getMetadataSecurityCredentials(roleName)
+ if err != nil {
+ return
+ }
+
+ if credentials.AccessKeyID == "" {
+ return result, errors.New("oauth2/google: missing AccessKeyId credential")
+ }
+
+ if credentials.SecretAccessKey == "" {
+ return result, errors.New("oauth2/google: missing SecretAccessKey credential")
+ }
+
+ return credentials, nil
+}
+
+func (cs *awsCredentialSource) getMetadataSecurityCredentials(roleName string) (awsSecurityCredentials, error) {
+ var result awsSecurityCredentials
+
+ req, err := http.NewRequest("GET", fmt.Sprintf("%s/%s", cs.CredVerificationURL, roleName), nil)
+ if err != nil {
+ return result, err
+ }
+ req.Header.Add("Content-Type", "application/json")
+
+ resp, err := cs.doRequest(req)
+ if err != nil {
+ return result, err
+ }
+ defer resp.Body.Close()
+
+ respBody, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20))
+ if err != nil {
+ return result, err
+ }
+
+ if resp.StatusCode != 200 {
+ return result, fmt.Errorf("oauth2/google: unable to retrieve AWS security credentials - %s", string(respBody))
+ }
+
+ err = json.Unmarshal(respBody, &result)
+ return result, err
+}
+
+func (cs *awsCredentialSource) getMetadataRoleName() (string, error) {
+ if cs.CredVerificationURL == "" {
+ return "", errors.New("oauth2/google: unable to determine the AWS metadata server security credentials endpoint")
+ }
+
+ req, err := http.NewRequest("GET", cs.CredVerificationURL, nil)
+ if err != nil {
+ return "", err
+ }
+
+ resp, err := cs.doRequest(req)
+ if err != nil {
+ return "", err
+ }
+ defer resp.Body.Close()
+
+ respBody, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20))
+ if err != nil {
+ return "", err
+ }
+
+ if resp.StatusCode != 200 {
+ return "", fmt.Errorf("oauth2/google: unable to retrieve AWS role name - %s", string(respBody))
}
- return fmt.Sprintf("%s Credential=%s/%s, SignedHeaders=%s, Signature=%s", awsAlgorithm, accessKeyId, credentialScope, canonicalHeaderColumns, hex.EncodeToString(signingKey)), nil
+ return string(respBody), nil
}
"fmt"
"golang.org/x/oauth2"
"net/http"
+ "strconv"
"time"
)
}
// parse determines the type of CredentialSource needed
-func (c *Config) parse(ctx context.Context) baseCredentialSource {
- if c.CredentialSource.File != "" {
- return fileCredentialSource{File: c.CredentialSource.File, Format: c.CredentialSource.Format}
+func (c *Config) parse(ctx context.Context) (baseCredentialSource, error) {
+ if len(c.CredentialSource.EnvironmentID) > 3 && c.CredentialSource.EnvironmentID[:3] == "aws" {
+ if awsVersion, err := strconv.Atoi(c.CredentialSource.EnvironmentID[3:]); err == nil {
+ if awsVersion != 1 {
+ return nil, fmt.Errorf("oauth2/google: aws version '%d' is not supported in the current build", awsVersion)
+ }
+ return awsCredentialSource{
+ EnvironmentID: c.CredentialSource.EnvironmentID,
+ RegionURL: c.CredentialSource.RegionURL,
+ RegionalCredVerificationURL: c.CredentialSource.RegionalCredVerificationURL,
+ CredVerificationURL: c.CredentialSource.URL,
+ TargetResource: c.Audience,
+ ctx: ctx,
+ }, nil
+ }
+ } else if c.CredentialSource.File != "" {
+ return fileCredentialSource{File: c.CredentialSource.File, Format: c.CredentialSource.Format}, nil
} else if c.CredentialSource.URL != "" {
- return urlCredentialSource{URL: c.CredentialSource.URL, Format: c.CredentialSource.Format, ctx: ctx}
+ return urlCredentialSource{URL: c.CredentialSource.URL, Format: c.CredentialSource.Format, ctx: ctx}, nil
}
- return nil
+ return nil, fmt.Errorf("oauth2/google: unable to parse credential source")
}
type baseCredentialSource interface {
func (ts tokenSource) Token() (*oauth2.Token, error) {
conf := ts.conf
- credSource := conf.parse(ts.ctx)
- if credSource == nil {
- return nil, fmt.Errorf("oauth2/google: unable to parse credential source")
+ credSource, err := conf.parse(ts.ctx)
+ if err != nil {
+ return nil, err
}
subjectToken, err := credSource.subjectToken()
+
if err != nil {
return nil, err
}
data.Set("subject_token_type", request.SubjectTokenType)
data.Set("subject_token", request.SubjectToken)
data.Set("scope", strings.Join(request.Scope, " "))
- opts, err := json.Marshal(options)
- if err != nil {
- return nil, fmt.Errorf("oauth2/google: failed to marshal additional options: %v", err)
+ if options != nil {
+ opts, err := json.Marshal(options)
+ if err != nil {
+ return nil, fmt.Errorf("oauth2/google: failed to marshal additional options: %v", err)
+ }
+ data.Set("options", string(opts))
}
- data.Set("options", string(opts))
authentication.InjectAuthentication(data, headers)
encodedData := data.Encode()
github.com/gorilla/mux
# github.com/gorilla/securecookie v1.1.1
github.com/gorilla/securecookie
-# github.com/gorilla/sessions v1.2.0
+# github.com/gorilla/sessions v1.2.1
+## explicit
github.com/gorilla/sessions
-# github.com/hashicorp/go-cleanhttp v0.5.1
+# github.com/hashicorp/go-cleanhttp v0.5.2
+## explicit
github.com/hashicorp/go-cleanhttp
# github.com/hashicorp/go-retryablehttp v0.6.8
## explicit
github.com/kr/pretty
# github.com/kr/text v0.2.0
github.com/kr/text
-# github.com/lafriks/xormstore v1.3.2
+# github.com/lafriks/xormstore v1.4.0
## explicit
github.com/lafriks/xormstore
github.com/lafriks/xormstore/util
# github.com/minio/md5-simd v1.1.1
## explicit
github.com/minio/md5-simd
-# github.com/minio/minio-go/v7 v7.0.7
+# github.com/minio/minio-go/v7 v7.0.9
## explicit
github.com/minio/minio-go/v7
github.com/minio/minio-go/v7/pkg/credentials
github.com/pquerna/otp
github.com/pquerna/otp/hotp
github.com/pquerna/otp/totp
-# github.com/prometheus/client_golang v1.8.0
+# github.com/prometheus/client_golang v1.9.0
## explicit
github.com/prometheus/client_golang/prometheus
github.com/prometheus/client_golang/prometheus/internal
github.com/prometheus/client_golang/prometheus/promhttp
# github.com/prometheus/client_model v0.2.0
github.com/prometheus/client_model/go
-# github.com/prometheus/common v0.14.0
+# github.com/prometheus/common v0.15.0
github.com/prometheus/common/expfmt
github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
github.com/prometheus/common/model
# github.com/willf/bitset v1.1.11
## explicit
github.com/willf/bitset
-# github.com/xanzy/go-gitlab v0.42.0
+# github.com/xanzy/go-gitlab v0.44.0
## explicit
github.com/xanzy/go-gitlab
# github.com/xanzy/ssh-agent v0.2.1
# github.com/yohcop/openid-go v1.0.0
## explicit
github.com/yohcop/openid-go
-# github.com/yuin/goldmark v1.3.1
+# github.com/yuin/goldmark v1.3.2
## explicit
github.com/yuin/goldmark
github.com/yuin/goldmark/ast
golang.org/x/net/ipv6
golang.org/x/net/proxy
golang.org/x/net/publicsuffix
-# golang.org/x/oauth2 v0.0.0-20210126194326-f9ce19ea3013
+# golang.org/x/oauth2 v0.0.0-20210210192628-66670185b0cd
## explicit
golang.org/x/oauth2
golang.org/x/oauth2/google
# strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
## explicit
strk.kbt.io/projects/go/libravatar
-# xorm.io/builder v0.3.7
+# xorm.io/builder v0.3.9
## explicit
xorm.io/builder
-# xorm.io/xorm v1.0.6
+# xorm.io/xorm v1.0.7
## explicit
xorm.io/xorm
xorm.io/xorm/caches
}
func noSQLQuoteNeeded(a interface{}) bool {
+ if a == nil {
+ return false
+ }
switch a.(type) {
case int, int8, int16, int32, int64:
return true
This changelog goes through all the changes that have been made in each release
without substantial changes to our git log.
+## [1.0.7](https://gitea.com/xorm/xorm/pulls?q=&type=all&state=closed&milestone=1336) - 2021-01-21
+
+* BUGFIXES
+ * Fix bug for mssql (#1854)
+* MISC
+ * fix_bugs_for_mssql (#1852)
+
## [1.0.6](https://gitea.com/xorm/xorm/pulls?q=&type=all&state=closed&milestone=1308) - 2021-01-05
* BUGFIXES
func (db *mssql) Init(uri *URI) error {
db.quoter = mssqlQuoter
+ db.defaultChar = "CHAR"
+ db.defaultVarchar = "VARCHAR"
return db.Base.Init(db, uri)
}
colName = strings.Trim(colName, "` ")
var isRegular bool
- if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) {
+ if (strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName)) && len(indexName) > (5+len(tableName)) {
indexName = indexName[5+len(tableName):]
isRegular = true
}
return s.Name == Json || s.Name == Jsonb
}
+func (s *SQLType) IsXML() bool {
+ return s.Name == XML
+}
+
var (
Bit = "BIT"
TinyInt = "TINYINT"
Json = "JSON"
Jsonb = "JSONB"
+ XML = "XML"
Array = "ARRAY"
SqlTypes = map[string]int{
Json: TEXT_TYPE,
Jsonb: TEXT_TYPE,
+ XML: TEXT_TYPE,
+
Char: TEXT_TYPE,
NChar: TEXT_TYPE,
Varchar: TEXT_TYPE,