@@ -28,11 +28,11 @@ pub struct Instance {
28
28
client : Arc < Docker >
29
29
}
30
30
31
- const RULE_REGEX : & str = "rule.(?<name>[a-z]+)" ;
31
+ const RULE_REGEX : & str = "rule\\ .(?<name>[a-z]+)" ;
32
32
const DEFAULT_RULE_REGEX : & str = "default" ;
33
33
const POLICY_NAME_REGEX : & str = "(?<policy>[a-z\\ .]+)" ;
34
34
/// Per default the schedule is set to daily at midnight
35
- const DEFAULT_SCHEDULE : & str = "0 0 * * * * *" ;
35
+ const DEFAULT_SCHEDULE : & str = "0 0 0 * * * *" ;
36
36
37
37
impl Instance {
38
38
pub fn new ( id : String , mut name : String , labels : HashMap < String , String > , networks : HashMap < String , EndpointSettings > , client : Arc < Docker > ) -> Result < Self , Error > {
@@ -129,11 +129,11 @@ impl Instance {
129
129
}
130
130
131
131
fn get_default_rule_pattern ( ) -> Regex {
132
- Regex :: new ( format ! ( "{NAME}.{DEFAULT_RULE_REGEX}.{POLICY_NAME_REGEX}" ) . as_str ( ) ) . expect ( "Default rule pattern should be valid" )
132
+ Regex :: new ( format ! ( "{NAME}\\ .{DEFAULT_RULE_REGEX}\\ .{POLICY_NAME_REGEX}" ) . as_str ( ) ) . expect ( "Default rule pattern should be valid" )
133
133
}
134
134
135
135
fn get_rule_pattern ( ) -> Regex {
136
- Regex :: new ( format ! ( "{NAME}.{RULE_REGEX}.{POLICY_NAME_REGEX}" ) . as_str ( ) ) . expect ( "Rule pattern should be valid" )
136
+ Regex :: new ( format ! ( "{NAME}\\ .{RULE_REGEX}\\ .{POLICY_NAME_REGEX}" ) . as_str ( ) ) . expect ( "Rule pattern should be valid" )
137
137
}
138
138
139
139
/// Parse all rules including the default rule from the instance configuration
@@ -167,23 +167,29 @@ impl Instance {
167
167
entry. push ( ( key, value. as_str ( ) ) )
168
168
} ) ;
169
169
170
+ debug ! ( "Rule labels {rule_labels:?}" ) ;
170
171
171
172
for ( name, labels) in rule_labels {
172
173
let is_default = default_rule_name. eq ( & name) ;
173
174
let rule = parse_rule ( name. clone ( ) , labels) ;
175
+ debug ! ( "Parsed rule {rule:?} default? {is_default}" ) ;
174
176
if let Some ( rule) = rule {
175
177
if is_default {
176
178
default_rule. tag_policies . extend ( rule. tag_policies ) ;
177
179
default_rule. repository_policies . extend ( rule. repository_policies ) ;
178
- if default_rule . schedule . is_empty ( ) {
180
+ if rule . schedule . is_empty ( ) {
179
181
default_rule. schedule = default_schedule. clone ( ) ;
182
+ } else {
183
+ default_rule. schedule = rule. schedule ;
180
184
}
181
185
} else {
182
186
rules. insert ( name, rule) ;
183
187
}
184
188
}
185
189
}
186
190
191
+ debug ! ( "Default rule {default_rule:?}" ) ;
192
+
187
193
( default_rule, rules)
188
194
}
189
195
@@ -207,6 +213,7 @@ impl Instance {
207
213
/// All tags (on repositories) which match at least one of the rules will be deleted and
208
214
/// additionally the garbage collector inside the registry will be run automatically
209
215
pub async fn apply_rules ( & self , rules : Vec < String > ) -> Result < ( ) , Error > {
216
+ debug ! ( "Applying rules to registry '{}'" , self . name) ;
210
217
let distribution = Distribution :: new ( Arc :: new ( self . distribution . clone ( ) ) ) ;
211
218
let repositories = distribution. get_repositories ( ) . await ?;
212
219
0 commit comments