From 891fb5ebc428c163c8acb7f02248068f808d48b9 Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Mon, 10 Jun 2024 15:44:12 +0200 Subject: [PATCH 01/12] chore: Bump axiom-go to v0.18.1 --- go.mod | 22 ++++++++++----------- go.sum | 60 +++++++++++++++++++++++++++++----------------------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/go.mod b/go.mod index 4a4696e..3dbab2e 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/MakeNowJust/heredoc v1.0.0 github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de - github.com/axiomhq/axiom-go v0.17.8 + github.com/axiomhq/axiom-go v0.18.1 github.com/axiomhq/pkg v0.6.0 github.com/briandowns/spinner v1.23.0 github.com/cli/cli v1.14.0 @@ -192,7 +192,7 @@ require ( github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-git/go-git/v5 v5.12.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/analysis v0.23.0 // indirect github.com/go-openapi/errors v0.22.0 // indirect @@ -421,11 +421,11 @@ require ( go.mongodb.org/mongo-driver v1.14.0 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.51.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect - go.opentelemetry.io/otel v1.26.0 // indirect - go.opentelemetry.io/otel/metric v1.26.0 // indirect - go.opentelemetry.io/otel/trace v1.26.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.52.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect + go.opentelemetry.io/otel v1.27.0 // indirect + go.opentelemetry.io/otel/metric v1.27.0 // indirect + go.opentelemetry.io/otel/trace v1.27.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/automaxprocs v1.5.3 // indirect go.uber.org/multierr v1.11.0 // indirect @@ -442,10 +442,10 @@ require ( golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect google.golang.org/api v0.172.0 // indirect google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect - google.golang.org/grpc v1.63.2 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/grpc v1.64.0 // indirect + google.golang.org/protobuf v1.34.1 // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index fde9438..01dcffa 100644 --- a/go.sum +++ b/go.sum @@ -249,8 +249,8 @@ github.com/aws/smithy-go v1.20.2 h1:tbp628ireGtzcHDDmLT/6ADHidqnwgF57XOXZe6tp4Q= github.com/aws/smithy-go v1.20.2/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20240514230400-03fa26f5508f h1:Z0kS9pJDQgCg3u2lH6+CdYaFbyQtyukVTiUCG6re0E4= github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20240514230400-03fa26f5508f/go.mod h1:rAE739ssmE5O5fLuQ2y8uHdmOJaelE5I0Es3SxV0y1A= -github.com/axiomhq/axiom-go v0.17.8 h1:QAAAs3aKXGGGU6n+usAdk/uKSLKy2+RKGD0iKzAb80k= -github.com/axiomhq/axiom-go v0.17.8/go.mod h1:N5n4fVnM1Qob33jnrLV+mE1MtuJHzci5GJjxLKiLK00= +github.com/axiomhq/axiom-go v0.18.1 h1:dKZlrc5/ZE5kdgEw1KO1XS2SuxLK2deNXlFarso8jp4= +github.com/axiomhq/axiom-go v0.18.1/go.mod h1:RjXKMe8Nib95qkaaPAR+7gIV60EdVitTfl40wIVdj/c= github.com/axiomhq/pkg v0.6.0 h1:elslidLCtDB+GPOx+1VzXijf+BT28+HnPUir8vSaEkA= github.com/axiomhq/pkg v0.6.0/go.mod h1:0Vu7mQOXdsxpYYyGIm5QfHwafGboyyyoz8FIhSvA30M= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -489,8 +489,8 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9 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= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-openapi/analysis v0.23.0 h1:aGday7OWupfMs+LbmLZG4k0MYXIANxcuBTYUC03zFCU= @@ -715,8 +715,8 @@ github.com/gostaticanalysis/testutil v0.4.0 h1:nhdCmubdmDF6VEatUNjgUZBJKWRqugoIS github.com/gostaticanalysis/testutil v0.4.0/go.mod h1:bLIoPefWXrRi/ssLFWX1dx7Repi5x3CuviD3dgAZaBU= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -1317,22 +1317,22 @@ go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= -go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.51.0 h1:974XTyIwHI4nHa1+uSLxHtUnlJ2DiVtAJjk7fd07p/8= -go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.51.0/go.mod h1:ZvX/taFlN6TGaOOM6D42wrNwPKUV1nGO2FuUXkityBU= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 h1:Xs2Ncz0gNihqu9iosIZ5SkBbWo5T8JhhLJFMQL1qmLI= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0/go.mod h1:vy+2G/6NvVMpwGX/NyLqcC41fxepnuKHk16E6IZUcJc= -go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= -go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 h1:1u/AyyOqAWzy+SkPxDpahCNZParHV8Vid1RnI2clyDE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0/go.mod h1:z46paqbJ9l7c9fIPCXTqTGwhQZ5XoTIsfeFYWboizjs= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0 h1:1wp/gyxsuYtuE/JFxsQRtcCDtMrO2qMvlfXALU5wkzI= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0/go.mod h1:gbTHmghkGgqxMomVQQMur1Nba4M0MQ8AYThXDUjsJ38= -go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30= -go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4= -go.opentelemetry.io/otel/sdk v1.26.0 h1:Y7bumHf5tAiDlRYFmGqetNcLaVUZmh4iYfmGxtmz7F8= -go.opentelemetry.io/otel/sdk v1.26.0/go.mod h1:0p8MXpqLeJ0pzcszQQN4F0S5FVjBLgypeGSngLsmirs= -go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= -go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= +go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.52.0 h1:Ud1trPqDHGSxyMiJ9a2XAdtTCXmRy0Yf7MjhW4dXogI= +go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.52.0/go.mod h1:l/UzmhdRx9YP37NI/nSr7l1bgG0dZnGfZf6C7TiV4jI= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 h1:9l89oX4ba9kHbBol3Xin3leYJ+252h0zszDtBwyKe2A= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0/go.mod h1:XLZfZboOJWHNKUv7eH0inh0E9VV6eWDFB/9yJyTLPp0= +go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= +go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 h1:R9DE4kQ4k+YtfLI2ULwX82VtNQ2J8yZmA7ZIF/D+7Mc= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0/go.mod h1:OQFyQVrDlbe+R7xrEyDr/2Wr67Ol0hRUgsfA+V5A95s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 h1:QY7/0NeRPKlzusf40ZE4t1VlMKbqSNT7cJRYzWuja0s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0/go.mod h1:HVkSiDhTM9BoUJU8qE6j2eSWLLXvi1USXjyd2BXT8PY= +go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik= +go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= +go.opentelemetry.io/otel/sdk v1.27.0 h1:mlk+/Y1gLPLn84U4tI8d3GNJmGT/eXe3ZuOXN9kTWmI= +go.opentelemetry.io/otel/sdk v1.27.0/go.mod h1:Ha9vbLwJE6W86YstIywK2xFfPjbWlCuwPtMkKdz/Y4A= +go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= +go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= go.opentelemetry.io/proto/otlp v1.2.0 h1:pVeZGk7nXDC9O2hncA6nHldxEjm6LByfA2aN8IOkz94= go.opentelemetry.io/proto/otlp v1.2.0/go.mod h1:gGpR8txAl5M03pDhMC79G6SdqNV26naRm/KDsgaHD8A= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1783,10 +1783,10 @@ google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaE google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 h1:ImUcDPHjTrAqNhlOkSocDLfG9rrNHH7w7uoKWPaWZ8s= google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7/go.mod h1:/3XmxOjePkvmKrHuBy4zNFw7IzxJXtAgdpXi8Ll990U= -google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 h1:oqta3O3AnlWbmIE3bFnWbu4bRxZjfbWCp0cKSuZh01E= -google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7/go.mod h1:VQW3tUculP/D4B+xVCo+VgSq8As6wA9ZjHl//pmk+6s= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1807,8 +1807,8 @@ google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= -google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1821,8 +1821,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 1ac08202a9d4f0e87355cef6819d177841c17c6b Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Mon, 10 Jun 2024 15:45:10 +0200 Subject: [PATCH 02/12] chore: Update trim call --- internal/cmd/dataset/dataset_trim.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/cmd/dataset/dataset_trim.go b/internal/cmd/dataset/dataset_trim.go index 1733b43..7636403 100644 --- a/internal/cmd/dataset/dataset_trim.go +++ b/internal/cmd/dataset/dataset_trim.go @@ -3,7 +3,6 @@ package dataset import ( "context" "fmt" - "strconv" "time" "github.com/AlecAivazis/survey/v2" @@ -132,7 +131,7 @@ func runTrim(ctx context.Context, opts *trimOptions) error { stop := opts.IO.StartActivityIndicator() defer stop() - res, err := client.Datasets.Trim(ctx, opts.Name, opts.Duration) + err = client.Datasets.Trim(ctx, opts.Name, opts.Duration) if err != nil { return err } @@ -141,8 +140,8 @@ func runTrim(ctx context.Context, opts *trimOptions) error { if opts.IO.IsStderrTTY() { cs := opts.IO.ColorScheme() - fmt.Fprintf(opts.IO.ErrOut(), "%s Trimmed dataset %s (dropped %s blocks)\n", - cs.SuccessIcon(), cs.Bold(opts.Name), cs.Bold(strconv.Itoa(res.BlocksDeleted))) + fmt.Fprintf(opts.IO.ErrOut(), "%s Trimmed dataset %s\n", + cs.SuccessIcon(), cs.Bold(opts.Name)) } return nil From dbc967b64b41d1564ea25915337c4a38778d8bea Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Mon, 10 Jun 2024 16:31:57 +0200 Subject: [PATCH 03/12] chore: Bump axiom-go to unreleased commit in branch https://github.com/axiomhq/axiom-go/pull/317 --- go.mod | 2 +- go.sum | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3dbab2e..5ae43db 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/MakeNowJust/heredoc v1.0.0 github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de - github.com/axiomhq/axiom-go v0.18.1 + github.com/axiomhq/axiom-go v0.18.2-0.20240611074313-84aa786e2394 github.com/axiomhq/pkg v0.6.0 github.com/briandowns/spinner v1.23.0 github.com/cli/cli v1.14.0 diff --git a/go.sum b/go.sum index 01dcffa..207cbec 100644 --- a/go.sum +++ b/go.sum @@ -251,6 +251,12 @@ github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20240514230400- github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20240514230400-03fa26f5508f/go.mod h1:rAE739ssmE5O5fLuQ2y8uHdmOJaelE5I0Es3SxV0y1A= github.com/axiomhq/axiom-go v0.18.1 h1:dKZlrc5/ZE5kdgEw1KO1XS2SuxLK2deNXlFarso8jp4= github.com/axiomhq/axiom-go v0.18.1/go.mod h1:RjXKMe8Nib95qkaaPAR+7gIV60EdVitTfl40wIVdj/c= +github.com/axiomhq/axiom-go v0.18.2-0.20240610132143-f784f1af85d5 h1:wR2i7KzXe4quBZWSm+A547sTs7MtnVN29bFJ5N8ZjmA= +github.com/axiomhq/axiom-go v0.18.2-0.20240610132143-f784f1af85d5/go.mod h1:RjXKMe8Nib95qkaaPAR+7gIV60EdVitTfl40wIVdj/c= +github.com/axiomhq/axiom-go v0.18.2-0.20240610151530-4a24251a0e46 h1:dEV3TwgtXr/po7Bmiv7mgI4LVwhDNLmz8wsbA0U8Bgs= +github.com/axiomhq/axiom-go v0.18.2-0.20240610151530-4a24251a0e46/go.mod h1:RjXKMe8Nib95qkaaPAR+7gIV60EdVitTfl40wIVdj/c= +github.com/axiomhq/axiom-go v0.18.2-0.20240611074313-84aa786e2394 h1:92jnb6DMs20sep8QttOBOF0IStKzuEztn+5lMXFVC2U= +github.com/axiomhq/axiom-go v0.18.2-0.20240611074313-84aa786e2394/go.mod h1:RjXKMe8Nib95qkaaPAR+7gIV60EdVitTfl40wIVdj/c= github.com/axiomhq/pkg v0.6.0 h1:elslidLCtDB+GPOx+1VzXijf+BT28+HnPUir8vSaEkA= github.com/axiomhq/pkg v0.6.0/go.mod h1:0Vu7mQOXdsxpYYyGIm5QfHwafGboyyyoz8FIhSvA30M= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= From 9f7bb847fabdc2247e041b1f3ab36fb0b5c928c8 Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Mon, 10 Jun 2024 16:29:20 +0200 Subject: [PATCH 04/12] feat: Add annotation create cmd --- internal/cmd/annotation/annotation.go | 70 +++++++ internal/cmd/annotation/annotation_create.go | 187 +++++++++++++++++++ internal/cmd/root/root.go | 2 + 3 files changed, 259 insertions(+) create mode 100644 internal/cmd/annotation/annotation.go create mode 100644 internal/cmd/annotation/annotation_create.go diff --git a/internal/cmd/annotation/annotation.go b/internal/cmd/annotation/annotation.go new file mode 100644 index 0000000..93174a2 --- /dev/null +++ b/internal/cmd/annotation/annotation.go @@ -0,0 +1,70 @@ +package annotation + +import ( + "context" + "sort" + + "github.com/MakeNowJust/heredoc" + "github.com/spf13/cobra" + + "github.com/axiomhq/cli/internal/cmd/auth" + "github.com/axiomhq/cli/internal/cmdutil" +) + +// NewCmd creates and returns the annotation command. +func NewCmd(f *cmdutil.Factory) *cobra.Command { + cmd := &cobra.Command{ + Use: "annotation ", + Short: "Manage annotations", + Long: "Manage annotations.", + + Example: heredoc.Doc(` + $ axiom annotation create --type=production-deployment --datasets=http-logs + $ axiom annotation list + $ axiom annotation update ann_123456789 --title="Production Deployment" + $ axiom annotation delete ann_123456789 + `), + + Annotations: map[string]string{ + "IsManagement": "true", + }, + + PersistentPreRunE: cmdutil.ChainRunFuncs( + cmdutil.AsksForSetup(f, auth.NewLoginCmd(f)), + cmdutil.NeedsActiveDeployment(f), + cmdutil.NeedsPersonalAccessToken(f), + ), + } + + cmd.AddCommand(newCreateCmd(f)) + // cmd.AddCommand(newDeleteCmd(f)) + // cmd.AddCommand(newListCmd(f)) + // cmd.AddCommand(newUpdateCmd(f)) + + return cmd +} + +func getDatasetNames(ctx context.Context, f *cmdutil.Factory) ([]string, error) { + client, err := f.Client(ctx) + if err != nil { + return nil, err + } + + stop := f.IO.StartActivityIndicator() + defer stop() + + datasets, err := client.Datasets.List(ctx) + if err != nil { + return nil, err + } + + stop() + + datasetNames := make([]string, len(datasets)) + for i, dataset := range datasets { + datasetNames[i] = dataset.Name + } + sort.Strings(datasetNames) + + return datasetNames, nil +} diff --git a/internal/cmd/annotation/annotation_create.go b/internal/cmd/annotation/annotation_create.go new file mode 100644 index 0000000..abbd086 --- /dev/null +++ b/internal/cmd/annotation/annotation_create.go @@ -0,0 +1,187 @@ +package annotation + +import ( + "context" + "fmt" + "regexp" + "time" + + "github.com/AlecAivazis/survey/v2" + "github.com/MakeNowJust/heredoc" + "github.com/axiomhq/axiom-go/axiom" + "github.com/spf13/cobra" + + "github.com/axiomhq/cli/internal/cmdutil" +) + +type createOptions struct { + *cmdutil.Factory + + // Type of the annotation to create. If not supplied as a flag, which is + // optional, the user will be asked for it. + Type string `survey:"type"` + // Datasets to attache the annotation to. If not supplied as a flag, which is + // optional, the user will be asked for it. + Datasets []string `survey:"datasets"` + + // Title of the annotation to create. + Title string `survey:"title"` + // Description of the annotation to create. + Description string `survey:"description"` + // URL of the annotation to create. + URL string `survey:"url"` + // Time of the annotation to create. + Time string `survey:"time"` + // EndTime of the annotation to create. + EndTime string `survey:"end-time"` +} + +func newCreateCmd(f *cmdutil.Factory) *cobra.Command { + opts := &createOptions{ + Factory: f, + } + + cmd := &cobra.Command{ + Use: "create (-t|--type) (-d|--datasets) [(-T|--title) ] [(-D|--description) <description>] [(-U|--url) <url>] [(--time) <time>] [(--end-time) <endTime>", + Short: "Create an annotation", + + Aliases: []string{"new"}, + + DisableFlagsInUseLine: true, + + Example: heredoc.Doc(` + # Interactively create an annotation + $ axiom annotation create + + # Create an annotation and provide the parameters on the command-line: + $ axiom annotation create --type=deploy --datasets=http-logs + `), + + RunE: func(cmd *cobra.Command, _ []string) error { + if err := completeCreate(cmd.Context(), opts); err != nil { + return err + } + return runCreate(cmd.Context(), opts) + }, + } + + cmd.Flags().StringVarP(&opts.Type, "type", "t", "", "Type of the annotation (must be lowercase alphanumeric and hyphens)") + cmd.Flags().StringArrayVarP(&opts.Datasets, "datasets", "d", nil, "Datasets to attach the annotation to") + cmd.Flags().StringVarP(&opts.Title, "title", "", "", "Title of the annotation") + cmd.Flags().StringVarP(&opts.Description, "description", "", "", "Description of the annotation") + cmd.Flags().StringVarP(&opts.URL, "url", "u", "", "URL of the annotation") + cmd.Flags().StringVarP(&opts.Time, "time", "", "", "Time of the annotation") + cmd.Flags().StringVarP(&opts.EndTime, "end-time", "", "", "End time of the annotation") + + _ = cmd.RegisterFlagCompletionFunc("type", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("datasets", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("title", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("description", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("url", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("time", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("end-time", cmdutil.NoCompletion) + + if !opts.IO.IsStdinTTY() { + _ = cmd.MarkFlagRequired("type") + _ = cmd.MarkFlagRequired("datasets") + } + + return cmd +} + +func completeCreate(ctx context.Context, opts *createOptions) error { + questions := make([]*survey.Question, 0, 2) + + datasetNames, err := getDatasetNames(ctx, opts.Factory) + if err != nil { + return err + } + + if len(opts.Datasets) == 0 { + questions = append(questions, &survey.Question{ + Name: "datasets", + Prompt: &survey.MultiSelect{ + Message: "Which datasets should this annotation be attached to?", + Options: datasetNames, + }, + Validate: survey.ComposeValidators( + survey.Required, + ), + }) + } + + if opts.Type == "" { + questions = append(questions, &survey.Question{ + Name: "type", + Prompt: &survey.Input{Message: "What is the type of the annotation?"}, + Validate: survey.ComposeValidators( + survey.Required, + validateType, + ), + }) + } + + return survey.Ask(questions, opts, opts.IO.SurveyIO()) +} + +var typeRegex = regexp.MustCompile(`^[a-z0-9-]+$`) + +func validateType(ans interface{}) error { + typ, ok := ans.(string) + if !ok { + return fmt.Errorf("expected a string, got %T", ans) + } + + if !typeRegex.MatchString(typ) { + return fmt.Errorf("type can only be lowercase letters, numbers, and hyphens") + } + + return nil +} + +func runCreate(ctx context.Context, opts *createOptions) error { + client, err := opts.Client(ctx) + if err != nil { + return err + } + + var startTime, endTime time.Time + if opts.Time != "" { + startTime, err = time.Parse(time.RFC3339, opts.Time) + if err != nil { + return fmt.Errorf("invalid time: %w", err) + } + } + if opts.EndTime != "" { + endTime, err = time.Parse(time.RFC3339, opts.EndTime) + if err != nil { + return fmt.Errorf("invalid end-time: %w", err) + } + } + + stop := opts.IO.StartActivityIndicator() + defer stop() + + annotation, err := client.Annotations.Create(ctx, &axiom.AnnotationCreateRequest{ + Type: opts.Type, + Datasets: opts.Datasets, + Title: opts.Title, + Description: opts.Description, + URL: opts.URL, + Time: startTime, + EndTime: endTime, + }) + if err != nil { + return err + } + + stop() + + if opts.IO.IsStderrTTY() { + cs := opts.IO.ColorScheme() + fmt.Fprintf(opts.IO.ErrOut(), "%s Created annotation %s\n", + cs.SuccessIcon(), cs.Bold(annotation.ID)) + } + + return nil +} diff --git a/internal/cmd/root/root.go b/internal/cmd/root/root.go index 8a8d854..a51d6c1 100644 --- a/internal/cmd/root/root.go +++ b/internal/cmd/root/root.go @@ -17,6 +17,7 @@ import ( streamCmd "github.com/axiomhq/cli/internal/cmd/stream" // Management commands + annotationCmd "github.com/axiomhq/cli/internal/cmd/annotation" configCmd "github.com/axiomhq/cli/internal/cmd/config" datasetCmd "github.com/axiomhq/cli/internal/cmd/dataset" @@ -133,6 +134,7 @@ func NewCmd(f *cmdutil.Factory) *cobra.Command { // Management commands cmd.AddCommand(configCmd.NewCmd(f)) cmd.AddCommand(datasetCmd.NewCmd(f)) + cmd.AddCommand(annotationCmd.NewCmd(f)) // Additional commands cmd.AddCommand(authCmd.NewCmd(f)) From 98b433ffc1386f64b4cc7553863fb4d09d244874 Mon Sep 17 00:00:00 2001 From: Arne Bahlo <arne@axiom.co> Date: Mon, 10 Jun 2024 16:52:59 +0200 Subject: [PATCH 05/12] feat: Add annotation delete cmd --- internal/cmd/annotation/annotation.go | 2 +- internal/cmd/annotation/annotation_delete.go | 115 +++++++++++++++++++ 2 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 internal/cmd/annotation/annotation_delete.go diff --git a/internal/cmd/annotation/annotation.go b/internal/cmd/annotation/annotation.go index 93174a2..ed1f54b 100644 --- a/internal/cmd/annotation/annotation.go +++ b/internal/cmd/annotation/annotation.go @@ -37,7 +37,7 @@ func NewCmd(f *cmdutil.Factory) *cobra.Command { } cmd.AddCommand(newCreateCmd(f)) - // cmd.AddCommand(newDeleteCmd(f)) + cmd.AddCommand(newDeleteCmd(f)) // cmd.AddCommand(newListCmd(f)) // cmd.AddCommand(newUpdateCmd(f)) diff --git a/internal/cmd/annotation/annotation_delete.go b/internal/cmd/annotation/annotation_delete.go new file mode 100644 index 0000000..a767363 --- /dev/null +++ b/internal/cmd/annotation/annotation_delete.go @@ -0,0 +1,115 @@ +package annotation + +import ( + "context" + "fmt" + + "github.com/AlecAivazis/survey/v2" + "github.com/MakeNowJust/heredoc" + "github.com/spf13/cobra" + + "github.com/axiomhq/cli/internal/cmdutil" + "github.com/axiomhq/cli/pkg/surveyext" +) + +type deleteOptions struct { + *cmdutil.Factory + + // ID of the annotation to delete. If not supplied as an argument, which is + // optional, the user will be asked for it. + ID string `survey:"id"` + // Force the deletion and skip the confirmation prompt. + Force bool +} + +func newDeleteCmd(f *cmdutil.Factory) *cobra.Command { + opts := &deleteOptions{ + Factory: f, + } + + cmd := &cobra.Command{ + Use: "delete <id>", + Short: "Delete an annotation", + + Aliases: []string{"remove"}, + + Args: cmdutil.PopulateFromArgs(f, &opts.ID), + + Example: heredoc.Doc(` + # Interactively delete an annotation: + $ axiom annotation delete + + # Delete an annotation and provide the annotation id as an argument: + $ axiom annotation delete ann_1234567890 + `), + + RunE: func(cmd *cobra.Command, _ []string) error { + if err := completeDelete(opts); err != nil { + return err + } + return runDelete(cmd.Context(), opts) + }, + } + + cmd.Flags().BoolVarP(&opts.Force, "force", "f", false, "Skip the confirmation prompt") + + _ = cmd.RegisterFlagCompletionFunc("force", cmdutil.NoCompletion) + + if !opts.IO.IsStdinTTY() { + _ = cmd.MarkFlagRequired("force") + } + + return cmd +} + +func completeDelete(opts *deleteOptions) error { + if opts.ID != "" { + return nil + } + + return survey.Ask([]*survey.Question{{ + Name: "id", + Prompt: &survey.Input{ + Message: "What is the ID of the annotation to delete?", + }, + Validate: survey.Required, + }}, &opts.ID, opts.IO.SurveyIO()) +} + +func runDelete(ctx context.Context, opts *deleteOptions) error { + // Deleting must be forced if not running interactively. + if !opts.IO.IsStdinTTY() && !opts.Force { + return cmdutil.ErrSilent + } + + if !opts.Force { + msg := fmt.Sprintf("Delete annotation %s?", opts.ID) + if overwrite, err := surveyext.AskConfirm(msg, false, opts.IO.SurveyIO()); err != nil { + return err + } else if !overwrite { + return cmdutil.ErrSilent + } + } + + client, err := opts.Client(ctx) + if err != nil { + return err + } + + stop := opts.IO.StartActivityIndicator() + defer stop() + + if err = client.Annotations.Delete(ctx, opts.ID); err != nil { + return err + } + + stop() + + if opts.IO.IsStderrTTY() { + cs := opts.IO.ColorScheme() + fmt.Fprintf(opts.IO.ErrOut(), "%s Deleted annotation %s\n", + cs.Red("✓"), cs.Bold(opts.ID)) + } + + return nil +} From aabe04d421d4a0f6c13e6d86c41c226afdbb5249 Mon Sep 17 00:00:00 2001 From: Arne Bahlo <arne@axiom.co> Date: Mon, 10 Jun 2024 17:08:46 +0200 Subject: [PATCH 06/12] feat: Add annotation list --- internal/cmd/annotation/annotation.go | 2 +- internal/cmd/annotation/annotation_list.go | 160 +++++++++++++++++++++ 2 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 internal/cmd/annotation/annotation_list.go diff --git a/internal/cmd/annotation/annotation.go b/internal/cmd/annotation/annotation.go index ed1f54b..868dc4a 100644 --- a/internal/cmd/annotation/annotation.go +++ b/internal/cmd/annotation/annotation.go @@ -38,7 +38,7 @@ func NewCmd(f *cmdutil.Factory) *cobra.Command { cmd.AddCommand(newCreateCmd(f)) cmd.AddCommand(newDeleteCmd(f)) - // cmd.AddCommand(newListCmd(f)) + cmd.AddCommand(newListCmd(f)) // cmd.AddCommand(newUpdateCmd(f)) return cmd diff --git a/internal/cmd/annotation/annotation_list.go b/internal/cmd/annotation/annotation_list.go new file mode 100644 index 0000000..37d3c20 --- /dev/null +++ b/internal/cmd/annotation/annotation_list.go @@ -0,0 +1,160 @@ +package annotation + +import ( + "context" + "fmt" + "io" + "strings" + "time" + + "github.com/MakeNowJust/heredoc" + "github.com/axiomhq/axiom-go/axiom" + "github.com/spf13/cobra" + + "github.com/axiomhq/cli/internal/cmdutil" + "github.com/axiomhq/cli/pkg/iofmt" + "github.com/axiomhq/cli/pkg/utils" +) + +type listOptions struct { + *cmdutil.Factory + + // Datasets to filter by. + Datasets []string `survey:"datasets"` + + // Filter by start time. + Start string `survey:"start-time"` + + // Filter by end time. + End string `survey:"end-time"` + + // Format to output data in. Defaults to tabular output. + Format string +} + +func newListCmd(f *cmdutil.Factory) *cobra.Command { + opts := &listOptions{ + Factory: f, + } + + cmd := &cobra.Command{ + Use: "list [(-f|--format)=json|table] [(-d|--datasets) <datasets>] [(-start-time) <start-time>] [(--end-time) <end-time>", + Short: "List all annotations", + + Aliases: []string{"ls"}, + + Example: heredoc.Doc(` + # List all annotations: + $ axiom annotations list + `), + + RunE: func(cmd *cobra.Command, _ []string) error { + return runList(cmd.Context(), opts) + }, + } + + cmd.Flags().StringArrayVarP(&opts.Datasets, "datasets", "d", nil, "Filter by datasets") + cmd.Flags().StringVarP(&opts.Start, "start-time", "", "", "Filter by start time") + cmd.Flags().StringVarP(&opts.End, "end-time", "", "", "Filter by end time") + cmd.Flags().StringVarP(&opts.Format, "format", "f", iofmt.Table.String(), "Format to output data in") + + _ = cmd.RegisterFlagCompletionFunc("format", cmdutil.FormatCompletion) + _ = cmd.RegisterFlagCompletionFunc("datasets", cmdutil.FormatCompletion) + _ = cmd.RegisterFlagCompletionFunc("start-time", cmdutil.FormatCompletion) + _ = cmd.RegisterFlagCompletionFunc("end-time", cmdutil.FormatCompletion) + + return cmd +} + +func runList(ctx context.Context, opts *listOptions) error { + client, err := opts.Client(ctx) + if err != nil { + return err + } + + var start, end *time.Time + if opts.Start != "" { + startVal, err := time.Parse(time.RFC3339, opts.Start) + if err != nil { + return fmt.Errorf("invalid start time: %w", err) + } + start = &startVal + } + if opts.End != "" { + endVal, err := time.Parse(time.RFC3339, opts.End) + if err != nil { + return fmt.Errorf("invalid start time: %w", err) + } + end = &endVal + } + + progStop := opts.IO.StartActivityIndicator() + defer progStop() + + var filter *axiom.AnnotationsFilter + if len(opts.Datasets) > 0 || start != nil || end != nil { + filter = &axiom.AnnotationsFilter{ + Datasets: opts.Datasets, + Start: start, + End: end, + } + } + + annotations, err := client.Annotations.List(ctx, filter) + if err != nil { + return err + } + + progStop() + + pagerStop, err := opts.IO.StartPager(ctx) + if err != nil { + return err + } + defer pagerStop() + + if opts.Format == iofmt.JSON.String() { + return iofmt.FormatToJSON(opts.IO.Out(), annotations, opts.IO.ColorEnabled()) + } + + if len(annotations) == 0 { + fmt.Fprintln(opts.IO.Out(), "No annotations found.") + return nil + } + + cs := opts.IO.ColorScheme() + + var header iofmt.HeaderBuilderFunc + if opts.IO.IsStdoutTTY() { + header = func(_ io.Writer, trb iofmt.TableRowBuilder) { + fmt.Fprintf(opts.IO.Out(), "Showing %s:\n\n", utils.Pluralize(cs, "annotation", len(annotations))) + trb.AddField("ID", cs.Bold) + trb.AddField("Type", cs.Bold) + trb.AddField("Datasets", cs.Bold) + trb.AddField("Title", cs.Bold) + trb.AddField("Description", cs.Bold) + trb.AddField("URL", cs.Bold) + trb.AddField("Time", cs.Bold) + trb.AddField("End time", cs.Bold) + } + } + + contentRow := func(trb iofmt.TableRowBuilder, k int) { + annotation := annotations[k] + + trb.AddField(annotation.ID, nil) + trb.AddField(annotation.Type, nil) + trb.AddField(strings.Join(annotation.Datasets, ", "), nil) + trb.AddField(annotation.Title, nil) + trb.AddField(annotation.Description, nil) + trb.AddField(annotation.URL, nil) + trb.AddField(annotation.Time.Format(time.RFC1123), cs.Gray) + if !annotation.EndTime.IsZero() { + trb.AddField(annotation.EndTime.Format(time.RFC1123), cs.Gray) + } else { + trb.AddField("-", cs.Gray) + } + } + + return iofmt.FormatToTable(opts.IO, len(annotations), header, nil, contentRow) +} From e33f691113bb3272fe0df9ba15650e188df95b23 Mon Sep 17 00:00:00 2001 From: Arne Bahlo <arne@axiom.co> Date: Mon, 10 Jun 2024 17:15:46 +0200 Subject: [PATCH 07/12] feat: Add annotation update --- internal/cmd/annotation/annotation.go | 2 +- internal/cmd/annotation/annotation_create.go | 6 + internal/cmd/annotation/annotation_update.go | 162 +++++++++++++++++++ 3 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 internal/cmd/annotation/annotation_update.go diff --git a/internal/cmd/annotation/annotation.go b/internal/cmd/annotation/annotation.go index 868dc4a..0a54e07 100644 --- a/internal/cmd/annotation/annotation.go +++ b/internal/cmd/annotation/annotation.go @@ -39,7 +39,7 @@ func NewCmd(f *cmdutil.Factory) *cobra.Command { cmd.AddCommand(newCreateCmd(f)) cmd.AddCommand(newDeleteCmd(f)) cmd.AddCommand(newListCmd(f)) - // cmd.AddCommand(newUpdateCmd(f)) + cmd.AddCommand(newUpdateCmd(f)) return cmd } diff --git a/internal/cmd/annotation/annotation_create.go b/internal/cmd/annotation/annotation_create.go index abbd086..db925e0 100644 --- a/internal/cmd/annotation/annotation_create.go +++ b/internal/cmd/annotation/annotation_create.go @@ -145,6 +145,12 @@ func runCreate(ctx context.Context, opts *createOptions) error { return err } + if opts.Type != "" { + if err := validateType(opts.Type); err != nil { + return err + } + } + var startTime, endTime time.Time if opts.Time != "" { startTime, err = time.Parse(time.RFC3339, opts.Time) diff --git a/internal/cmd/annotation/annotation_update.go b/internal/cmd/annotation/annotation_update.go new file mode 100644 index 0000000..12dc8c7 --- /dev/null +++ b/internal/cmd/annotation/annotation_update.go @@ -0,0 +1,162 @@ +package annotation + +import ( + "context" + "fmt" + "time" + + "github.com/AlecAivazis/survey/v2" + "github.com/MakeNowJust/heredoc" + "github.com/axiomhq/axiom-go/axiom" + "github.com/spf13/cobra" + + "github.com/axiomhq/cli/internal/cmdutil" +) + +type updateOptions struct { + *cmdutil.Factory + + // Type of the annotation to update. + ID string `survey:"id"` + // Type of the annotation to update. + Type string `survey:"type"` + // Datasets to attach the updated annotation to. + Datasets []string `survey:"datasets"` + // Title of the annotation to create. + Title string `survey:"title"` + // Description of the annotation to create. + Description string `survey:"description"` + // URL of the annotation to create. + URL string `survey:"url"` + // Time of the annotation to create. + Time string `survey:"time"` + // EndTime of the annotation to create. + EndTime string `survey:"end-time"` +} + +func newUpdateCmd(f *cmdutil.Factory) *cobra.Command { + opts := &updateOptions{ + Factory: f, + } + + cmd := &cobra.Command{ + Use: "update [<id>] [(-t|--type) <type>] [(-d|--datasets) <datasets>] [(-T|--title) <title>] [(-D|--description) <description>] [(-U|--url) <url>] [(--time) <time>] [(--end-time) <endTime>", + Short: "Update an annotation", + + Args: cmdutil.PopulateFromArgs(f, &opts.ID), + Aliases: []string{"update"}, + + DisableFlagsInUseLine: true, + + Example: heredoc.Doc(` + # Interactively update an annotation + $ axiom annotation update + + # Update an annotation and provide the parameters on the command-line: + $ axiom annotation update --type=deploy --datasets=http-logs + `), + + RunE: func(cmd *cobra.Command, _ []string) error { + if err := completeUpdate(opts); err != nil { + return err + } + return runUpdate(cmd.Context(), opts) + }, + } + + cmd.Flags().StringVarP(&opts.Type, "type", "t", "", "Type of the annotation (must be lowercase alphanumeric and hyphens)") + cmd.Flags().StringArrayVarP(&opts.Datasets, "datasets", "d", nil, "Datasets to attach the annotation to") + cmd.Flags().StringVarP(&opts.Title, "title", "", "", "Title of the annotation") + cmd.Flags().StringVarP(&opts.Description, "description", "", "", "Description of the annotation") + cmd.Flags().StringVarP(&opts.URL, "url", "u", "", "URL of the annotation") + cmd.Flags().StringVarP(&opts.Time, "time", "", "", "Time of the annotation") + cmd.Flags().StringVarP(&opts.EndTime, "end-time", "", "", "End time of the annotation") + + _ = cmd.RegisterFlagCompletionFunc("type", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("datasets", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("title", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("description", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("url", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("time", cmdutil.NoCompletion) + _ = cmd.RegisterFlagCompletionFunc("end-time", cmdutil.NoCompletion) + + if !opts.IO.IsStdinTTY() { + _ = cmd.MarkFlagRequired("type") + _ = cmd.MarkFlagRequired("datasets") + } + + return cmd +} + +func completeUpdate(opts *updateOptions) error { + questions := make([]*survey.Question, 0, 2) + + if opts.ID == "" { + questions = append(questions, &survey.Question{ + Name: "id", + Prompt: &survey.Input{Message: "What is the ID of the annotation to update?"}, + Validate: survey.ComposeValidators( + survey.Required, + ), + }) + } + + return survey.Ask(questions, opts, opts.IO.SurveyIO()) +} + +func runUpdate(ctx context.Context, opts *updateOptions) error { + client, err := opts.Client(ctx) + if err != nil { + return err + } + + if opts.Type != "" { + if err := validateType(opts.Type); err != nil { + return err + } + } + + var startTime, endTime time.Time + if opts.Time != "" { + startTime, err = time.Parse(time.RFC3339, opts.Time) + if err != nil { + return fmt.Errorf("invalid time: %w", err) + } + } + if opts.EndTime != "" { + endTime, err = time.Parse(time.RFC3339, opts.EndTime) + if err != nil { + return fmt.Errorf("invalid end-time: %w", err) + } + } + + if opts.Type == "" && opts.Datasets == nil && opts.Title == "" && opts.Description == "" && opts.URL == "" && startTime.IsZero() && endTime.IsZero() { + return nil // Nothing to update + } + + stop := opts.IO.StartActivityIndicator() + defer stop() + + annotation, err := client.Annotations.Update(ctx, opts.ID, &axiom.AnnotationUpdateRequest{ + Type: opts.Type, + Datasets: opts.Datasets, + Title: opts.Title, + Description: opts.Description, + URL: opts.URL, + Time: startTime, + EndTime: endTime, + }) + if err != nil { + return err + } + + stop() + + if opts.IO.IsStderrTTY() { + cs := opts.IO.ColorScheme() + fmt.Fprintf(opts.IO.ErrOut(), "%s Updated annotation %s\n", + cs.SuccessIcon(), cs.Bold(annotation.ID)) + } + + return nil +} From 8b76ad64b37b07fc1dc53c2279dc007d20ade39f Mon Sep 17 00:00:00 2001 From: Arne Bahlo <arne@axiom.co> Date: Wed, 12 Jun 2024 13:02:39 +0200 Subject: [PATCH 08/12] chore: Bump axiom-go to v0.19.0 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 5ae43db..ccbba13 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/MakeNowJust/heredoc v1.0.0 github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de - github.com/axiomhq/axiom-go v0.18.2-0.20240611074313-84aa786e2394 + github.com/axiomhq/axiom-go v0.19.0 github.com/axiomhq/pkg v0.6.0 github.com/briandowns/spinner v1.23.0 github.com/cli/cli v1.14.0 diff --git a/go.sum b/go.sum index 207cbec..20ec5dd 100644 --- a/go.sum +++ b/go.sum @@ -257,6 +257,8 @@ github.com/axiomhq/axiom-go v0.18.2-0.20240610151530-4a24251a0e46 h1:dEV3TwgtXr/ github.com/axiomhq/axiom-go v0.18.2-0.20240610151530-4a24251a0e46/go.mod h1:RjXKMe8Nib95qkaaPAR+7gIV60EdVitTfl40wIVdj/c= github.com/axiomhq/axiom-go v0.18.2-0.20240611074313-84aa786e2394 h1:92jnb6DMs20sep8QttOBOF0IStKzuEztn+5lMXFVC2U= github.com/axiomhq/axiom-go v0.18.2-0.20240611074313-84aa786e2394/go.mod h1:RjXKMe8Nib95qkaaPAR+7gIV60EdVitTfl40wIVdj/c= +github.com/axiomhq/axiom-go v0.19.0 h1:OPn+ZuUOwTFP2GSLvFcMgl8IikNzqTR1/NmDJsUhtcY= +github.com/axiomhq/axiom-go v0.19.0/go.mod h1:N04SZxbuYknU7PecU+cYMKRrBHvDksMACJ6stRgtIGw= github.com/axiomhq/pkg v0.6.0 h1:elslidLCtDB+GPOx+1VzXijf+BT28+HnPUir8vSaEkA= github.com/axiomhq/pkg v0.6.0/go.mod h1:0Vu7mQOXdsxpYYyGIm5QfHwafGboyyyoz8FIhSvA30M= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= From 63cd352076dfc8ce02f8fb368e071526892a2828 Mon Sep 17 00:00:00 2001 From: Arne Bahlo <arne@axiom.co> Date: Wed, 12 Jun 2024 13:45:38 +0200 Subject: [PATCH 09/12] chore: Run go mod tidy --- go.sum | 8 -------- 1 file changed, 8 deletions(-) diff --git a/go.sum b/go.sum index 20ec5dd..782363c 100644 --- a/go.sum +++ b/go.sum @@ -249,14 +249,6 @@ github.com/aws/smithy-go v1.20.2 h1:tbp628ireGtzcHDDmLT/6ADHidqnwgF57XOXZe6tp4Q= github.com/aws/smithy-go v1.20.2/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20240514230400-03fa26f5508f h1:Z0kS9pJDQgCg3u2lH6+CdYaFbyQtyukVTiUCG6re0E4= github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20240514230400-03fa26f5508f/go.mod h1:rAE739ssmE5O5fLuQ2y8uHdmOJaelE5I0Es3SxV0y1A= -github.com/axiomhq/axiom-go v0.18.1 h1:dKZlrc5/ZE5kdgEw1KO1XS2SuxLK2deNXlFarso8jp4= -github.com/axiomhq/axiom-go v0.18.1/go.mod h1:RjXKMe8Nib95qkaaPAR+7gIV60EdVitTfl40wIVdj/c= -github.com/axiomhq/axiom-go v0.18.2-0.20240610132143-f784f1af85d5 h1:wR2i7KzXe4quBZWSm+A547sTs7MtnVN29bFJ5N8ZjmA= -github.com/axiomhq/axiom-go v0.18.2-0.20240610132143-f784f1af85d5/go.mod h1:RjXKMe8Nib95qkaaPAR+7gIV60EdVitTfl40wIVdj/c= -github.com/axiomhq/axiom-go v0.18.2-0.20240610151530-4a24251a0e46 h1:dEV3TwgtXr/po7Bmiv7mgI4LVwhDNLmz8wsbA0U8Bgs= -github.com/axiomhq/axiom-go v0.18.2-0.20240610151530-4a24251a0e46/go.mod h1:RjXKMe8Nib95qkaaPAR+7gIV60EdVitTfl40wIVdj/c= -github.com/axiomhq/axiom-go v0.18.2-0.20240611074313-84aa786e2394 h1:92jnb6DMs20sep8QttOBOF0IStKzuEztn+5lMXFVC2U= -github.com/axiomhq/axiom-go v0.18.2-0.20240611074313-84aa786e2394/go.mod h1:RjXKMe8Nib95qkaaPAR+7gIV60EdVitTfl40wIVdj/c= github.com/axiomhq/axiom-go v0.19.0 h1:OPn+ZuUOwTFP2GSLvFcMgl8IikNzqTR1/NmDJsUhtcY= github.com/axiomhq/axiom-go v0.19.0/go.mod h1:N04SZxbuYknU7PecU+cYMKRrBHvDksMACJ6stRgtIGw= github.com/axiomhq/pkg v0.6.0 h1:elslidLCtDB+GPOx+1VzXijf+BT28+HnPUir8vSaEkA= From 237c5f94523643750653d7fa077e6a50c8af935d Mon Sep 17 00:00:00 2001 From: Arne Bahlo <arne@axiom.co> Date: Wed, 12 Jun 2024 14:43:03 +0200 Subject: [PATCH 10/12] fix: Update annotation filter options handling --- internal/cmd/annotation/annotation_list.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/cmd/annotation/annotation_list.go b/internal/cmd/annotation/annotation_list.go index 37d3c20..1ea3594 100644 --- a/internal/cmd/annotation/annotation_list.go +++ b/internal/cmd/annotation/annotation_list.go @@ -72,27 +72,27 @@ func runList(ctx context.Context, opts *listOptions) error { return err } - var start, end *time.Time + var start, end time.Time if opts.Start != "" { - startVal, err := time.Parse(time.RFC3339, opts.Start) + var err error + start, err = time.Parse(time.RFC3339, opts.Start) if err != nil { return fmt.Errorf("invalid start time: %w", err) } - start = &startVal } if opts.End != "" { - endVal, err := time.Parse(time.RFC3339, opts.End) + var err error + end, err = time.Parse(time.RFC3339, opts.End) if err != nil { return fmt.Errorf("invalid start time: %w", err) } - end = &endVal } progStop := opts.IO.StartActivityIndicator() defer progStop() var filter *axiom.AnnotationsFilter - if len(opts.Datasets) > 0 || start != nil || end != nil { + if len(opts.Datasets) > 0 || !start.IsZero() || !end.IsZero() { filter = &axiom.AnnotationsFilter{ Datasets: opts.Datasets, Start: start, From 48f4a74320297b3fce0e2a440a2905db70b36b87 Mon Sep 17 00:00:00 2001 From: Arne Bahlo <arne@axiom.co> Date: Wed, 12 Jun 2024 16:53:50 +0200 Subject: [PATCH 11/12] fix: lukaslint Co-authored-by: Lukas Malkmus <lukas@axiom.co> --- internal/cmd/dataset/dataset_trim.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/cmd/dataset/dataset_trim.go b/internal/cmd/dataset/dataset_trim.go index 7636403..82bbb7b 100644 --- a/internal/cmd/dataset/dataset_trim.go +++ b/internal/cmd/dataset/dataset_trim.go @@ -131,8 +131,7 @@ func runTrim(ctx context.Context, opts *trimOptions) error { stop := opts.IO.StartActivityIndicator() defer stop() - err = client.Datasets.Trim(ctx, opts.Name, opts.Duration) - if err != nil { + if err = client.Datasets.Trim(ctx, opts.Name, opts.Duration); err != nil { return err } From 69e265b3fd5e67bf01920a924842c350cee939b0 Mon Sep 17 00:00:00 2001 From: Arne Bahlo <arne@axiom.co> Date: Wed, 12 Jun 2024 16:54:19 +0200 Subject: [PATCH 12/12] fix: Improve trimming response --- internal/cmd/dataset/dataset_trim.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/dataset/dataset_trim.go b/internal/cmd/dataset/dataset_trim.go index 82bbb7b..c176ebc 100644 --- a/internal/cmd/dataset/dataset_trim.go +++ b/internal/cmd/dataset/dataset_trim.go @@ -139,7 +139,7 @@ func runTrim(ctx context.Context, opts *trimOptions) error { if opts.IO.IsStderrTTY() { cs := opts.IO.ColorScheme() - fmt.Fprintf(opts.IO.ErrOut(), "%s Trimmed dataset %s\n", + fmt.Fprintf(opts.IO.ErrOut(), "%s Dataset trimming requested %s\n", cs.SuccessIcon(), cs.Bold(opts.Name)) }