diff --git a/go.mod b/go.mod index 222fefb..96c08bf 100644 --- a/go.mod +++ b/go.mod @@ -3,34 +3,19 @@ module github.com/chen-keinan/beacon go 1.14 require ( - github.com/Knetic/govaluate v3.0.0+incompatible github.com/cheggaaa/pb v1.0.29 github.com/chen-keinan/go-command-eval v0.0.2 - github.com/gobuffalo/envy v1.9.0 // indirect - github.com/gobuffalo/logger v1.0.4 // indirect - github.com/gobuffalo/packd v1.0.0 // indirect + github.com/chen-keinan/go-user-plugins v0.0.4 github.com/gobuffalo/packr v1.30.1 - github.com/gobuffalo/packr/v2 v2.8.1 // indirect github.com/golang/mock v1.6.0 github.com/gosuri/uitable v0.0.4 - github.com/karrick/godirwalk v1.16.1 // indirect - github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect github.com/magiconair/properties v1.8.5 - github.com/mattn/go-isatty v0.0.12 // indirect - github.com/mattn/go-runewidth v0.0.7 // indirect github.com/mitchellh/cli v1.1.2 github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db github.com/mitchellh/mapstructure v1.4.1 - github.com/rogpeppe/go-internal v1.8.0 // indirect - github.com/sirupsen/logrus v1.8.1 // indirect - github.com/spf13/cobra v1.2.1 // indirect github.com/stretchr/testify v1.7.0 go.uber.org/fx v1.13.1 go.uber.org/zap v1.18.1 - golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect - golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect - golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect - golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect - golang.org/x/tools v0.1.2 // indirect + golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e // indirect gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index db7375b..ed7086a 100644 --- a/go.sum +++ b/go.sum @@ -69,6 +69,10 @@ github.com/cheggaaa/pb v1.0.29 h1:FckUN5ngEk2LpvuG0fw1GEFx6LtyY2pWI/Z2QgCnEYo= github.com/cheggaaa/pb v1.0.29/go.mod h1:W40334L7FMC5JKWldsTWbdGjLo0RxUKK73K+TuPxX30= github.com/chen-keinan/go-command-eval v0.0.2 h1:AX61aKAWv8b/TUEk4HkvfWgheIbV0lKSwt/8r3whOU0= github.com/chen-keinan/go-command-eval v0.0.2/go.mod h1:fpE+yYOq5AAybeT2iLG0v30o0L/2NtOHbEUtufWstk0= +github.com/chen-keinan/go-user-plugins v0.0.4 h1:0csMIC6TFLLVA4g5T+RRXXPnw/Dsr8nRgypIE9ZNEXw= +github.com/chen-keinan/go-user-plugins v0.0.4/go.mod h1:3EDlzuXfBL94XRyO5U0WR7UdwfpMSTbEE+W93in7+lQ= +github.com/chen-keinan/lxd-probe v0.2.0 h1:1H3gEc20ol5NiUBDiLU2AXjxwY7rXR5/4w1joK7G5TY= +github.com/chen-keinan/lxd-probe v0.2.0/go.mod h1:UMJjgIJHGxchNNpNGOS8HuhO5EMGm5be8HOS92KDYY0= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -116,7 +120,6 @@ github.com/gobuffalo/envy v1.9.0 h1:eZR0DuEgVLfeIb1zIKt3bT4YovIMf9O9LXQeCZLXpqE= github.com/gobuffalo/envy v1.9.0/go.mod h1:FurDp9+EDPE4aIUS3ZLyD+7/9fpx7YRt/ukY6jIHf0w= github.com/gobuffalo/logger v1.0.0/go.mod h1:2zbswyIUa45I+c+FLXuWl9zSWEiVuthsk8ze5s8JvPs= github.com/gobuffalo/logger v1.0.3/go.mod h1:SoeejUwldiS7ZsyCBphOGURmWdwUFXs0J7TCjEhjKxM= -github.com/gobuffalo/logger v1.0.4 h1:HFJRqL7AmL4QNvQb9Grss9sDz+3u02VBgAoR03A7q4o= github.com/gobuffalo/logger v1.0.4/go.mod h1:/GRUdWb+gM3shxj0P5jiV6ecVS3X0aboJvl+hBu0HeE= github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q= github.com/gobuffalo/packd v1.0.0 h1:6ERZvJHfe24rfFmA9OaoKBdC7+c9sydrytMg8SdFGBM= @@ -124,7 +127,6 @@ github.com/gobuffalo/packd v1.0.0/go.mod h1:6VTc4htmJRFB7u1m/4LeMTWjFoYrUiBkU9Fd github.com/gobuffalo/packr v1.30.1 h1:hu1fuVR3fXEZR7rXNW3h8rqSML8EVAf6KNm0NKO/wKg= github.com/gobuffalo/packr v1.30.1/go.mod h1:ljMyFO2EcrnzsHsN99cvbq055Y9OhRrIaviy289eRuk= github.com/gobuffalo/packr/v2 v2.5.1/go.mod h1:8f9c96ITobJlPzI44jj+4tHnEKNt0xXWSVlXRN9X1Iw= -github.com/gobuffalo/packr/v2 v2.8.1 h1:tkQpju6i3EtMXJ9uoF5GT6kB+LMTimDWD8Xvbz6zDVA= github.com/gobuffalo/packr/v2 v2.8.1/go.mod h1:c/PLlOuTU+p3SybaJATW3H6lX/iK7xEz5OeMf+NnJpg= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -231,7 +233,6 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= @@ -243,14 +244,12 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/karrick/godirwalk v1.15.8/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= -github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw= github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= 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/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -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/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -262,9 +261,7 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/markbates/errx v1.1.0 h1:QDFeR+UP95dO12JgW+tgi2UVfo0V8YBHiUIOaeBPiEI= github.com/markbates/errx v1.1.0/go.mod h1:PLa46Oex9KNbVDZhKel8v1OT7hD5JZ2eI7AHhA0wswc= -github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY= github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= @@ -272,12 +269,11 @@ github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaa github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 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-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.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= -github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +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/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= @@ -303,6 +299,7 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= @@ -340,7 +337,6 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= @@ -352,12 +348,10 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= -github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw= github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= @@ -525,7 +519,6 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -551,7 +544,6 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -578,11 +570,11 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf h1:2ucpDCmfkl8Bd/FsLtiD653Wf96cW37s+iGx93zsu4k= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e h1:XMgFehsDnnLGtjvjOfqWSUzt0alpTR1RSEuznObga2c= +golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/internal/bplugin/bplugin.go b/internal/bplugin/bplugin.go deleted file mode 100644 index 4b67f45..0000000 --- a/internal/bplugin/bplugin.go +++ /dev/null @@ -1,141 +0,0 @@ -package bplugin - -import ( - "fmt" - "github.com/chen-keinan/beacon/pkg/models" - "github.com/chen-keinan/beacon/pkg/utils" - "io/ioutil" - "math/rand" - "os" - "os/exec" - "path/filepath" - "plugin" -) - -// PluginLoader keeps the context needed to find where Plugins and -// objects are stored. -type PluginLoader struct { - pluginsDir string - objectsDir string -} - -//NewPluginLoader return new plugin loader object with src and compiled folders -func NewPluginLoader() (*PluginLoader, error) { - fm := utils.NewKFolder() - // The directory that will be watched for new Plugins. - srcFolder, err := utils.GetPluginSourceSubFolder(fm) - if err != nil { - return nil, fmt.Errorf("could not find current directory: %v", err) - } - // The directory where all .so files will be stored. - compiledFolder, err := utils.GetCompilePluginSubFolder(fm) - if err != nil { - return nil, fmt.Errorf("could not create objects dir: %v", err) - } - return &PluginLoader{pluginsDir: srcFolder, objectsDir: compiledFolder}, nil -} - -//Compile the go plugin in a given path and hook name and return it symbol -func (l *PluginLoader) Compile(name string, hookName string) (plugin.Symbol, error) { - obj, err := l.compile(name) - if err != nil { - return nil, fmt.Errorf("could not compile %s: %v", name, err) - } - defer func() { - err = os.Remove(obj) - if err != nil { - fmt.Println(err) - } - }() - - var sym plugin.Symbol - if sym, err = l.load(obj, hookName); err != nil { - return nil, fmt.Errorf("could not compile %s: %v", name, err) - } - return sym, nil -} - -// compile compiles the code in the given path, builds a -// plugin, and returns its path. -//nolint:gosec -func (l *PluginLoader) compile(name string) (string, error) { - // Copy the file to the objects directory with a different name - // each time, to avoid retrieving the cached version. - // Apparently the cache key is the path of the file compiled and - // there's no way to invalidate it. - f, err := ioutil.ReadFile(filepath.Join(l.pluginsDir, name)) - if err != nil { - return "", fmt.Errorf("could not read %s: %v", name, err) - } - - name = fmt.Sprintf("%d.go", rand.Int()) - srcPath := filepath.Join(l.objectsDir, name) - fileCreated, err := os.Create(srcPath) - if err != nil { - return "", fmt.Errorf("could not write %s: %v", name, err) - } - defer func() { - err = fileCreated.Close() - if err != nil { - fmt.Print(err.Error()) - } - }() - _, err = fileCreated.WriteString(string(f)) - if err != nil { - return "", fmt.Errorf("could not write %s: %v", name, err) - } - objectPath := srcPath[:len(srcPath)-3] + ".so" - cmd := exec.Command("go", "build", "-buildmode=plugin", fmt.Sprintf("-o=%s", objectPath), srcPath) - cmd.Stderr = os.Stderr - cmd.Stdout = os.Stdout - if err := cmd.Run(); err != nil { - return "", fmt.Errorf("could not compile %s: %v", name, err) - } - - return objectPath, nil -} - -// load loads the plugin object in the given path and runs the Run -// function. -func (l *PluginLoader) load(object string, hookName string) (plugin.Symbol, error) { - p, err := plugin.Open(object) - if err != nil { - return nil, fmt.Errorf("could not open %s: %v", object, err) - } - return p.Lookup(hookName) -} - -//ExecuteK8sAuditResults execute on K8s api call hook -func ExecuteK8sAuditResults(sym plugin.Symbol, auditEvt models.KubeAuditResults) error { - runFunc, ok := sym.(func(netEvent models.KubeAuditResults) error) - if !ok { - return fmt.Errorf("found Run but type is %T instead of func() error", sym) - } - return runFunc(auditEvt) -} - -//Plugins lists all the files in the Plugins -func (l *PluginLoader) Plugins() ([]string, error) { - dir, err := os.Open(l.pluginsDir) - if err != nil { - return nil, err - } - defer func() { - err = dir.Close() - if err != nil { - fmt.Println(err.Error()) - } - }() - names, err := dir.Readdirnames(-1) - if err != nil { - return nil, err - } - - var res []string - for _, name := range names { - if filepath.Ext(name) == ".go" { - res = append(res, name) - } - } - return res, nil -} diff --git a/internal/bplugin/bplugin_test.go b/internal/bplugin/bplugin_test.go deleted file mode 100644 index 3093d54..0000000 --- a/internal/bplugin/bplugin_test.go +++ /dev/null @@ -1,105 +0,0 @@ -package bplugin - -import ( - "fmt" - "github.com/chen-keinan/beacon/internal/common" - "github.com/chen-keinan/beacon/pkg/models" - "github.com/chen-keinan/beacon/pkg/utils" - "github.com/stretchr/testify/assert" - "io/ioutil" - "os" - "path" - "testing" -) - -func TestPluginLoader_Plugins(t *testing.T) { - pl, err := pluginSetUp("k8s_bench_audit_result_hook.go") - assert.NoError(t, err) - plFiles, err := pl.Plugins() - assert.NoError(t, err) - assert.Equal(t, plFiles[0], "test_plugin.go") -} - -func TestExecuteNetEvt(t *testing.T) { - pl, err := pluginSetUp("k8s_bench_audit_result_hook.go") - assert.NoError(t, err) - plFiles, err := pl.Plugins() - assert.NoError(t, err) - sym, err := pl.Compile(plFiles[0], common.K8sBenchAuditResultHook) - assert.NoError(t, err) - err = ExecuteK8sAuditResults(sym, models.KubeAuditResults{}) - assert.NoError(t, err) -} - -func TestPluginLoader_CompileBad(t *testing.T) { - pl, err := pluginSetUp("empty.go") - assert.NoError(t, err) - plFiles, err := pl.Plugins() - assert.NoError(t, err) - _, err = pl.Compile(plFiles[0], common.K8sBenchAuditResultHook) - assert.Error(t, err) - _, err = pl.Compile("a/b/c", common.K8sBenchAuditResultHook) - assert.Error(t, err) -} -func TestPluginLoader_CompileWrongHook(t *testing.T) { - pl, err := pluginSetUp("k8s_bench_audit_result_hook.go") - assert.NoError(t, err) - plFiles, err := pl.Plugins() - assert.NoError(t, err) - _, err = pl.Compile(plFiles[0], "NoHook") - assert.Error(t, err) -} - -func pluginSetUp(fileName string) (*PluginLoader, error) { - fm := utils.NewKFolder() - folder, err := utils.GetPluginSourceSubFolder(fm) - if err != nil { - return nil, err - } - err = os.RemoveAll(folder) - if err != nil { - return nil, err - } - cfolder, err := utils.GetCompilePluginSubFolder(fm) - if err != nil { - return nil, err - } - err = os.RemoveAll(cfolder) - if err != nil { - return nil, err - } - err = utils.CreateHomeFolderIfNotExist(fm) - if err != nil { - return nil, err - } - err = utils.CreatePluginsSourceFolderIfNotExist(fm) - if err != nil { - return nil, err - } - err = utils.CreatePluginsCompiledFolderIfNotExist(fm) - if err != nil { - return nil, err - } - f, err := os.Open(fmt.Sprintf("./fixtures/%s", fileName)) - if err != nil { - return nil, err - } - defer f.Close() - data, err := ioutil.ReadAll(f) - if err != nil { - return nil, err - } - nf, err := os.Create(path.Join(folder, "test_plugin.go")) - if err != nil { - return nil, err - } - _, err = nf.WriteString(string(data)) - if err != nil { - return nil, err - } - pl, err := NewPluginLoader() - if err != nil { - return nil, err - } - return pl, err -} diff --git a/internal/bplugin/fixtures/empty.go b/internal/bplugin/fixtures/empty.go deleted file mode 100644 index 06ab7d0..0000000 --- a/internal/bplugin/fixtures/empty.go +++ /dev/null @@ -1 +0,0 @@ -package main diff --git a/internal/bplugin/fixtures/k8s_bench_audit_result_hook.go b/internal/bplugin/fixtures/k8s_bench_audit_result_hook.go deleted file mode 100644 index 6125422..0000000 --- a/internal/bplugin/fixtures/k8s_bench_audit_result_hook.go +++ /dev/null @@ -1,14 +0,0 @@ -package main - -import ( - "fmt" - "github.com/chen-keinan/beacon/pkg/models" -) - -//K8sBenchAuditResultHook this plugin method accept k8s audit bench results -//event include test data , description , audit, remediation and result -//nolint -func K8sBenchAuditResultHook(k8sAuditResults models.KubeAuditResults) error { - fmt.Println("this is K8sBenchAuditResultHook plugin") - return nil -} diff --git a/internal/bplugin/model.go b/internal/bplugin/model.go deleted file mode 100644 index bdbe5ff..0000000 --- a/internal/bplugin/model.go +++ /dev/null @@ -1,8 +0,0 @@ -package bplugin - -import "plugin" - -//K8sBenchAuditResultHook hold the plugin symbol for K8s bench audit result Hook -type K8sBenchAuditResultHook struct { - Plugins []plugin.Symbol -} diff --git a/internal/cli/cli.go b/internal/cli/cli.go index bacfec1..830db4f 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -4,14 +4,15 @@ import ( "bytes" "context" "fmt" - "github.com/chen-keinan/beacon/internal/bplugin" "github.com/chen-keinan/beacon/internal/cli/commands" "github.com/chen-keinan/beacon/internal/common" + "github.com/chen-keinan/beacon/internal/hook" "github.com/chen-keinan/beacon/internal/logger" "github.com/chen-keinan/beacon/internal/startup" "github.com/chen-keinan/beacon/pkg/models" "github.com/chen-keinan/beacon/pkg/utils" "github.com/chen-keinan/go-command-eval/eval" + "github.com/chen-keinan/go-user-plugins/uplugin" "github.com/mitchellh/cli" "go.uber.org/fx" "go.uber.org/zap" @@ -86,19 +87,26 @@ func initPluginFolders(fm utils.FolderMgr) { } //loadAuditBenchPluginSymbols load API call plugin symbols -func loadAuditBenchPluginSymbols(log *zap.Logger) bplugin.K8sBenchAuditResultHook { - pl, err := bplugin.NewPluginLoader() +func loadAuditBenchPluginSymbols(log *zap.Logger) hook.K8sBenchAuditResultHook { + fm := utils.NewKFolder() + sourceFolder, err := utils.GetPluginSourceSubFolder(fm) if err != nil { - log.Error(fmt.Sprintf("failed to load plugin symbol %s", err.Error())) + panic("failed tpo get plugin source sourceFolder") } - plugins, err := pl.Plugins() + compliledFolder, err := utils.GetCompilePluginSubFolder(fm) if err != nil { - log.Error(fmt.Sprintf("failed to load plugin symbol %s", err.Error())) + panic("failed tpo get plugin compiled sourceFolder") } - apiPlugin := bplugin.K8sBenchAuditResultHook{Plugins: make([]plugin.Symbol, 0)} - for _, name := range plugins { - sym, err := pl.Compile(name, common.K8sBenchAuditResultHook) + pl := uplugin.NewPluginLoader(sourceFolder, compliledFolder) + names, err := pl.Plugins(uplugin.CompiledExt) + if err != nil { + panic(fmt.Sprintf("failed to get plugin compiled plugins %s", err.Error())) + } + apiPlugin := hook.K8sBenchAuditResultHook{Plugins: make([]plugin.Symbol, 0), Plug: pl} + for _, name := range names { + sym, err := pl.Load(name, common.K8sBenchAuditResultHook) if err != nil { + log.Error(fmt.Sprintf("failed to load sym %s error %s", name, err.Error())) continue } apiPlugin.Plugins = append(apiPlugin.Plugins, sym) @@ -113,8 +121,8 @@ func initPluginWorker(plChan chan models.KubeAuditResults, completedChan chan bo panic(err) } k8sHooks := loadAuditBenchPluginSymbols(log) - pluginData := bplugin.NewPluginWorkerData(plChan, k8sHooks, completedChan) - worker := bplugin.NewPluginWorker(pluginData, log) + pluginData := hook.NewPluginWorkerData(plChan, k8sHooks, completedChan) + worker := hook.NewPluginWorker(pluginData, log) worker.Invoke() } diff --git a/internal/bplugin/worker.go b/internal/hook/worker.go similarity index 80% rename from internal/bplugin/worker.go rename to internal/hook/worker.go index 41f6d9f..3f3115c 100644 --- a/internal/bplugin/worker.go +++ b/internal/hook/worker.go @@ -1,11 +1,19 @@ -package bplugin +package hook import ( "fmt" "github.com/chen-keinan/beacon/pkg/models" + "github.com/chen-keinan/go-user-plugins/uplugin" "go.uber.org/zap" + "plugin" ) +//K8sBenchAuditResultHook hold the plugin symbol for K8s bench audit result Hook +type K8sBenchAuditResultHook struct { + Plugins []plugin.Symbol + Plug *uplugin.PluginLoader +} + //PluginWorker instance which match command data to specific pattern type PluginWorker struct { cmd *PluginWorkerData @@ -35,7 +43,7 @@ func (pm *PluginWorker) Invoke() { ae := <-pm.cmd.plChan if len(pm.cmd.plugins.Plugins) > 0 { for _, pl := range pm.cmd.plugins.Plugins { - err := ExecuteK8sAuditResults(pl, ae) + _, err := pm.cmd.plugins.Plug.Invoke(pl, ae) if err != nil { pm.log.Error(fmt.Sprintf("failed to execute plugins %s", err.Error())) } diff --git a/internal/bplugin/worker_test.go b/internal/hook/worker_test.go similarity index 96% rename from internal/bplugin/worker_test.go rename to internal/hook/worker_test.go index ca3b6bb..e012ee7 100644 --- a/internal/bplugin/worker_test.go +++ b/internal/hook/worker_test.go @@ -1,4 +1,4 @@ -package bplugin +package hook import ( m2 "github.com/chen-keinan/beacon/pkg/models" @@ -14,5 +14,4 @@ func Test_NewPluginWorker(t *testing.T) { plChan := make(chan m2.KubeAuditResults) pw := NewPluginWorker(NewPluginWorkerData(plChan, K8sBenchAuditResultHook{}, completedChan), production) assert.True(t, len(pw.cmd.plugins.Plugins) == 0) - }