File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 7
7
import secrets
8
8
import string
9
9
import subprocess
10
- from typing import List
10
+ from typing import List , Optional , Union
11
11
12
12
from charms .mongodb .v0 .mongodb import MongoDBConfiguration , MongoDBConnection
13
13
from ops .model import (
29
29
30
30
# Increment this PATCH version before using `charmcraft publish-lib` or reset
31
31
# to 0 if you are raising the major API version
32
- LIBPATCH = 0
32
+ LIBPATCH = 1
33
33
34
34
# path to store mongodb ketFile
35
35
KEY_FILE = "keyFile"
@@ -267,3 +267,22 @@ def process_pbm_status(pbm_status: str) -> StatusBase:
267
267
return WaitingStatus ("waiting to sync s3 configurations." )
268
268
269
269
return ActiveStatus ()
270
+
271
+
272
+ _StrOrBytes = Union [str , bytes ]
273
+
274
+
275
+ def process_pbm_error (error_string : Optional [_StrOrBytes ]) -> str :
276
+ """Parses pbm error string and returns a user friendly message."""
277
+ message = "couldn't configure s3 backup option"
278
+ if not error_string :
279
+ return message
280
+ if type (error_string ) == bytes :
281
+ error_string = error_string .decode ("utf-8" )
282
+ if "status code: 403" in error_string : # type: ignore
283
+ message = "s3 credentials are incorrect."
284
+ elif "status code: 404" in error_string : # type: ignore
285
+ message = "s3 configurations are incompatible."
286
+ elif "status code: 301" in error_string : # type: ignore
287
+ message = "s3 configurations are incompatible."
288
+ return message
You can’t perform that action at this time.
0 commit comments