@@ -14,18 +14,29 @@ class ConfluenceSettings(BaseSettings):
14
14
"""
15
15
Contains configuration settings for the Confluence integration.
16
16
17
- Attributes:
18
- url: An optional list of Confluence URLs.
19
- token: An optional list of authentication tokens.
20
- space_key: An optional list of Confluence space keys.
21
- document_name: An optional list of document names.
22
- verify_ssl: An optional list of booleans indicating whether SSL verification is enabled.
23
- include_attachments: Indicates whether to include attachments in the integration.
24
- keep_markdown_format: Determines if markdown formatting is maintained.
25
- keep_newlines: Indicates whether newlines are preserved.
17
+ Parameters
18
+ ----------
19
+ url : CommaSeparatedStrList, optional
20
+ List of Confluence URLs.
21
+ token : CommaSeparatedStrList, optional
22
+ List of authentication tokens.
23
+ space_key : CommaSeparatedStrList, optional
24
+ List of Confluence space keys.
25
+ document_name : CommaSeparatedStrList, optional
26
+ List of document names.
27
+ verify_ssl : CommaSeparatedBoolList, optional
28
+ List of booleans indicating whether SSL verification is enabled.
29
+ include_attachments : CommaSeparatedBoolList, optional
30
+ Indicates whether to include attachments in the integration.
31
+ keep_markdown_format : CommaSeparatedBoolList, optional
32
+ Determines if markdown formatting is maintained.
33
+ keep_newlines : CommaSeparatedBoolList, optional
34
+ Indicates whether newlines are preserved.
26
35
"""
27
36
28
37
class Config :
38
+ """Config class for reading Fields from env."""
39
+
29
40
env_prefix = "CONFLUENCE_"
30
41
case_sensitive = False
31
42
@@ -41,22 +52,24 @@ class Config:
41
52
@model_validator (mode = "after" )
42
53
def check_lists_length_consistency (cls , values ):
43
54
"""
44
- Validate that all list-valued settings have the same length. If not, the list is adjusted accordingly.
55
+ Validate that all list-valued settings have the same length.
56
+
57
+ If not, the list is adjusted accordingly.
45
58
46
59
Parameters
47
60
----------
48
61
values : dict
49
- Dictionary of configuration settings. Expected to contain keys with list values.
62
+ Dictionary of configuration settings.
50
63
51
64
Returns
52
65
-------
53
66
dict
54
- The original values dict if all checked lists have the same length .
67
+ The validated values dictionary with consistent list lengths .
55
68
56
69
Raises
57
70
------
58
71
ValueError
59
- If any list has a different length compared to the others.
72
+ If any non-optional list has a different length compared to others.
60
73
"""
61
74
# Define the keys to check
62
75
keys = [
@@ -93,71 +106,65 @@ def check_lists_length_consistency(cls, values):
93
106
try :
94
107
document_name = getattr (values , "document_name" , None )
95
108
if not document_name or len (document_name ) == 0 :
96
- setattr ( values , " document_name" , CommaSeparatedStrList (["" ] * n ) )
109
+ values . document_name = CommaSeparatedStrList (["" ] * n )
97
110
elif len (document_name ) != n :
98
111
raise ValueError ("document_name list length mismatch" )
99
112
except ValueError as e :
100
113
logger .error (f"Error setting document_name: { e } " )
101
114
logger .warning ("Setting document_name to default values" )
102
115
document_name = getattr (values , "document_name" , [])
103
- setattr ( values , " document_name" , CommaSeparatedStrList (document_name + ["" ] * (n - len (document_name ) )))
116
+ values . document_name = CommaSeparatedStrList (document_name + ["" ] * (n - len (document_name )))
104
117
105
118
try :
106
119
verify_ssl = getattr (values , "verify_ssl" , None )
107
120
if not verify_ssl or len (verify_ssl ) == 0 :
108
- setattr ( values , " verify_ssl" , CommaSeparatedBoolList ([True ] * n ) )
121
+ values . verify_ssl = CommaSeparatedBoolList ([True ] * n )
109
122
elif len (verify_ssl ) != n :
110
123
raise ValueError ("verify_ssl list length mismatch" )
111
124
except ValueError as e :
112
125
logger .error (f"Error setting verify_ssl: { e } " )
113
126
logger .warning ("Setting verify_ssl to default values" )
114
127
verify_ssl = getattr (values , "verify_ssl" , [])
115
- setattr ( values , " verify_ssl" , CommaSeparatedBoolList (verify_ssl + [True ] * (n - len (verify_ssl ) )))
128
+ values . verify_ssl = CommaSeparatedBoolList (verify_ssl + [True ] * (n - len (verify_ssl )))
116
129
117
130
try :
118
131
include_attachments = getattr (values , "include_attachments" , None )
119
132
if not include_attachments or len (include_attachments ) == 0 :
120
- setattr ( values , " include_attachments" , CommaSeparatedBoolList ([False ] * n ) )
133
+ values . include_attachments = CommaSeparatedBoolList ([False ] * n )
121
134
elif len (include_attachments ) != n :
122
135
raise ValueError ("include_attachments list length mismatch" )
123
136
except ValueError as e :
124
137
logger .error (f"Error setting include_attachments: { e } " )
125
138
logger .warning ("Setting include_attachments to default values" )
126
139
include_attachments = getattr (values , "include_attachments" , [])
127
- setattr (
128
- values ,
129
- "include_attachments" ,
130
- CommaSeparatedBoolList (include_attachments + [False ] * (n - len (include_attachments ))),
140
+ values .include_attachments = CommaSeparatedBoolList (
141
+ include_attachments + [False ] * (n - len (include_attachments ))
131
142
)
132
143
133
144
try :
134
145
keep_markdown_format = getattr (values , "keep_markdown_format" , None )
135
146
if not keep_markdown_format or len (keep_markdown_format ) == 0 :
136
- setattr ( values , " keep_markdown_format" , CommaSeparatedBoolList ([True ] * n ) )
147
+ values . keep_markdown_format = CommaSeparatedBoolList ([True ] * n )
137
148
elif len (keep_markdown_format ) != n :
138
149
raise ValueError ("keep_markdown_format list length mismatch" )
139
150
except ValueError as e :
140
151
logger .error (f"Error setting keep_markdown_format: { e } " )
141
152
logger .warning ("Setting keep_markdown_format to default values" )
142
153
keep_markdown_format = getattr (values , "keep_markdown_format" , [])
143
- setattr (
144
- values ,
145
- "keep_markdown_format" ,
146
- CommaSeparatedBoolList (keep_markdown_format + [True ] * (n - len (keep_markdown_format ))),
154
+ values .keep_markdown_format = CommaSeparatedBoolList (
155
+ keep_markdown_format + [True ] * (n - len (keep_markdown_format ))
147
156
)
148
157
149
158
try :
150
159
keep_newlines = getattr (values , "keep_newlines" , None )
151
160
if not keep_newlines or len (keep_newlines ) == 0 :
152
- setattr ( values , " keep_newlines" , CommaSeparatedBoolList ([True ] * n ) )
161
+ values . keep_newlines = CommaSeparatedBoolList ([True ] * n )
153
162
elif len (keep_newlines ) != n :
154
163
raise ValueError ("keep_newlines list length mismatch" )
155
164
except ValueError as e :
156
165
logger .error (f"Error setting keep_newlines: { e } " )
157
166
logger .warning ("Setting keep_newlines to default values" )
158
167
keep_newlines = getattr (values , "keep_newlines" , [])
159
- setattr (
160
- values , "keep_newlines" , CommaSeparatedBoolList (keep_newlines + [True ] * (n - len (keep_newlines )))
161
- )
168
+ values .keep_newlines = CommaSeparatedBoolList (keep_newlines + [True ] * (n - len (keep_newlines )))
162
169
163
170
return values
0 commit comments