7
7
8
8
try :
9
9
import boto3
10
- from botocore import UNSIGNED
11
- from botocore .config import Config
12
10
13
11
S3_ENABLED = True
14
12
except ImportError :
@@ -31,8 +29,7 @@ def write(self, s):
31
29
pass
32
30
33
31
def close (self ):
34
- """Finish logging. Implementations may save or copy the log.
35
- May return a path to the saved log"""
32
+ """Finish logging. Implementations may save or copy the log."""
36
33
pass
37
34
38
35
@@ -89,7 +86,9 @@ def close(self):
89
86
# Empty log means image already exists so nothing was built
90
87
return
91
88
dest = f"{ self .keyprefix } { self .logname } "
92
- self .log .debug (f"Uploading log to { self .endpoint } key:{ self .bucket } /{ dest } " )
89
+ self .log .info (
90
+ f"Uploading log to { self .endpoint } bucket:{ self .bucket } key:{ dest } "
91
+ )
93
92
s3 = boto3 .resource (
94
93
"s3" ,
95
94
config = boto3 .session .Config (signature_version = "s3v4" ),
@@ -101,22 +100,3 @@ def close(self):
101
100
ExtraArgs = {"ContentType" : "text/plain" , "ACL" : self .acl },
102
101
)
103
102
os .remove (self ._logfile .name )
104
- return self ._get_url ()
105
-
106
- def _get_url (self ):
107
- # For simple S3 servers you can easily build the canonical URL.
108
- # For AWS S3 this can be more complicated as it depends on your region.
109
- # boto3 doesn't have a way to just get the public URL, so instead we create a pre-signed
110
- # URL but discard the parameters since the object is public.
111
- s3unsigned = boto3 .client (
112
- "s3" , config = Config (UNSIGNED ), ** self ._s3_credentials ()
113
- )
114
- link = s3unsigned .generate_presigned_url (
115
- "get_object" ,
116
- ExpiresIn = 0 ,
117
- Params = {
118
- "Bucket" : self .bucket ,
119
- "Key" : f"{ self .keyprefix } { self .logname } " ,
120
- },
121
- )
122
- return link .split ("?" , 1 )[0 ]
0 commit comments