mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[DebugPackage] Add Agency Dump & State (#1230)
This commit is contained in:
parent
4871fb09fc
commit
1992298afc
18 changed files with 880 additions and 134 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
|
||||
- (Bugfix) Fix deployment creation on ARM64
|
||||
- (DebugPackage) Add Agency Dump & State
|
||||
|
||||
## [1.2.23](https://github.com/arangodb/kube-arangodb/tree/1.2.23) (2023-01-12)
|
||||
- (Bugfix) Remove PDBs if group count is 0
|
||||
|
|
24
go.mod
24
go.mod
|
@ -30,7 +30,7 @@ require (
|
|||
github.com/arangodb/go-upgrade-rules v0.0.0-20180809110947-031b4774ff21
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible
|
||||
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
|
||||
github.com/gin-gonic/gin v1.7.2
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible
|
||||
github.com/jessevdk/go-assets v0.0.0-20160921144138-4f4301a06e15
|
||||
github.com/josephburnett/jd v1.6.1
|
||||
|
@ -45,9 +45,9 @@ require (
|
|||
github.com/rs/zerolog v1.19.0
|
||||
github.com/spf13/cobra v1.2.1
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/stretchr/testify v1.7.1
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069
|
||||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
|
||||
google.golang.org/grpc v1.47.0
|
||||
google.golang.org/protobuf v1.28.0
|
||||
|
@ -67,13 +67,15 @@ require (
|
|||
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/evanphx/json-patch v4.11.0+incompatible // indirect
|
||||
github.com/gin-contrib/pprof v1.4.0 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-logr/logr v0.4.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
github.com/go-openapi/swag v0.21.1 // indirect
|
||||
github.com/go-playground/locales v0.13.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.17.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.8.0 // indirect
|
||||
github.com/go-playground/locales v0.14.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.10.0 // indirect
|
||||
github.com/goccy/go-json v0.9.7 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
|
@ -84,19 +86,21 @@ require (
|
|||
github.com/imdario/mergo v0.3.5 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.11 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
|
||||
github.com/moby/spdystream v0.2.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pavel-v-chernykh/keystore-go v2.1.0+incompatible // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/common v0.26.0 // indirect
|
||||
github.com/prometheus/procfs v0.6.0 // indirect
|
||||
github.com/stretchr/objx v0.2.0 // indirect
|
||||
github.com/ugorji/go/codec v1.2.6 // indirect
|
||||
github.com/ugorji/go/codec v1.2.7 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
|
||||
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect
|
||||
|
|
33
go.sum
33
go.sum
|
@ -152,10 +152,14 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
|
|||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/pprof v1.4.0 h1:XxiBSf5jWZ5i16lNOPbMTVdgHBdhfGRD5PZ1LWazzvg=
|
||||
github.com/gin-contrib/pprof v1.4.0/go.mod h1:RrehPJasUVBPK6yTUwOl8/NP6i0vbUgmxtis+Z5KE90=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.7.2 h1:Tg03T9yM2xa8j6I3Z3oqLaQRSmKvxPd6g/2HJ6zICFA=
|
||||
github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
|
||||
github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8=
|
||||
github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
|
@ -186,12 +190,20 @@ github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBY
|
|||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
|
||||
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
|
||||
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
|
||||
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-playground/validator/v10 v10.8.0 h1:1kAa0fCrnpv+QYdkdcRzrRM7AyYs5o8+jZdJCz9xj6k=
|
||||
github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk=
|
||||
github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0=
|
||||
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM=
|
||||
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
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=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
|
@ -325,6 +337,8 @@ github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
|
|||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
|
||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
|
@ -341,6 +355,8 @@ 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=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
|
@ -362,6 +378,8 @@ github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
|
|||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
|
||||
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||
|
@ -375,6 +393,7 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu
|
|||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8=
|
||||
github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c=
|
||||
github.com/moby/term v0.0.0-20210610120745-9d4ed1856297/go.mod h1:vgPCkQMyxTZ7IDy8SXRufE172gr8+K/JE/7hHFxHW3A=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
|
@ -383,6 +402,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
|
|||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
|
@ -407,8 +428,12 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI
|
|||
github.com/pavel-v-chernykh/keystore-go v2.1.0+incompatible h1:Jd6xfriVlJ6hWPvYOE0Ni0QWcNTLRehfGPFxr3eSL80=
|
||||
github.com/pavel-v-chernykh/keystore-go v2.1.0+incompatible/go.mod h1:xlUlxe/2ItGlQyMTstqeDv9r3U4obH7xYd26TbDQutY=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ=
|
||||
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||
github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU=
|
||||
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
|
||||
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
|
@ -451,6 +476,8 @@ github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfm
|
|||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/zerolog v1.19.0 h1:hYz4ZVdUgjXTBUmrkrw55j1nHx68LfOKIQk5IYtyScg=
|
||||
github.com/rs/zerolog v1.19.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo=
|
||||
|
@ -498,6 +525,8 @@ github.com/ugorji/go v0.0.0-20181209151446-772ced7fd4c2/go.mod h1:hnLbHMwcvSihnD
|
|||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ=
|
||||
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
|
||||
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
|
||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
|
@ -722,6 +751,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 h1:siQdpVirKtzPhKl3lZWozZraCFObP8S1v6PRp0bLrtU=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
|
||||
|
@ -923,6 +954,8 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
|
|||
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/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -39,11 +39,13 @@ var rootFactories = []shared.Factory{
|
|||
kubernetes.Events(),
|
||||
kubernetes.Pods(),
|
||||
kubernetes.Secrets(),
|
||||
kubernetes.Services(),
|
||||
kubernetes.Deployments(),
|
||||
kubernetes.AgencyDump(),
|
||||
}
|
||||
|
||||
func InitCommand(cmd *cobra.Command) {
|
||||
cli.Register(cmd)
|
||||
|
||||
f := cmd.Flags()
|
||||
|
||||
for _, factory := range rootFactories {
|
||||
|
|
162
pkg/debug_package/generators/kubernetes/agency.go
Normal file
162
pkg/debug_package/generators/kubernetes/agency.go
Normal file
|
@ -0,0 +1,162 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/shared"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||
)
|
||||
|
||||
const LocalBinDir = "/usr/bin/arangodb_operator"
|
||||
|
||||
func AgencyDump() shared.Factory {
|
||||
return shared.NewFactory("agency-dump", true, agencyDump)
|
||||
}
|
||||
|
||||
func agencyDump(logger zerolog.Logger, files chan<- shared.File) error {
|
||||
ef, err := discoverExecFunc()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
k, ok := kclient.GetDefaultFactory().Client()
|
||||
if !ok {
|
||||
return errors.Newf("Client is not initialised")
|
||||
}
|
||||
|
||||
deployments, err := ListDeployments(k)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, deployment := range deployments {
|
||||
if !deployment.Spec.Mode.HasAgents() {
|
||||
continue
|
||||
}
|
||||
|
||||
NewDeploymentAgencyInfo(files, deployment.GetName(), ef)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewDeploymentAgencyInfo(out chan<- shared.File, name string, handler ArangoOperatorExecFunc) {
|
||||
out <- shared.NewFile(fmt.Sprintf("kubernetes/arango/deployments/%s/agency/dump.json", name), func() ([]byte, error) {
|
||||
out, _, err := handler("admin", "agency", "dump", "-d", name)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return out, nil
|
||||
})
|
||||
|
||||
out <- shared.NewFile(fmt.Sprintf("kubernetes/arango/deployments/%s/agency/state.json", name), func() ([]byte, error) {
|
||||
out, _, err := handler("admin", "agency", "state", "-d", name)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return out, nil
|
||||
})
|
||||
}
|
||||
|
||||
type ArangoOperatorExecFunc func(args ...string) ([]byte, []byte, error)
|
||||
|
||||
func discoverExecFunc() (ArangoOperatorExecFunc, error) {
|
||||
if _, err := os.Stat(LocalBinDir); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k, ok := kclient.GetDefaultFactory().Client()
|
||||
if !ok {
|
||||
return nil, errors.Newf("Client is not initialised")
|
||||
}
|
||||
|
||||
pods, err := ListPods(k)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var id string
|
||||
|
||||
for _, v := range pods {
|
||||
if id != "" {
|
||||
break
|
||||
}
|
||||
|
||||
for _, container := range v.Spec.Containers {
|
||||
if container.Name != "operator" {
|
||||
continue
|
||||
}
|
||||
|
||||
var stderr, stdout bytes.Buffer
|
||||
|
||||
if err := shared.ExecuteCommandInPod(k, "operator", v.GetName(), v.GetNamespace(), []string{LocalBinDir, "version"}, nil, &stdout, &stderr); err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
id = v.GetName()
|
||||
}
|
||||
}
|
||||
|
||||
if id == "" {
|
||||
return nil, errors.Newf("Unable to find Operator pod")
|
||||
}
|
||||
|
||||
return func(args ...string) ([]byte, []byte, error) {
|
||||
var stderr, stdout bytes.Buffer
|
||||
|
||||
in := make([]string, len(args)+1)
|
||||
in[0] = LocalBinDir
|
||||
for id := range args {
|
||||
in[id+1] = args[id]
|
||||
}
|
||||
|
||||
err := shared.ExecuteCommandInPod(k, "operator", id, cli.GetInput().Namespace, in, nil, &stdout, &stderr)
|
||||
|
||||
return stdout.Bytes(), stderr.Bytes(), err
|
||||
}, nil
|
||||
} else {
|
||||
return func(args ...string) ([]byte, []byte, error) {
|
||||
cmd := exec.Command(LocalBinDir, args...)
|
||||
var stderr, stdout bytes.Buffer
|
||||
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
|
||||
err := cmd.Run()
|
||||
|
||||
return stdout.Bytes(), stderr.Bytes(), err
|
||||
}, nil
|
||||
}
|
||||
}
|
94
pkg/debug_package/generators/kubernetes/deployments.go
Normal file
94
pkg/debug_package/generators/kubernetes/deployments.go
Normal file
|
@ -0,0 +1,94 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/shared"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||
)
|
||||
|
||||
func Deployments() shared.Factory {
|
||||
return shared.NewFactory("deployments", true, deployments)
|
||||
}
|
||||
|
||||
func deployments(logger zerolog.Logger, files chan<- shared.File) error {
|
||||
k, ok := kclient.GetDefaultFactory().Client()
|
||||
if !ok {
|
||||
return errors.Newf("Client is not initialised")
|
||||
}
|
||||
|
||||
deployments, err := ListDeployments(k)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
deploymentList := deployments.AsList()
|
||||
|
||||
errDeployments := make([]error, len(deployments))
|
||||
|
||||
for id := range deploymentList {
|
||||
errDeployments[id] = deployment(k, deploymentList[id], files)
|
||||
}
|
||||
|
||||
if err := errors.Errors(errDeployments...); err != nil {
|
||||
logger.Err(err).Msgf("Error while collecting arango deployments")
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func deployment(client kclient.Client, depl *api.ArangoDeployment, files chan<- shared.File) error {
|
||||
files <- shared.NewYAMLFile(fmt.Sprintf("kubernetes/arango/deployments/%s.yaml", depl.GetName()), func() ([]interface{}, error) {
|
||||
return []interface{}{depl}, nil
|
||||
})
|
||||
|
||||
if err := deploymentMembers(client, depl, files); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func deploymentMembers(client kclient.Client, depl *api.ArangoDeployment, files chan<- shared.File) error {
|
||||
for _, member := range depl.Status.Members.AsList() {
|
||||
mName := member.Member.ArangoMemberName(depl.GetName(), member.Group)
|
||||
|
||||
arangoMember, err := client.Arango().DatabaseV1().ArangoMembers(cli.GetInput().Namespace).Get(context.Background(), mName, meta.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
files <- shared.NewYAMLFile(fmt.Sprintf("kubernetes/arango/deployments/%s/members/%s.yaml", depl.GetName(), arangoMember.GetName()), func() ([]interface{}, error) {
|
||||
return []interface{}{arangoMember}, nil
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -21,14 +21,8 @@
|
|||
package kubernetes
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
eventsv1 "k8s.io/api/events/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/shared"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||
|
@ -44,29 +38,13 @@ func events(logger zerolog.Logger, files chan<- shared.File) error {
|
|||
return errors.Newf("Client is not initialised")
|
||||
}
|
||||
|
||||
events := map[types.UID]*eventsv1.Event{}
|
||||
next := ""
|
||||
for {
|
||||
r, err := k.Kubernetes().EventsV1().Events(cli.GetInput().Namespace).List(context.Background(), meta.ListOptions{
|
||||
Continue: next,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, e := range r.Items {
|
||||
events[e.UID] = e.DeepCopy()
|
||||
}
|
||||
|
||||
next = r.Continue
|
||||
if next == "" {
|
||||
break
|
||||
}
|
||||
events, err := ListEvents(k)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
files <- shared.NewJSONFile("kubernetes/events.json", func() (interface{}, error) {
|
||||
q := make([]*eventsv1.Event, 0, len(events))
|
||||
files <- shared.NewYAMLFile("kubernetes/events.yaml", func() ([]interface{}, error) {
|
||||
q := make([]interface{}, 0, len(events))
|
||||
|
||||
for _, e := range events {
|
||||
q = append(q, e)
|
||||
|
|
70
pkg/debug_package/generators/kubernetes/lister_deployment.go
Normal file
70
pkg/debug_package/generators/kubernetes/lister_deployment.go
Normal file
|
@ -0,0 +1,70 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||
)
|
||||
|
||||
type DeploymentList map[types.UID]*api.ArangoDeployment
|
||||
|
||||
func (d DeploymentList) AsList() []*api.ArangoDeployment {
|
||||
deploymentList := make([]*api.ArangoDeployment, 0, len(d))
|
||||
for _, p := range d {
|
||||
deploymentList = append(deploymentList, p)
|
||||
}
|
||||
|
||||
return deploymentList
|
||||
}
|
||||
|
||||
func ListDeployments(k kclient.Client) (DeploymentList, error) {
|
||||
deployments := DeploymentList{}
|
||||
next := ""
|
||||
|
||||
for {
|
||||
deps, err := k.Arango().DatabaseV1().ArangoDeployments(cli.GetInput().Namespace).List(context.Background(), meta.ListOptions{
|
||||
Continue: next,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, d := range deps.Items {
|
||||
deployments[d.UID] = d.DeepCopy()
|
||||
deployments[d.UID].ManagedFields = nil
|
||||
}
|
||||
|
||||
if deps.Continue == "" {
|
||||
break
|
||||
}
|
||||
|
||||
next = deps.Continue
|
||||
}
|
||||
|
||||
return deployments, nil
|
||||
}
|
70
pkg/debug_package/generators/kubernetes/lister_events.go
Normal file
70
pkg/debug_package/generators/kubernetes/lister_events.go
Normal file
|
@ -0,0 +1,70 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
core "k8s.io/api/core/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||
)
|
||||
|
||||
type EventList map[types.UID]*core.Event
|
||||
|
||||
func (d EventList) AsList() []*core.Event {
|
||||
eventList := make([]*core.Event, 0, len(d))
|
||||
for _, p := range d {
|
||||
eventList = append(eventList, p)
|
||||
}
|
||||
|
||||
return eventList
|
||||
}
|
||||
|
||||
func ListEvents(k kclient.Client) (EventList, error) {
|
||||
events := EventList{}
|
||||
next := ""
|
||||
|
||||
for {
|
||||
deps, err := k.Kubernetes().CoreV1().Events(cli.GetInput().Namespace).List(context.Background(), meta.ListOptions{
|
||||
Continue: next,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, d := range deps.Items {
|
||||
events[d.UID] = d.DeepCopy()
|
||||
events[d.UID].ManagedFields = nil
|
||||
}
|
||||
|
||||
if deps.Continue == "" {
|
||||
break
|
||||
}
|
||||
|
||||
next = deps.Continue
|
||||
}
|
||||
|
||||
return events, nil
|
||||
}
|
70
pkg/debug_package/generators/kubernetes/lister_pods.go
Normal file
70
pkg/debug_package/generators/kubernetes/lister_pods.go
Normal file
|
@ -0,0 +1,70 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
core "k8s.io/api/core/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||
)
|
||||
|
||||
type PodList map[types.UID]*core.Pod
|
||||
|
||||
func (d PodList) AsList() []*core.Pod {
|
||||
podList := make([]*core.Pod, 0, len(d))
|
||||
for _, p := range d {
|
||||
podList = append(podList, p)
|
||||
}
|
||||
|
||||
return podList
|
||||
}
|
||||
|
||||
func ListPods(k kclient.Client) (PodList, error) {
|
||||
pods := PodList{}
|
||||
next := ""
|
||||
|
||||
for {
|
||||
deps, err := k.Kubernetes().CoreV1().Pods(cli.GetInput().Namespace).List(context.Background(), meta.ListOptions{
|
||||
Continue: next,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, d := range deps.Items {
|
||||
pods[d.UID] = d.DeepCopy()
|
||||
pods[d.UID].ManagedFields = nil
|
||||
}
|
||||
|
||||
if deps.Continue == "" {
|
||||
break
|
||||
}
|
||||
|
||||
next = deps.Continue
|
||||
}
|
||||
|
||||
return pods, nil
|
||||
}
|
70
pkg/debug_package/generators/kubernetes/lister_secrets.go
Normal file
70
pkg/debug_package/generators/kubernetes/lister_secrets.go
Normal file
|
@ -0,0 +1,70 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
core "k8s.io/api/core/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||
)
|
||||
|
||||
type SecretList map[types.UID]*core.Secret
|
||||
|
||||
func (d SecretList) AsList() []*core.Secret {
|
||||
secretList := make([]*core.Secret, 0, len(d))
|
||||
for _, p := range d {
|
||||
secretList = append(secretList, p)
|
||||
}
|
||||
|
||||
return secretList
|
||||
}
|
||||
|
||||
func ListSecrets(k kclient.Client) (SecretList, error) {
|
||||
secrets := SecretList{}
|
||||
next := ""
|
||||
|
||||
for {
|
||||
deps, err := k.Kubernetes().CoreV1().Secrets(cli.GetInput().Namespace).List(context.Background(), meta.ListOptions{
|
||||
Continue: next,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, d := range deps.Items {
|
||||
secrets[d.UID] = d.DeepCopy()
|
||||
secrets[d.UID].ManagedFields = nil
|
||||
}
|
||||
|
||||
if deps.Continue == "" {
|
||||
break
|
||||
}
|
||||
|
||||
next = deps.Continue
|
||||
}
|
||||
|
||||
return secrets, nil
|
||||
}
|
70
pkg/debug_package/generators/kubernetes/lister_services.go
Normal file
70
pkg/debug_package/generators/kubernetes/lister_services.go
Normal file
|
@ -0,0 +1,70 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
core "k8s.io/api/core/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||
)
|
||||
|
||||
type ServiceList map[types.UID]*core.Service
|
||||
|
||||
func (d ServiceList) AsList() []*core.Service {
|
||||
serviceList := make([]*core.Service, 0, len(d))
|
||||
for _, p := range d {
|
||||
serviceList = append(serviceList, p)
|
||||
}
|
||||
|
||||
return serviceList
|
||||
}
|
||||
|
||||
func ListServices(k kclient.Client) (ServiceList, error) {
|
||||
services := ServiceList{}
|
||||
next := ""
|
||||
|
||||
for {
|
||||
deps, err := k.Kubernetes().CoreV1().Services(cli.GetInput().Namespace).List(context.Background(), meta.ListOptions{
|
||||
Continue: next,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, d := range deps.Items {
|
||||
services[d.UID] = d.DeepCopy()
|
||||
services[d.UID].ManagedFields = nil
|
||||
}
|
||||
|
||||
if deps.Continue == "" {
|
||||
break
|
||||
}
|
||||
|
||||
next = deps.Continue
|
||||
}
|
||||
|
||||
return services, nil
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package kubernetes
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -27,8 +27,6 @@ import (
|
|||
|
||||
"github.com/rs/zerolog"
|
||||
core "k8s.io/api/core/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/shared"
|
||||
|
@ -46,38 +44,18 @@ func pods(logger zerolog.Logger, files chan<- shared.File) error {
|
|||
return errors.Newf("Client is not initialised")
|
||||
}
|
||||
|
||||
pods := map[types.UID]*core.Pod{}
|
||||
next := ""
|
||||
for {
|
||||
r, err := k.Kubernetes().CoreV1().Pods(cli.GetInput().Namespace).List(context.Background(), meta.ListOptions{
|
||||
Continue: next,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, e := range r.Items {
|
||||
pods[e.UID] = e.DeepCopy()
|
||||
}
|
||||
|
||||
next = r.Continue
|
||||
if next == "" {
|
||||
break
|
||||
}
|
||||
pods, err := ListPods(k)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
podsList := make([]*core.Pod, 0, len(pods))
|
||||
podsList := pods.AsList()
|
||||
|
||||
for _, p := range pods {
|
||||
podsList = append(podsList, p)
|
||||
}
|
||||
files <- shared.NewYAMLFile("kubernetes/pods.yaml", func() ([]interface{}, error) {
|
||||
q := make([]interface{}, len(podsList))
|
||||
|
||||
files <- shared.NewJSONFile("kubernetes/pods.json", func() (interface{}, error) {
|
||||
q := make([]*core.Pod, 0, len(pods))
|
||||
|
||||
for _, e := range pods {
|
||||
q = append(q, e)
|
||||
for id := range podsList {
|
||||
q[id] = podsList[id]
|
||||
}
|
||||
|
||||
return q, nil
|
||||
|
@ -103,6 +81,8 @@ func podsLogs(client kclient.Client, files chan<- shared.File, pods ...*core.Pod
|
|||
}
|
||||
|
||||
func podLogs(client kclient.Client, files chan<- shared.File, pod *core.Pod) error {
|
||||
podYaml(files, pod)
|
||||
|
||||
errs := make([]error, 0, len(pod.Status.ContainerStatuses)+len(pod.Status.InitContainerStatuses)+len(pod.Status.EphemeralContainerStatuses))
|
||||
|
||||
if s := pod.Status.ContainerStatuses; len(s) > 0 {
|
||||
|
@ -138,6 +118,12 @@ func podLogs(client kclient.Client, files chan<- shared.File, pod *core.Pod) err
|
|||
return errors.Errors(errs...)
|
||||
}
|
||||
|
||||
func podYaml(files chan<- shared.File, pod *core.Pod) {
|
||||
files <- shared.NewYAMLFile(fmt.Sprintf("kubernetes/pods/%s/pod.yaml", pod.GetName()), func() ([]interface{}, error) {
|
||||
return []interface{}{pod}, nil
|
||||
})
|
||||
}
|
||||
|
||||
func podContainerLogs(client kclient.Client, files chan<- shared.File, pod *core.Pod, container string) error {
|
||||
res := client.Kubernetes().CoreV1().Pods(pod.GetNamespace()).GetLogs(pod.GetName(), &core.PodLogOptions{
|
||||
Container: container,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -21,16 +21,8 @@
|
|||
package kubernetes
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
core "k8s.io/api/core/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/shared"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||
|
@ -46,38 +38,13 @@ func secrets(logger zerolog.Logger, files chan<- shared.File) error {
|
|||
return errors.Newf("Client is not initialised")
|
||||
}
|
||||
|
||||
secrets := map[types.UID]*core.Secret{}
|
||||
next := ""
|
||||
for {
|
||||
r, err := k.Kubernetes().CoreV1().Secrets(cli.GetInput().Namespace).List(context.Background(), meta.ListOptions{
|
||||
Continue: next,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, e := range r.Items {
|
||||
hashed := make(map[string][]byte, len(e.Data))
|
||||
for k, v := range e.Data {
|
||||
if cli.GetInput().HideSensitiveData {
|
||||
hashed[k] = []byte(fmt.Sprintf("%02x", sha256.Sum256(v)))
|
||||
} else {
|
||||
hashed[k] = v
|
||||
}
|
||||
}
|
||||
secrets[e.UID] = e.DeepCopy()
|
||||
secrets[e.UID].Data = hashed
|
||||
}
|
||||
|
||||
next = r.Continue
|
||||
if next == "" {
|
||||
break
|
||||
}
|
||||
secrets, err := ListSecrets(k)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
files <- shared.NewJSONFile("kubernetes/secrets.json", func() (interface{}, error) {
|
||||
q := make([]*core.Secret, 0, len(secrets))
|
||||
files <- shared.NewYAMLFile("kubernetes/secrets.yaml", func() ([]interface{}, error) {
|
||||
q := make([]interface{}, 0, len(secrets))
|
||||
|
||||
for _, e := range secrets {
|
||||
q = append(q, e)
|
||||
|
|
76
pkg/debug_package/generators/kubernetes/services.go
Normal file
76
pkg/debug_package/generators/kubernetes/services.go
Normal file
|
@ -0,0 +1,76 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/debug_package/shared"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||
)
|
||||
|
||||
func Services() shared.Factory {
|
||||
return shared.NewFactory("kubernetes-services", true, services)
|
||||
}
|
||||
|
||||
func services(logger zerolog.Logger, files chan<- shared.File) error {
|
||||
k, ok := kclient.GetDefaultFactory().Client()
|
||||
if !ok {
|
||||
return errors.Newf("Client is not initialised")
|
||||
}
|
||||
|
||||
services, err := ListServices(k)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
files <- shared.NewYAMLFile("kubernetes/services.yaml", func() ([]interface{}, error) {
|
||||
q := make([]interface{}, 0, len(services))
|
||||
|
||||
for _, e := range services {
|
||||
q = append(q, e)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
})
|
||||
|
||||
for _, svc := range services {
|
||||
endpoints(k, svc.GetNamespace(), svc.GetName(), files)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func endpoints(k kclient.Client, namespace, name string, files chan<- shared.File) {
|
||||
ep, err := k.Kubernetes().CoreV1().Endpoints(namespace).Get(context.Background(), name, meta.GetOptions{})
|
||||
if err == nil {
|
||||
files <- shared.NewYAMLFile(fmt.Sprintf("kubernetes/services/%s/endpoints.yaml", name), func() ([]interface{}, error) {
|
||||
ep.ManagedFields = nil
|
||||
|
||||
return []interface{}{ep}, nil
|
||||
})
|
||||
}
|
||||
}
|
64
pkg/debug_package/shared/exec.go
Normal file
64
pkg/debug_package/shared/exec.go
Normal file
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package shared
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
core "k8s.io/api/core/v1"
|
||||
scheme2 "k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/tools/remotecommand"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||
)
|
||||
|
||||
// ExecuteCommandInPod executes command in pod with the given pod name and namespace.
|
||||
func ExecuteCommandInPod(k kclient.Client, container, podName, namespace string,
|
||||
command []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
|
||||
|
||||
req := k.Kubernetes().CoreV1().RESTClient().Post().Resource("pods").Name(podName).
|
||||
Namespace(namespace).SubResource("exec")
|
||||
|
||||
option := &core.PodExecOptions{
|
||||
Command: command,
|
||||
Container: container,
|
||||
Stdin: stdin != nil,
|
||||
Stdout: true,
|
||||
Stderr: stderr != nil,
|
||||
TTY: false,
|
||||
}
|
||||
|
||||
req.VersionedParams(
|
||||
option,
|
||||
scheme2.ParameterCodec,
|
||||
)
|
||||
|
||||
exec, err := remotecommand.NewSPDYExecutor(k.Config(), "POST", req.URL())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return exec.Stream(remotecommand.StreamOptions{
|
||||
Stdin: stdin,
|
||||
Stdout: stdout,
|
||||
Stderr: stderr,
|
||||
})
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -21,8 +21,12 @@
|
|||
package shared
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
type GenFunc func(logger zerolog.Logger, files chan<- File) error
|
||||
|
@ -32,17 +36,63 @@ type File interface {
|
|||
Write() ([]byte, error)
|
||||
}
|
||||
|
||||
func NewJSONFile(path string, write func() (interface{}, error)) File {
|
||||
func NewJSONFile(path string, write func() ([]interface{}, error)) File {
|
||||
return NewFile(path, func() ([]byte, error) {
|
||||
obj, err := write()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for z := range obj {
|
||||
obj[z] = cleanObject(&obj[z])
|
||||
}
|
||||
|
||||
return json.Marshal(obj)
|
||||
})
|
||||
}
|
||||
|
||||
func cleanObject(obj interface{}) interface{} {
|
||||
if obj == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if v, ok := obj.(meta.Object); ok {
|
||||
v.SetManagedFields(nil)
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
func NewYAMLFile(path string, write func() ([]interface{}, error)) File {
|
||||
return NewFile(path, func() ([]byte, error) {
|
||||
obj, err := write()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
buff := bytes.NewBuffer(nil)
|
||||
|
||||
for z := range obj {
|
||||
obj[z] = cleanObject(&obj[z])
|
||||
}
|
||||
|
||||
for z := range obj {
|
||||
d, err := yaml.Marshal(obj[z])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
buff.Write(d)
|
||||
|
||||
if z+1 < len(obj) {
|
||||
buff.Write([]byte("\n---\n\n"))
|
||||
}
|
||||
}
|
||||
|
||||
return buff.Bytes(), nil
|
||||
})
|
||||
}
|
||||
|
||||
func NewFile(path string, write func() ([]byte, error)) File {
|
||||
return file{
|
||||
name: path,
|
||||
|
|
Loading…
Reference in a new issue