提交 76b01980 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

agent build related functions

上级 a4575bf6
......@@ -12,12 +12,15 @@ require (
github.com/emirpasic/gods v1.12.0
github.com/fatih/color v1.9.0
github.com/go-errors/errors v1.0.2 // indirect
github.com/go-git/go-git/v5 v5.2.0
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/gorilla/mux v1.7.4
github.com/klauspost/compress v1.10.10
github.com/kr/pretty v0.2.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-runewidth v0.0.9
github.com/mholt/archiver/v3 v3.5.0
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
github.com/robfig/cron/v3 v3.0.1
......
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/awesome-gocui/gocui v0.6.0 h1:hhDJiQC12tEsJNJ+iZBBVaSSLFYo9llFuYpQlL5JZVI=
github.com/awesome-gocui/gocui v0.6.0/go.mod h1:1QikxFaPhe2frKeKvEwZEIGia3haiOxOUXKinrv17mA=
github.com/awesome-gocui/termbox-go v0.0.0-20190427202837-c0aef3d18bcc h1:wGNpKcHU8Aadr9yOzsT3GEsFLS7HQu8HxQIomnekqf0=
......@@ -12,24 +17,55 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
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/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q=
github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo=
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
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/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-errors/errors v1.0.2 h1:xMxH9j2fNg/L4hLn/4y3M0IUsn0M6Wbu/Uh9QlOfBh4=
github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM=
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-git v1.0.0 h1:YcN9iDGDoXuIw0vHls6rINwV416HYa0EB2X+RBsyYp4=
github.com/go-git/go-git v4.7.0+incompatible h1:+W9rgGY4DOKKdX2x6HxSR7HNeTxqiKrOvKnuittYVdA=
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
github.com/go-git/go-git/v5 v5.2.0 h1:YPBLG/3UK1we1ohRkncLjaXWLW+HKp5QNM/jTli2JgI=
github.com/go-git/go-git/v5 v5.2.0/go.mod h1:kh02eMX+wdqqxgNMEyq8YgwlIOsDOa9homkUq1PoTMs=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0=
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.10.10 h1:a/y8CglcM7gLGYmlbP/stPE5sR3hbhFRUjCBfd/0B3I=
github.com/klauspost/compress v1.10.10/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/pgzip v1.2.4 h1:TQ7CNpYKovDOmqzRHKxJh0BeaBI7UdQZYc6p7pMQh1A=
github.com/klauspost/pgzip v1.2.4/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
......@@ -50,8 +86,19 @@ github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mholt/archiver v1.1.2 h1:xukR55YIrnhDHp10lrNtRSsAK5THpWrOCuviweNSBw4=
github.com/mholt/archiver v3.1.1+incompatible h1:1dCVxuqs0dJseYEhi5pl7MYPH9zDa1wBi7mF09cbNkU=
github.com/mholt/archiver/v3 v3.5.0 h1:nE8gZIrw66cu4osS/U7UW7YDuGMHssxKutU8IfWxwWE=
github.com/mholt/archiver/v3 v3.5.0/go.mod h1:qqTTPUK/HZPFgFQ/TJ3BzvTpF/dPtFVJXdQbCmeMxwc=
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/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ=
github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
github.com/pierrec/lz4/v4 v4.0.3 h1:vNQKSVZNYUEAvRY9FaUXAF1XPbSOHJtDTiP41kzDz2E=
github.com/pierrec/lz4/v4 v4.0.3/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/errors v0.8.1/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/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo=
......@@ -61,6 +108,8 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
......@@ -71,20 +120,37 @@ github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIK
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.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
github.com/ulikunitz/xz v0.5.7 h1:YvTNdFzX6+W5m9msiYg/zpkSURPPtOlzbqYjrFn7Yt4=
github.com/ulikunitz/xz v0.5.7/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
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/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4 h1:0sw0nJM544SpsihWx1bkXdYLQDlzRflMgFJQ4Yih9ts=
github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4/go.mod h1:+ccdNT0xMY1dtc5XBxumbYfOUhmduiGudqaDgD2rVRE=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/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-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
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-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/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-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 h1:YTzHMGlqJu67/uEo1lBv0n3wBXhXNeUbB1XfN2vmTm0=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
......@@ -94,11 +160,15 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.56.0 h1:DPMeDvGTM54DXbPkVIZsp19fp/I2K7zwA/itHYHKo8Y=
gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
package domain
import (
serverConst "github.com/easysoft/zentaoatf/src/server/utils/const"
"time"
)
type Build struct {
WorkDir string
ProjectDir string
AppPath string
ID uint
Serial string
Priority int
NodeIp string
NodePort int
DeviceIp string
BuildType serverConst.BuildType
AppiumPort int
SeleniumDriverType serverConst.BrowserType
SeleniumDriverVersion string
SeleniumDriverPath string
QueueId uint
ScriptUrl string
ScmAddress string
ScmAccount string
ScmPassword string
AppUrl string
BuildCommands string
ResultFiles string
KeepResultFiles MyBool
ResultPath string
ResultMsg string
StartTime time.Time
CompleteTime time.Time
Progress serverConst.BuildProgress
Status serverConst.BuildStatus
}
package domain
import "fmt"
type MyBool bool
func (b *MyBool) Scan(src interface{}) error {
str, ok := src.(int64)
if !ok {
return fmt.Errorf("Unexpected type for MyBool: %T", src)
}
switch str {
case 0:
v := false
*b = MyBool(v)
case 1:
v := true
*b = MyBool(v)
}
return nil
}
package domain
import serverConst "github.com/easysoft/zentaoatf/src/server/utils/const"
type OptResult struct {
Code int `json:"code"`
Msg string `json:"msg"`
Payload interface{} `json:"payload"`
}
func (result *OptResult) Success(msg string) {
result.Code = serverConst.ResultSuccess.Int()
result.Msg = msg
}
func (result *OptResult) Fail(msg string) {
result.Code = serverConst.ResultFail.Int()
result.Msg = msg
}
func (result *OptResult) IsSuccess() bool {
return result.Code == serverConst.ResultSuccess.Int()
}
package domain
type ReqData struct {
Action string `json:"action"`
Id int `json:"id"`
Mode string `json:"mode"`
Data string `json:"data"`
}
type RespData struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
WorkDir string `json:"workDir"`
}
package serverModel
package domain
type SysInfo struct {
AgentDir string `json:"agentDir"`
......
package serverModel
import (
"time"
)
type ReqData struct {
Action string `json:"action"`
Id int `json:"id"`
DomainId int `json:"domainId"`
Mode string `json:"mode"`
Data interface{} `json:"data"`
Src int `json:"src"`
Dist int `json:"dist"`
Keywords string `json:"keywords"`
Page int `json:"page"`
}
type ResData struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
Model interface{} `json:"model"`
Res interface{} `json:"res"`
WorkDir string `json:"workDir"`
Total int `json:"total"`
}
type Model struct {
ID uint `gorm:"column:id;primary_key" json:"id"`
CreatedAt time.Time `gorm:"column:createdAt" json:"createdAt" yaml:"-"`
UpdatedAt time.Time `gorm:"column:updatedAt" json:"updatedAt" yaml:"-"`
Disabled bool `gorm:"column:disabled;default:false" json:"disabled" yaml:"-"`
Deleted bool `gorm:"column:deleted;default:false" json:"deleted" yaml:"-"`
}
......@@ -3,7 +3,7 @@ package server
import (
"encoding/json"
"fmt"
serverModel "github.com/easysoft/zentaoatf/src/server/model"
"github.com/easysoft/zentaoatf/src/server/domain"
"github.com/easysoft/zentaoatf/src/server/service"
serverUtils "github.com/easysoft/zentaoatf/src/server/utils/common"
serverConst "github.com/easysoft/zentaoatf/src/server/utils/const"
......@@ -18,16 +18,24 @@ import (
type Server struct {
commonService *service.CommonService
agentService *service.AgentService
buildService *service.BuildService
taskService *service.TaskService
cronService *service.CronService
}
func NewServer() *Server {
commonService := service.NewCommonService()
agentService := service.NewAgentService()
taskService := service.NewTaskService()
buildService := service.NewBuildService(taskService)
cronService := service.NewCronService(commonService)
cronService.Init()
return &Server{commonService: commonService, agentService: agentService, cronService: cronService}
return &Server{commonService: commonService, agentService: agentService,
buildService: buildService, taskService: taskService,
cronService: cronService}
}
func (s *Server) Init() {
......@@ -57,7 +65,7 @@ func (s *Server) Handler() http.Handler {
}
func (s *Server) handle(writer http.ResponseWriter, req *http.Request) {
ret := serverModel.ResData{Code: 1, Msg: "success"}
ret := domain.RespData{Code: 1, Msg: "success"}
var err error
serverUtils.SetupCORS(&writer, req)
......@@ -81,17 +89,15 @@ func (s *Server) handle(writer http.ResponseWriter, req *http.Request) {
io.WriteString(writer, string(bytes))
}
func (s *Server) get(req *http.Request) (resp serverModel.ResData, err error) {
func (s *Server) get(req *http.Request) (resp domain.RespData, err error) {
method, _ := serverUtils.ParserGetParams(req)
switch method {
case "ListTask":
resp.Msg = "ListTask"
case "ListHistory":
resp.Msg = "ListHistory"
case "PushTask":
resp.Msg = "PushTask"
case "listTask":
resp.Msg = "listTask"
case "listHistory":
resp.Msg = "listHistory"
case "":
resp.Code = 0
......@@ -104,13 +110,13 @@ func (s *Server) get(req *http.Request) (resp serverModel.ResData, err error) {
return
}
func (s *Server) post(req *http.Request) (resp serverModel.ResData, err error) {
func (s *Server) post(req *http.Request) (resp domain.RespData, err error) {
body, err := ioutil.ReadAll(req.Body)
if len(body) == 0 {
return
}
reqData := serverModel.ReqData{}
reqData := domain.ReqData{}
err = serverUtils.ParserJsonReq(body, &reqData)
if err != nil {
return
......@@ -120,7 +126,8 @@ func (s *Server) post(req *http.Request) (resp serverModel.ResData, err error) {
switch method {
case "ListTask":
case "addTask":
s.buildService.Add(reqData)
default:
resp.Code = 0
......
package service
import (
"encoding/json"
"fmt"
"github.com/easysoft/zentaoatf/src/server/domain"
logUtils "github.com/easysoft/zentaoatf/src/utils/log"
)
type BuildService struct {
taskService *TaskService
}
func NewBuildService(taskService *TaskService) *BuildService {
return &BuildService{taskService: taskService}
}
func (s *BuildService) Add(req domain.ReqData) (reply domain.OptResult) {
build := domain.Build{}
err := json.Unmarshal([]byte(req.Data), &build)
if err != nil {
logUtils.PrintTo(fmt.Sprintf("error: %v", err))
return
}
size := s.taskService.GetSize()
if size == 0 {
s.taskService.Add(build)
reply.Success("Success to add job.")
} else {
reply.Fail(fmt.Sprintf("already has %d jobs to be done.", size))
}
return
}
package service
import (
"github.com/easysoft/zentaoatf/src/server/domain"
serverConst "github.com/easysoft/zentaoatf/src/server/utils/const"
"time"
)
var (
tasks = make([]domain.Build, 0)
tm = time.Now()
isRunning = false
)
type TaskService struct {
buildService *BuildService
}
func NewTaskService() *TaskService {
return &TaskService{}
}
func (s *TaskService) Add(build domain.Build) {
tasks = append(tasks, build)
}
func (s *TaskService) Peek() domain.Build {
return tasks[0]
}
func (s *TaskService) Remove() (task domain.Build) {
if len(tasks) == 0 {
return task
}
task = tasks[0]
tasks = tasks[1:]
return task
}
func (s *TaskService) Start() {
tm = time.Now()
isRunning = true
}
func (s *TaskService) End() {
isRunning = false
}
func (s *TaskService) GetSize() int {
return len(tasks)
}
func (s *TaskService) CheckRunning() bool {
if time.Now().Unix()-tm.Unix() > serverConst.AgentRunTime*60*1000 {
isRunning = false
}
return isRunning
}
package serverUtils
import (
"strings"
)
func GetGitProjectName(gitUrl string) string {
index := strings.LastIndex(gitUrl, "/")
name := gitUrl[index+1:]
name = strings.Split(name, ".git")[0]
return name
}
......@@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
serverModel "github.com/easysoft/zentaoatf/src/server/model"
serverModel "github.com/easysoft/zentaoatf/src/server/domain"
"io"
"log"
"net/http"
......@@ -23,13 +23,13 @@ func OutputErr(err error, writer http.ResponseWriter) {
WriteRes(errRes, writer)
}
func WriteRes(ret serverModel.ResData, writer http.ResponseWriter) {
func WriteRes(ret serverModel.RespData, writer http.ResponseWriter) {
jsonStr, _ := json.Marshal(ret)
io.WriteString(writer, string(jsonStr))
}
func ErrRes(msg string) serverModel.ResData {
return serverModel.ResData{Code: 0, Msg: msg}
func ErrRes(msg string) serverModel.RespData {
return serverModel.RespData{Code: 0, Msg: msg}
}
func ParserJsonReq(bytes []byte, obj *serverModel.ReqData) (err error) {
......
package serverUtils
import (
serverModel "github.com/easysoft/zentaoatf/src/server/domain"
fileUtils "github.com/easysoft/zentaoatf/src/utils/file"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/mholt/archiver/v3"
uuid "github.com/satori/go.uuid"
"os"
"strings"
)
func GetTestScript(build *serverModel.Build) (result serverModel.OptResult) {
if build.ScmAddress != "" {
CheckoutCodes(build)
} else if strings.Index(build.ScriptUrl, "http://") == 0 {
DownloadCodes(build)
} else {
build.ProjectDir = fileUtils.AddPathSepIfNeeded(build.ScriptUrl)
}
result.Success("")
return result
}
func CheckoutCodes(task *serverModel.Build) {
url := task.ScmAddress
userName := task.ScmAccount
password := task.ScmPassword
projectDir := task.WorkDir + GetGitProjectName(url) + string(os.PathSeparator)
fileUtils.MkDirIfNeeded(projectDir)
options := git.CloneOptions{
URL: url,
Progress: os.Stdout,
}
if userName != "" {
options.Auth = &http.BasicAuth{
Username: userName,
Password: password,
}
}
_, err := git.PlainClone(projectDir, false, &options)
if err != nil {
return
}
task.ProjectDir = projectDir
}
func DownloadCodes(task *serverModel.Build) {
zipPath := task.WorkDir + uuid.NewV4().String() + fileUtils.GetExtName(task.ScriptUrl)
Download(task.ScriptUrl, zipPath)
scriptFolder := GetZipSingleDir(zipPath)
if scriptFolder != "" { // single dir in zip
task.ProjectDir = task.WorkDir + scriptFolder
archiver.Unarchive(zipPath, task.WorkDir)
} else { // more then one dir, unzip to a folder
fileNameWithoutExt := fileUtils.GetFileNameWithoutExt(zipPath)
task.ProjectDir = task.WorkDir + fileNameWithoutExt + string(os.PathSeparator)
archiver.Unarchive(zipPath, task.ProjectDir)
}
}
package serverUtils
import (
"fmt"
errUtils "github.com/easysoft/zentaoatf/src/utils/err"
logUtils "github.com/easysoft/zentaoatf/src/utils/log"
"github.com/klauspost/compress/zip"
"github.com/mholt/archiver/v3"
"io/ioutil"
"net/http"
"strings"
)
func Download(url string, dst string) {
fmt.Printf("DownloadToFile From: %s.\n", url)
if d, err := HTTPDownload(url); err == nil {
logUtils.Logger.Info(fmt.Sprintf("downloaded %s.\n", url))
if WriteDownloadFile(dst, d) == nil {
logUtils.Logger.Info(fmt.Sprintf("saved %s as %s\n", url, dst))
}
}
}
func HTTPDownload(uri string) ([]byte, error) {
logUtils.Logger.Info(fmt.Sprintf("HTTPDownload From: %s.\n", uri))
res, err := http.Get(uri)
if err != nil {
logUtils.Logger.Error(err.Error())
}
defer res.Body.Close()
d, err := ioutil.ReadAll(res.Body)
if err != nil {
logUtils.Logger.Error(err.Error())
}
logUtils.Logger.Info(fmt.Sprintf("ReadFile: Size of download: %d\n", len(d)))
return d, err
}
func WriteDownloadFile(dst string, d []byte) error {
logUtils.Logger.Info(fmt.Sprintf("WriteFile: Size of download: %d\n", len(d)))
err := ioutil.WriteFile(dst, d, 0444)
if err != nil {
logUtils.Logger.Error(err.Error())
}
return err
}
func GetZipSingleDir(path string) string {
folder := ""
z := archiver.Zip{}
err := z.Walk(path, func(f archiver.File) error {
if f.IsDir() {
zfh, ok := f.Header.(zip.FileHeader)
if ok {
fmt.Println("file: ", zfh.Name)
if folder == "" && zfh.Name != "__MACOSX" {
folder = zfh.Name
} else {
if strings.Index(zfh.Name, folder) != 0 {
return errUtils.New("found more than one folder")
}
}
}
}
return nil
})
if err != nil {
return ""
}
return folder
}
......@@ -3,7 +3,7 @@ package serverUtils
import (
"bytes"
"errors"
serverModel "github.com/easysoft/zentaoatf/src/server/model"
serverModel "github.com/easysoft/zentaoatf/src/server/domain"
"github.com/easysoft/zentaoatf/src/utils/vari"
"os"
"os/exec"
......
......@@ -3,5 +3,6 @@ package serverConst
const (
HeartBeatInterval = 5
AgentDir = "ztf_agent"
AgentDir = "ztf_agent"
AgentRunTime = 30 * 60
)
package serverConst
type ResultCode int
const (
ResultSuccess ResultCode = 1
ResultFail ResultCode = 0
)
func (c ResultCode) Int() int {
return int(c)
}
type BuildProgress string
const (
ProgressCreated BuildProgress = "created"
ProgressLaunchVm BuildProgress = "launch_vm"
ProgressPending BuildProgress = "pending"
ProgressInProgress BuildProgress = "in_progress"
ProgressTimeout BuildProgress = "timeout"
ProgressCompleted BuildProgress = "completed"
)
type BuildStatus string
const (
StatusCreated BuildStatus = "created"
StatusPass BuildStatus = "pass"
StatusFail BuildStatus = "fail"
)
type VmStatus string
const (
VmCreated VmStatus = "created"
VmLaunch VmStatus = "launch"
VmRunning VmStatus = "running"
VmActive VmStatus = "active"
VmBusy VmStatus = "busy"
VmDestroy VmStatus = "destroy"
VmFailToCreate VmStatus = "fail_to_create"
VmFailToDestroy VmStatus = "fail_to_destroy"
VmUnknown VmStatus = "unknown"
)
type HostStatus string
const (
HostActive HostStatus = "active"
HostOffline HostStatus = "offline"
)
type DeviceStatus string
const (
DeviceOff DeviceStatus = "off"
DeviceOn DeviceStatus = "on"
DeviceActive DeviceStatus = "active"
DeviceBusy DeviceStatus = "busy"
DeviceUnknown DeviceStatus = "unknown"
)
type ServiceStatus string
const (
ServiceOff ServiceStatus = "off"
ServiceOn ServiceStatus = "on"
ServiceActive ServiceStatus = "active"
ServiceBusy ServiceStatus = "busy"
)
type Platform string
const (
Android Platform = "android"
Ios Platform = "ios"
Host Platform = "host"
Vm Platform = "vm"
)
type BuildType string
const (
AppiumTest BuildType = "appium_test"
SeleniumTest BuildType = "selenium_test"
UnitTest BuildType = "unit_test"
)
type OsPlatform string
const (
OsWindows OsPlatform = "windows"
OsLinux OsPlatform = "linux"
OsMac OsPlatform = "mac"
OsDriver OsPlatform = "driver"
)
type OsType string
const (
Win10 OsType = "win10"
Win7 OsType = "win7"
WinXP OsType = "winxp"
Ubuntu OsType = "ubuntu"
CentOS OsType = "centos"
Mac OsType = "mac"
Virtio OsType = "virtio"
)
type OsLang string
const (
EN_US OsLang = "en_us"
ZH_CN OsLang = "zh_cn"
ZH_TW OsLang = "zh_tw"
ZH_HK OsLang = "zh_hk"
DE_DE OsLang = "de_de"
JA_JP OsLang = "ja_jp"
FR_FR OsLang = "fr_fr"
RU_RU OsLang = "ru_ru"
)
type BrowserType string
const (
Chrome BrowserType = "chrome"
Firefox BrowserType = "firefox"
Edge BrowserType = "edge"
IE BrowserType = "ie"
)
package errUtils
func New(text string) error {
return &errorStr{text}
}
type errorStr struct {
str string
}
func (e *errorStr) Error() string {
return e.str
}
......@@ -226,3 +226,22 @@ func CopyFile(src, dst string) (int64, error) {
nBytes, err := io.Copy(destination, source)
return nBytes, err
}
func GetFileNameWithoutExt(pathOrUrl string) string {
name := GetFileName(pathOrUrl)
index := strings.LastIndex(name, ".")
return name[:index]
}
func GetExtName(pathOrUrl string) string {
index := strings.LastIndex(pathOrUrl, ".")
return pathOrUrl[index:]
}
func GetFileName(pathOrUrl string) string {
index := strings.LastIndex(pathOrUrl, string(os.PathSeparator))
name := pathOrUrl[index+1:]
return name
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册