mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-25 00:19:11 -05:00
chore: update aws sdk (#28712)
* chore: update the awk-sdk to version 3 and awspublish to use version 3 (version 8) [run ci] chore: add region to aws s3 bucket [run ci] * run ci for aws_updates
This commit is contained in:
+14
-11
@@ -1,7 +1,7 @@
|
||||
const debug = require('debug')('cypress:binary')
|
||||
import la from 'lazy-ass'
|
||||
import is from 'check-more-types'
|
||||
import S3 from 'aws-sdk/clients/s3'
|
||||
import { CopyObjectCommandInput, CopyObjectCommandOutput, ObjectCannedACL, S3 } from '@aws-sdk/client-s3'
|
||||
|
||||
export const hasOnlyStringValues = (o) => {
|
||||
return Object.values(o).every((v) => is.unemptyString(v))
|
||||
@@ -22,9 +22,12 @@ export const s3helpers = {
|
||||
}
|
||||
|
||||
return new S3({
|
||||
accessKeyId: aws.accessKeyId,
|
||||
secretAccessKey: aws.secretAccessKey,
|
||||
sessionToken: aws.sessionToken,
|
||||
credentials: {
|
||||
accessKeyId: aws.accessKeyId,
|
||||
secretAccessKey: aws.secretAccessKey,
|
||||
sessionToken: aws.sessionToken,
|
||||
},
|
||||
region: 'us-east-1',
|
||||
})
|
||||
},
|
||||
|
||||
@@ -83,12 +86,12 @@ export const s3helpers = {
|
||||
* and ACL 'public-read'
|
||||
*/
|
||||
copyS3 (sourceKey: string, destinationKey: string, bucket: string,
|
||||
contentType: S3.ContentType, acl: S3.ObjectCannedACL,
|
||||
s3: S3): Promise<S3.CopyObjectOutput> {
|
||||
contentType: string, acl: ObjectCannedACL,
|
||||
s3: S3): Promise<CopyObjectCommandOutput> {
|
||||
return new Promise((resolve, reject) => {
|
||||
debug('copying %s in bucket %s to %s', sourceKey, bucket, destinationKey)
|
||||
|
||||
const params: S3.CopyObjectRequest = {
|
||||
const params: CopyObjectCommandInput = {
|
||||
Bucket: bucket,
|
||||
CopySource: `${bucket}/${sourceKey}`,
|
||||
Key: destinationKey,
|
||||
@@ -116,7 +119,7 @@ export const s3helpers = {
|
||||
* but the returned object has these prefixes stripped. Thus if we set
|
||||
* a single "x-amz-meta-user: gleb", the resolved object will be simply {user: "gleb"}
|
||||
*/
|
||||
getUserMetadata (bucket: string, key: string, s3: S3): Promise<S3.Metadata> {
|
||||
getUserMetadata (bucket: string, key: string, s3: S3): Promise<Record<string, string>> {
|
||||
return new Promise((resole, reject) => {
|
||||
debug('getting user metadata from %s %s', bucket, key)
|
||||
|
||||
@@ -139,15 +142,15 @@ export const s3helpers = {
|
||||
* Setting user metadata can be accomplished with copying the object back onto itself
|
||||
* with replaced metadata object.
|
||||
*/
|
||||
setUserMetadata (bucket: string, key: string, metadata: S3.Metadata,
|
||||
contentType: S3.ContentType, acl: S3.ObjectCannedACL, s3: S3): Promise<S3.CopyObjectOutput> {
|
||||
setUserMetadata (bucket: string, key: string, metadata: Record<string, string>,
|
||||
contentType: string, acl: ObjectCannedACL, s3: S3): Promise<CopyObjectCommandOutput> {
|
||||
la(hasOnlyStringValues(metadata),
|
||||
'metadata object can only have string values', metadata)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
debug('setting metadata to %o for %s %s', metadata, bucket, key)
|
||||
|
||||
const params: S3.CopyObjectRequest = {
|
||||
const params: CopyObjectCommandInput = {
|
||||
Bucket: bucket,
|
||||
CopySource: `${bucket}/${key}`,
|
||||
Key: key,
|
||||
|
||||
@@ -69,9 +69,12 @@ const getPublisher = async function () {
|
||||
params: {
|
||||
Bucket: S3Configuration.bucket,
|
||||
},
|
||||
accessKeyId: aws.accessKeyId,
|
||||
secretAccessKey: aws.secretAccessKey,
|
||||
sessionToken: aws.sessionToken,
|
||||
credentials: {
|
||||
accessKeyId: aws.accessKeyId,
|
||||
secretAccessKey: aws.secretAccessKey,
|
||||
sessionToken: aws.sessionToken,
|
||||
},
|
||||
region: 'us-east-1',
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user