|
56 | 56 | type: str |
57 | 57 | time_machine_expiration: |
58 | 58 | description: |
59 | | - - The amount of time, after a tag is deleted, that the tag is accessible |
| 59 | + - After a tag is deleted, the amount of time in seconds it is kept |
60 | 60 | in time machine before being garbage collected. |
| 61 | + - The O(time_machine_expiration) parameter accepts a time unit as a |
| 62 | + suffix; C(s) for seconds, C(m) for minutes, C(h) for hours, C(d) for |
| 63 | + days, and C(w) for weeks. For example, C(2w) for two weeks. |
| 64 | + - Only the expiration times that your Quay administrator declares in |
| 65 | + C(config.yaml) with the C(TAG_EXPIRATION_OPTIONS) option are allowed. |
| 66 | + The default value for the C(TAG_EXPIRATION_OPTIONS) option is C(0s), |
| 67 | + C(1d), C(1w), C(2w), and C(4w). |
61 | 68 | type: str |
62 | | - choices: [0s, 1d, 7d, 14d, 1month] |
63 | 69 | state: |
64 | 70 | description: |
65 | 71 | - If V(absent), then the module deletes the organization. |
|
72 | 78 | default: present |
73 | 79 | choices: [absent, present] |
74 | 80 | notes: |
| 81 | + - To use the O(time_machine_expiration) parameter, your Quay administrator |
| 82 | + must set C(FEATURE_CHANGE_TAG_EXPIRATION) to C(true), which is the default, |
| 83 | + in C(config.yaml). |
75 | 84 | - The token that you provide in O(quay_token) must have the "Administer |
76 | 85 | Organization" and "Administer User" permissions. |
77 | 86 | - To rename organizations, the token must also have the "Super User Access" |
|
96 | 105 | infra.quay_configuration.quay_organization: |
97 | 106 | name: production |
98 | 107 | email: prodlist@example.com |
99 | | - time_machine_expiration: "7d" |
| 108 | + time_machine_expiration: 1w |
100 | 109 | state: present |
101 | 110 | quay_host: https://quay.example.com |
102 | 111 | quay_token: vgfH9zH5q6eV16Con7SvDQYSr0KPYQimMHVehZv7 |
|
125 | 134 |
|
126 | 135 |
|
127 | 136 | def main(): |
128 | | - tm_allowed_values = { |
129 | | - "0s": 0, |
130 | | - "1d": 86400, |
131 | | - "7d": 604800, |
132 | | - "14d": 1209600, |
133 | | - "1month": 2419200, |
134 | | - } |
135 | 137 | argument_spec = dict( |
136 | 138 | name=dict(required=True), |
137 | 139 | new_name=dict(), |
138 | 140 | email=dict(), |
139 | | - time_machine_expiration=dict(choices=list(tm_allowed_values.keys())), |
| 141 | + time_machine_expiration=dict(), |
140 | 142 | auto_prune_method=dict( |
141 | 143 | choices=["none", "tags", "date"], |
142 | 144 | removed_at_date="2025-12-01", |
@@ -200,6 +202,14 @@ def main(): |
200 | 202 | ) |
201 | 203 | auto_prune_value = value |
202 | 204 |
|
| 205 | + # Verify that the expiration is valid and convert it to an integer (seconds) |
| 206 | + # Even though the user might provide a valid value, the API will rejects the |
| 207 | + # value if it is not in the TAG_EXPIRATION_OPTIONS array (in config.yaml) |
| 208 | + if tm_expiration: |
| 209 | + tag_expiration_s = module.str_period_to_second( |
| 210 | + "time_machine_expiration", tm_expiration |
| 211 | + ) |
| 212 | + |
203 | 213 | org_details = module.get_organization(name) |
204 | 214 | new_org_details = module.get_organization(new_name) if new_name else None |
205 | 215 |
|
@@ -286,7 +296,7 @@ def main(): |
286 | 296 | # Prepare the data that gets set for update |
287 | 297 | new_fields = {} |
288 | 298 | if tm_expiration: |
289 | | - new_fields["tag_expiration_s"] = tm_allowed_values[tm_expiration] |
| 299 | + new_fields["tag_expiration_s"] = tag_expiration_s |
290 | 300 | if email: |
291 | 301 | new_fields["email"] = email |
292 | 302 |
|
|
0 commit comments