From 9a5fb8d3cb67fb8c969b2b177306013e00dfd69f Mon Sep 17 00:00:00 2001 From: Sebastian Florek Date: Wed, 9 Oct 2024 14:27:19 +0200 Subject: [PATCH] feat(upgradeinsights): add client stats support to upgrade insights --- go.mod | 2 +- go.sum | 4 ++-- internal/controller/upgradeinsights_cloudprovider.go | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9a9ff162..adfca085 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/open-policy-agent/gatekeeper/v3 v3.17.1 github.com/orcaman/concurrent-map/v2 v2.0.1 github.com/pkg/errors v0.9.1 - github.com/pluralsh/console/go/client v1.20.0 + github.com/pluralsh/console/go/client v1.21.0 github.com/pluralsh/controller-reconcile-helper v0.1.0 github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34 github.com/pluralsh/polly v0.1.10 diff --git a/go.sum b/go.sum index cf0de887..5bcfb3d1 100644 --- a/go.sum +++ b/go.sum @@ -666,8 +666,8 @@ github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rK github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pluralsh/console/go/client v1.20.0 h1:XZ9GcNAcEXRXtcyHZdA1dpi/GovMdHbC+obJgD+RnzE= -github.com/pluralsh/console/go/client v1.20.0/go.mod h1:lpoWASYsM9keNePS3dpFiEisUHEfObIVlSL3tzpKn8k= +github.com/pluralsh/console/go/client v1.21.0 h1:l7gltTPY8gR4qhK0RV8WYBP3MdpwJe96AIclTti9Hz0= +github.com/pluralsh/console/go/client v1.21.0/go.mod h1:lpoWASYsM9keNePS3dpFiEisUHEfObIVlSL3tzpKn8k= github.com/pluralsh/controller-reconcile-helper v0.1.0 h1:BV3dYZFH5rn8ZvZjtpkACSv/GmLEtRftNQj/Y4ddHEo= github.com/pluralsh/controller-reconcile-helper v0.1.0/go.mod h1:RxAbvSB4/jkvx616krCdNQXPbpGJXW3J1L3rASxeFOA= github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34 h1:ab2PN+6if/Aq3/sJM0AVdy1SYuMAnq4g20VaKhTm/Bw= diff --git a/internal/controller/upgradeinsights_cloudprovider.go b/internal/controller/upgradeinsights_cloudprovider.go index c923f50e..770fd8e6 100644 --- a/internal/controller/upgradeinsights_cloudprovider.go +++ b/internal/controller/upgradeinsights_cloudprovider.go @@ -3,6 +3,7 @@ package controller import ( "context" "fmt" + "strconv" "time" "github.com/aws/aws-sdk-go-v2/aws" @@ -156,6 +157,13 @@ func (in *EKSCloudProvider) toInsightDetails(insight *types.Insight) []*console. ReplacedIn: r.StartServingReplacementVersion, RemovedIn: r.StopServingVersion, Status: in.fromClientStats(r.ClientStats), + ClientInfo: algorithms.Map(r.ClientStats, func(cs types.ClientStat) *console.InsightClientInfoAttributes { + return &console.InsightClientInfoAttributes{ + UserAgent: cs.UserAgent, + Count: lo.ToPtr(strconv.FormatInt(int64(cs.NumberOfRequestsLast30Days), 10)), + LastRequestAt: lo.ToPtr(cs.LastRequestTime.Format(time.RFC3339)), + } + }), }) }