Skip to content

Commit 41b6cdd

Browse files
committed
Fixed conversion issues and added formatting improvements
1 parent 8f056b6 commit 41b6cdd

File tree

8 files changed

+183
-35
lines changed

8 files changed

+183
-35
lines changed

chaoscenter/authentication/go.mod

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/litmuschaos/litmus/chaoscenter/authentication
22

3-
go 1.22.0
3+
go 1.25
44

55
require (
66
github.com/coreos/go-oidc/v3 v3.1.0
@@ -11,7 +11,6 @@ require (
1111
github.com/kelseyhightower/envconfig v1.4.0
1212
github.com/sirupsen/logrus v1.9.3
1313
github.com/stretchr/testify v1.9.0
14-
github.com/swaggo/swag v1.16.3
1514
go.mongodb.org/mongo-driver v1.17.1
1615
golang.org/x/crypto v0.31.0
1716
golang.org/x/oauth2 v0.21.0
@@ -20,29 +19,23 @@ require (
2019
)
2120

2221
require (
23-
github.com/KyleBanks/depth v1.2.1 // indirect
2422
github.com/bytedance/sonic v1.11.6 // indirect
2523
github.com/bytedance/sonic/loader v0.1.1 // indirect
2624
github.com/cloudwego/base64x v0.1.4 // indirect
2725
github.com/cloudwego/iasm v0.2.0 // indirect
2826
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2927
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
3028
github.com/gin-contrib/sse v0.1.0 // indirect
31-
github.com/go-openapi/jsonpointer v0.21.0 // indirect
32-
github.com/go-openapi/jsonreference v0.21.0 // indirect
33-
github.com/go-openapi/spec v0.21.0 // indirect
34-
github.com/go-openapi/swag v0.23.0 // indirect
3529
github.com/go-playground/locales v0.14.1 // indirect
3630
github.com/go-playground/universal-translator v0.18.1 // indirect
3731
github.com/go-playground/validator/v10 v10.20.0 // indirect
3832
github.com/goccy/go-json v0.10.2 // indirect
3933
github.com/golang/snappy v0.0.4 // indirect
40-
github.com/josharian/intern v1.0.0 // indirect
4134
github.com/json-iterator/go v1.1.12 // indirect
4235
github.com/klauspost/compress v1.17.0 // indirect
4336
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
37+
github.com/kr/pretty v0.3.1 // indirect
4438
github.com/leodido/go-urn v1.4.0 // indirect
45-
github.com/mailru/easyjson v0.7.7 // indirect
4639
github.com/mattn/go-isatty v0.0.20 // indirect
4740
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4841
github.com/modern-go/reflect2 v1.0.2 // indirect
@@ -62,8 +55,8 @@ require (
6255
golang.org/x/sync v0.10.0 // indirect
6356
golang.org/x/sys v0.28.0 // indirect
6457
golang.org/x/text v0.21.0 // indirect
65-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
6658
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
59+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
6760
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
6861
gopkg.in/yaml.v3 v3.0.1 // indirect
6962
)

chaoscenter/authentication/go.sum

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
2-
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
3-
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
42
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
53
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
64
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
@@ -11,6 +9,7 @@ github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
119
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
1210
github.com/coreos/go-oidc/v3 v3.1.0 h1:6avEvcdvTa1qYsOZ6I5PRkSYHzpTNWgKYmaJfaYbrRw=
1311
github.com/coreos/go-oidc/v3 v3.1.0/go.mod h1:rEJ/idjfUyfkBit1eI1fvyr+64/g9dcKpAm8MJMesvo=
12+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
1413
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1514
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1615
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
@@ -21,14 +20,6 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
2120
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
2221
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
2322
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
24-
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
25-
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
26-
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
27-
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4=
28-
github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY=
29-
github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk=
30-
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
31-
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
3223
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
3324
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
3425
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
@@ -52,8 +43,6 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
5243
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
5344
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
5445
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
55-
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
56-
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
5746
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
5847
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
5948
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
@@ -64,14 +53,15 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02
6453
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
6554
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
6655
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
56+
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
6757
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
6858
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
59+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
60+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
6961
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
7062
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
7163
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
7264
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
73-
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
74-
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
7565
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
7666
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
7767
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -83,9 +73,11 @@ github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8
8373
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
8474
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
8575
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
76+
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
8677
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8778
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
8879
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
80+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
8981
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
9082
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
9183
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
@@ -104,8 +96,6 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
10496
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
10597
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
10698
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
107-
github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg=
108-
github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk=
10999
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
110100
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
111101
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
@@ -129,8 +119,6 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
129119
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
130120
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
131121
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
132-
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
133-
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
134122
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
135123
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
136124
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -169,8 +157,6 @@ golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
169157
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
170158
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
171159
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
172-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
173-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
174160
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
175161
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
176162
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=

chaoscenter/event-tracker/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/litmuschaos/litmus/chaoscenter/event-tracker
22

3-
go 1.22
3+
go 1.25
44

55
require (
66
github.com/jmespath/go-jmespath v0.4.0

chaoscenter/graphql/server/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/litmuschaos/litmus/chaoscenter/graphql/server
22

3-
go 1.22.0
3+
go 1.25
44

55
require (
66
github.com/99designs/gqlgen v0.17.49

chaoscenter/subscriber/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module subscriber
22

3-
go 1.22
3+
go 1.25
44

55
require (
66
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24

chaoscenter/upgrade-agents/control-plane/go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module github.com/litmuschaos/litmus/chaoscenter/upgrader-agents/control-plane
22

3-
go 1.22
4-
toolchain go1.23.7
3+
go 1.25
54

65
require (
76
github.com/kelseyhightower/envconfig v1.4.0

test-chaoscenter-mods.ps1

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# test-chaoscenter-mods.ps1
2+
# Run from repo root (where the litmus folder exists) or pass -Root to chaoscenter path.
3+
param(
4+
[string]$ChaosCenter = ".\litmus\chaoscenter",
5+
[string]$GoVersion = "1.25"
6+
)
7+
8+
$ErrorActionPreference = "Stop"
9+
$startDir = Get-Location
10+
$logsDir = Join-Path $startDir "go_mod_update_logs"
11+
New-Item -ItemType Directory -Force -Path $logsDir | Out-Null
12+
13+
# Discover all go.mod files inside ChaosCenter (depth arbitrary)
14+
$gomods = Get-ChildItem -Path $ChaosCenter -Recurse -Filter "go.mod" -File
15+
16+
if (-not $gomods) {
17+
Write-Host "No go.mod files found under $ChaosCenter"
18+
exit 1
19+
}
20+
21+
$results = @()
22+
23+
Write-Host "Found $($gomods.Count) modules. Updating to go $GoVersion, tidying, building, and testing..." -ForegroundColor Cyan
24+
25+
foreach ($gm in $gomods) {
26+
$moduleDir = $gm.Directory.FullName
27+
$relPath = Resolve-Path -LiteralPath $moduleDir | ForEach-Object {
28+
$_.Path.Substring((Resolve-Path .).Path.Length).TrimStart('\')
29+
}
30+
$name = Split-Path $moduleDir -Leaf
31+
$log = Join-Path $logsDir ("{0}-{1:yyyyMMdd_HHmmss}.log" -f $name,(Get-Date))
32+
33+
$status = @{
34+
Module = $name
35+
Path = $relPath
36+
Update = "SKIP"
37+
Tidy = "SKIP"
38+
Build = "SKIP"
39+
Test = "SKIP"
40+
Log = $log
41+
}
42+
43+
Write-Host "`n=== $relPath ===" -ForegroundColor Yellow
44+
Push-Location $moduleDir
45+
try {
46+
# 1) Update 'go' directive in go.mod to requested version (in-place)
47+
Write-Host "Updating go.mod go directive to $GoVersion"
48+
"== update go directive ==" | Tee-Object -FilePath $log -Append | Out-Null
49+
# Replace 'go x.y' line; preserves comments/other lines
50+
$gomodText = Get-Content -Raw -LiteralPath "go.mod"
51+
$gomodText = $gomodText -replace "(?m)^\s*go\s+\d+\.\d+\s*$","go $GoVersion"
52+
$gomodText | Set-Content -LiteralPath "go.mod"
53+
$status.Update = "OK"
54+
55+
# 2) Tidy dependencies (recommended in multi-module workspaces) [go.work guidance] [web:19][web:4]
56+
Write-Host "go mod tidy..."
57+
"== go mod tidy ==" | Tee-Object -FilePath $log -Append | Out-Null
58+
& go mod tidy 2>&1 | Tee-Object -FilePath $log -Append | Out-Null
59+
if ($LASTEXITCODE -eq 0) { $status.Tidy = "OK" } else { $status.Tidy = "FAIL" }
60+
61+
# 3) Build all packages in the module [web:12]
62+
Write-Host "go build ./..."
63+
"== go build ./... ==" | Tee-Object -FilePath $log -Append | Out-Null
64+
& go build ./... 2>&1 | Tee-Object -FilePath $log -Append | Out-Null
65+
if ($LASTEXITCODE -eq 0) { $status.Build = "OK" } else { $status.Build = "FAIL" }
66+
67+
# 4) Test all packages in the module (race + fresh run) [web:2][web:12]
68+
Write-Host "go test ./... -race -count=1 -v"
69+
"== go test ./... -race -count=1 -v ==" | Tee-Object -FilePath $log -Append | Out-Null
70+
& go test ./... -race -count=1 -v 2>&1 | Tee-Object -FilePath $log -Append | Out-Null
71+
if ($LASTEXITCODE -eq 0) { $status.Test = "OK" } else { $status.Test = "FAIL" }
72+
}
73+
finally {
74+
Pop-Location
75+
}
76+
77+
$results += [pscustomobject]$status
78+
}
79+
80+
Write-Host "`n===== SUMMARY =====" -ForegroundColor Cyan
81+
$results | Sort-Object Path | Format-Table Module,Path,Update,Tidy,Build,Test,Log -AutoSize
82+
83+
# Exit non-zero if any step failed
84+
$failed = $results | Where-Object { $_.Update -eq "FAIL" -or $_.Tidy -eq "FAIL" -or $_.Build -eq "FAIL" -or $_.Test -eq "FAIL" }
85+
if ($failed) { exit 1 } else { exit 0 }

test-chaoscenter-mods.ps1​

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# test-chaoscenter-mods.ps1
2+
# Run from repo root (where the litmus folder exists) or pass -Root to chaoscenter path.
3+
param(
4+
[string]$ChaosCenter = ".\litmus\chaoscenter",
5+
[string]$GoVersion = "1.25"
6+
)
7+
8+
$ErrorActionPreference = "Stop"
9+
$startDir = Get-Location
10+
$logsDir = Join-Path $startDir "go_mod_update_logs"
11+
New-Item -ItemType Directory -Force -Path $logsDir | Out-Null
12+
13+
# Discover all go.mod files inside ChaosCenter (depth arbitrary)
14+
$gomods = Get-ChildItem -Path $ChaosCenter -Recurse -Filter "go.mod" -File
15+
16+
if (-not $gomods) {
17+
Write-Host "No go.mod files found under $ChaosCenter"
18+
exit 1
19+
}
20+
21+
$results = @()
22+
23+
Write-Host "Found $($gomods.Count) modules. Updating to go $GoVersion, tidying, building, and testing..." -ForegroundColor Cyan
24+
25+
foreach ($gm in $gomods) {
26+
$moduleDir = $gm.Directory.FullName
27+
$relPath = Resolve-Path -LiteralPath $moduleDir | ForEach-Object {
28+
$_.Path.Substring((Resolve-Path .).Path.Length).TrimStart('\')
29+
}
30+
$name = Split-Path $moduleDir -Leaf
31+
$log = Join-Path $logsDir ("{0}-{1:yyyyMMdd_HHmmss}.log" -f $name,(Get-Date))
32+
33+
$status = @{
34+
Module = $name
35+
Path = $relPath
36+
Update = "SKIP"
37+
Tidy = "SKIP"
38+
Build = "SKIP"
39+
Test = "SKIP"
40+
Log = $log
41+
}
42+
43+
Write-Host "`n=== $relPath ===" -ForegroundColor Yellow
44+
Push-Location $moduleDir
45+
try {
46+
# 1) Update 'go' directive in go.mod to requested version (in-place)
47+
Write-Host "Updating go.mod go directive to $GoVersion"
48+
"== update go directive ==" | Tee-Object -FilePath $log -Append | Out-Null
49+
# Replace 'go x.y' line; preserves comments/other lines
50+
$gomodText = Get-Content -Raw -LiteralPath "go.mod"
51+
$gomodText = $gomodText -replace "(?m)^\s*go\s+\d+\.\d+\s*$","go $GoVersion"
52+
$gomodText | Set-Content -LiteralPath "go.mod"
53+
$status.Update = "OK"
54+
55+
# 2) Tidy dependencies (recommended in multi-module workspaces) [go.work guidance] [web:19][web:4]
56+
Write-Host "go mod tidy..."
57+
"== go mod tidy ==" | Tee-Object -FilePath $log -Append | Out-Null
58+
& go mod tidy 2>&1 | Tee-Object -FilePath $log -Append | Out-Null
59+
if ($LASTEXITCODE -eq 0) { $status.Tidy = "OK" } else { $status.Tidy = "FAIL" }
60+
61+
# 3) Build all packages in the module [web:12]
62+
Write-Host "go build ./..."
63+
"== go build ./... ==" | Tee-Object -FilePath $log -Append | Out-Null
64+
& go build ./... 2>&1 | Tee-Object -FilePath $log -Append | Out-Null
65+
if ($LASTEXITCODE -eq 0) { $status.Build = "OK" } else { $status.Build = "FAIL" }
66+
67+
# 4) Test all packages in the module (race + fresh run) [web:2][web:12]
68+
Write-Host "go test ./... -race -count=1 -v"
69+
"== go test ./... -race -count=1 -v ==" | Tee-Object -FilePath $log -Append | Out-Null
70+
& go test ./... -race -count=1 -v 2>&1 | Tee-Object -FilePath $log -Append | Out-Null
71+
if ($LASTEXITCODE -eq 0) { $status.Test = "OK" } else { $status.Test = "FAIL" }
72+
}
73+
finally {
74+
Pop-Location
75+
}
76+
77+
$results += [pscustomobject]$status
78+
}
79+
80+
Write-Host "`n===== SUMMARY =====" -ForegroundColor Cyan
81+
$results | Sort-Object Path | Format-Table Module,Path,Update,Tidy,Build,Test,Log -AutoSize
82+
83+
# Exit non-zero if any step failed
84+
$failed = $results | Where-Object { $_.Update -eq "FAIL" -or $_.Tidy -eq "FAIL" -or $_.Build -eq "FAIL" -or $_.Test -eq "FAIL" }
85+
if ($failed) { exit 1 } else { exit 0 }

0 commit comments

Comments
 (0)