@@ -953,13 +953,20 @@ func generateFullReleaseJSON(v version.Version) {
953
953
return
954
954
}
955
955
956
- awsClient , err := aws .GetClient ()
957
- check (err , "get aws client" )
956
+ awsClientOld , err := aws .GetClient ()
957
+ check (err , "get aws client old " )
958
958
959
- feed , err := awsClient .GenerateFullReleaseFeedFromObjects ()
959
+ newAccessKeyID := os .Getenv ("NEW_AWS_ACCESS_KEY_ID" )
960
+ newSecretAccessKey := os .Getenv ("NEW_AWS_SECRET_ACCESS_KEY" )
961
+ newSessionToken := os .Getenv ("NEW_AWS_SESSION_TOKEN" )
962
+
963
+ awsClientNew , err := aws .NewClientFromCredentials (newAccessKeyID , newSecretAccessKey , newSessionToken , "private" )
964
+ check (err , "new aws client from credentials" )
965
+
966
+ feed , err := awsClientOld .GenerateFullReleaseFeedFromObjects ()
960
967
check (err , "generate full release feed from s3 objects" )
961
968
962
- uploadFeedFile ("full.json" , feed , awsClient )
969
+ uploadFeedFile ("full.json" , feed , awsClientOld , awsClientNew )
963
970
}
964
971
965
972
func uploadReleaseJSON (v version.Version ) {
@@ -996,8 +1003,15 @@ func uploadReleaseJSON(v version.Version) {
996
1003
log .Fatalf ("found %d sign tasks, but expected %d" , len (signTasks ), pfCount )
997
1004
}
998
1005
999
- awsClient , err := aws .GetClient ()
1000
- check (err , "get aws client" )
1006
+ awsClientOld , err := aws .GetClient ()
1007
+ check (err , "get aws client old" )
1008
+
1009
+ newAccessKeyID := os .Getenv ("NEW_AWS_ACCESS_KEY_ID" )
1010
+ newSecretAccessKey := os .Getenv ("NEW_AWS_SECRET_ACCESS_KEY" )
1011
+ newSessionToken := os .Getenv ("NEW_AWS_SESSION_TOKEN" )
1012
+
1013
+ awsClientNew , err := aws .NewClientFromCredentials (newAccessKeyID , newSecretAccessKey , newSessionToken , "private" )
1014
+ check (err , "new aws client from credentials" )
1001
1015
1002
1016
// Accumulate all downloaded artifacts from sign tasks for JSON feed.
1003
1017
var dls []* download.ToolsDownload
@@ -1061,8 +1075,18 @@ func uploadReleaseJSON(v version.Version) {
1061
1075
}
1062
1076
1063
1077
// Download the current full.json
1064
- buff , err := awsClient .DownloadFile ("downloads.mongodb.org" , "tools/db/full.json" )
1065
- check (err , "download full.json" )
1078
+ const addr = "https://downloads.mongodb.org/tools/db/full.json"
1079
+ res , err := http .Get (addr )
1080
+ check (err , "http get full.json" )
1081
+
1082
+ defer res .Body .Close ()
1083
+
1084
+ buff , err := io .ReadAll (res .Body )
1085
+ check (err , "read full.json body" )
1086
+
1087
+ if res .StatusCode != http .StatusOK {
1088
+ panic (fmt .Errorf ("get full.json status %d: %s" , res .StatusCode , string (buff )))
1089
+ }
1066
1090
1067
1091
var fullFeed download.JSONFeed
1068
1092
@@ -1074,7 +1098,7 @@ func uploadReleaseJSON(v version.Version) {
1074
1098
fullFeed .Versions ,
1075
1099
& download.ToolsVersion {Version : v .String (), Downloads : dls },
1076
1100
)
1077
- uploadFeedFile ("full.json" , & fullFeed , awsClient )
1101
+ uploadFeedFile ("full.json" , & fullFeed , awsClientOld , awsClientNew )
1078
1102
1079
1103
// Upload only the most recent version to release.json
1080
1104
var feed download.JSONFeed
@@ -1083,23 +1107,32 @@ func uploadReleaseJSON(v version.Version) {
1083
1107
& download.ToolsVersion {Version : v .String (), Downloads : dls },
1084
1108
)
1085
1109
1086
- uploadFeedFile ("release.json" , & feed , awsClient )
1110
+ uploadFeedFile ("release.json" , & feed , awsClientOld , awsClientNew )
1087
1111
}
1088
1112
1089
- func uploadFeedFile (filename string , feed * download.JSONFeed , awsClient * aws.AWS ) {
1113
+ func uploadFeedFile (filename string , feed * download.JSONFeed , awsClientOld , awsClientNew * aws.AWS ) {
1090
1114
var feedBuffer bytes.Buffer
1091
1115
1092
1116
jsonEncoder := json .NewEncoder (& feedBuffer )
1093
1117
jsonEncoder .SetIndent ("" , " " )
1094
1118
err := jsonEncoder .Encode (* feed )
1095
1119
check (err , "encode json feed" )
1096
1120
1121
+ feedBytes := feedBuffer .Bytes ()
1122
+
1097
1123
log .Printf (
1098
1124
"uploading download feed to https://s3.amazonaws.com/downloads.mongodb.org/tools/db/%s\n " ,
1099
1125
filename ,
1100
1126
)
1101
- err = awsClient .UploadBytes ("downloads.mongodb.org" , "/tools/db" , filename , & feedBuffer )
1102
- check (err , "upload json feed" )
1127
+ err = awsClientOld .UploadBytes ("downloads.mongodb.org" , "/tools/db" , filename , bytes .NewReader (feedBytes ))
1128
+ check (err , "upload json feed old" )
1129
+
1130
+ log .Printf (
1131
+ "uploading download feed to s3://cdn-origin-db-tools/tools/db/%s\n " ,
1132
+ filename ,
1133
+ )
1134
+ err = awsClientNew .UploadBytes ("cdn-origin-db-tools" , "/tools/db" , filename , bytes .NewReader (feedBytes ))
1135
+ check (err , "upload json feed new" )
1103
1136
}
1104
1137
1105
1138
func uploadRelease (v version.Version ) {
@@ -1129,8 +1162,15 @@ func uploadRelease(v version.Version) {
1129
1162
log .Fatalf ("found %d sign tasks, but expected one" , len (signTasks ))
1130
1163
}
1131
1164
1132
- awsClient , err := aws .GetClient ()
1133
- check (err , "get aws client" )
1165
+ awsClientOld , err := aws .GetClient ()
1166
+ check (err , "get old aws client" )
1167
+
1168
+ newAccessKeyID := os .Getenv ("NEW_AWS_ACCESS_KEY_ID" )
1169
+ newSecretAccessKey := os .Getenv ("NEW_AWS_SECRET_ACCESS_KEY" )
1170
+ newSessionToken := os .Getenv ("NEW_AWS_SESSION_TOKEN" )
1171
+
1172
+ awsClientNew , err := aws .NewClientFromCredentials (newAccessKeyID , newSecretAccessKey , newSessionToken , "private" )
1173
+ check (err , "new aws client from credentials" )
1134
1174
1135
1175
for _ , task := range signTasks {
1136
1176
log .Printf ("\n getting artifacts for %s\n " , task .Variant )
@@ -1182,14 +1222,29 @@ func uploadRelease(v version.Version) {
1182
1222
" uploading to https://s3.amazonaws.com/downloads.mongodb.org/tools/db/%s\n " ,
1183
1223
stableFile ,
1184
1224
)
1185
- err = awsClient .UploadFile ("downloads.mongodb.org" , "/tools/db" , stableFile )
1225
+ err = awsClientOld .UploadFile ("downloads.mongodb.org" , "/tools/db" , stableFile )
1186
1226
check (err , "uploading %q file to S3" , stableFile )
1187
1227
log .Printf (
1188
1228
" uploading to https://s3.amazonaws.com/downloads.mongodb.org/tools/db/%s\n " ,
1189
1229
latestStableFile ,
1190
1230
)
1191
- err = awsClient .UploadFile ("downloads.mongodb.org" , "/tools/db" , latestStableFile )
1231
+
1232
+ err = awsClientOld .UploadFile ("downloads.mongodb.org" , "/tools/db" , latestStableFile )
1192
1233
check (err , "uploading %q file to S3" , latestStableFile )
1234
+
1235
+ log .Printf (
1236
+ " uploading to s3://cdn-origin-db-tools/tools/db/%s\n " ,
1237
+ stableFile ,
1238
+ )
1239
+ err = awsClientNew .UploadFile ("cdn-origin-db-tools" , "/tools/db" , stableFile )
1240
+ check (err , "uploading %q file to S3 new" , stableFile )
1241
+ log .Printf (
1242
+ " uploading to s3://cdn-origin-db-tools/tools/db/%s\n " ,
1243
+ latestStableFile ,
1244
+ )
1245
+
1246
+ err = awsClientNew .UploadFile ("cdn-origin-db-tools" , "/tools/db" , latestStableFile )
1247
+ check (err , "uploading %q file to S3 new" , latestStableFile )
1193
1248
}
1194
1249
}
1195
1250
}
0 commit comments