1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
//! Migration utilities for transitioning from v0.3.x to v0.4.0 API.
//!
//! This module provides type aliases and helpers to assist with migrating
//! from the old job-centric API to the new workflow-centric API.
//!
//! # Deprecation Notices
//!
//! All type aliases in this module are deprecated and will be removed in a future version.
//! Use them only during the migration period and update your code to use the new types.
//!
//! # Quick Migration Reference
//!
//! | Old Type (v0.3.x) | New Type (v0.4.0) | Module |
//! |-------------------|-------------------|--------|
//! | `Job` | `Workflow` | `workflows` |
//! | `JobBuilder` | `WorkflowBuilder` | `workflows` |
//! | `MaestroK8sClient` | `MaestroClient` | `client` |
//!
//! # Example: Migrating Type Usage
//!
//! ```rust,no_run
//! use k8s_maestro::migration::*;
//!
//! #[allow(deprecated)]
//! fn legacy_code() {
//! // Old API - deprecated but still available for migration
//! let _client: MaestroK8sClient = todo!();
//! let _builder: JobBuilder = todo!();
//! }
//!
//! // New API - use this instead
//! fn new_code() {
//! use k8s_maestro::{MaestroClientBuilder, WorkflowBuilder};
//!
//! let _client = MaestroClientBuilder::new().build().unwrap();
//! let _builder = WorkflowBuilder::new();
//! }
//! ```
//!
//! # Migration Path
//!
//! 1. **Phase 1 - Deprecation**: Use type aliases from this module
//! 2. **Phase 2 - Transition**: Mix old and new types in the same codebase
//! 3. **Phase 3 - Completion**: Remove all deprecated type aliases
//!
//! For detailed migration guidance, see the [Migration Guide](../../docs/migration-guide.md).
pub use crateWorkflowBuilder;
/// Deprecated type alias for backward compatibility.
///
/// **Migration Path:** Replace `JobBuilder` with `WorkflowBuilder`
///
/// **Example:**
///
/// ```rust,ignore
/// // Old (deprecated)
/// let job = JobBuilder::new().with_name("my-job").build()?;
///
/// // New
/// let workflow = WorkflowBuilder::new()
/// .with_name("my-workflow")
/// .add_step(JobStep::new("step-1", "image:tag"))
/// .build()?;
/// ```
pub type JobBuilder = WorkflowBuilder;
/// Deprecated type alias for backward compatibility.
///
/// **Migration Path:** Replace `Job` with `Workflow`
///
/// **Example:**
///
/// ```rust,ignore
/// // Old (deprecated)
/// let job: Job = JobBuilder::new().build()?;
///
/// // New
/// let workflow: Workflow = WorkflowBuilder::new()
/// .add_step(JobStep::new("step-1", "image:tag"))
/// .build()?;
/// ```
pub type Job = crateWorkflow;
/// Deprecated type alias for backward compatibility.
///
/// **Migration Path:** Replace `MaestroK8sClient` with `MaestroClient` created via `MaestroClientBuilder`
///
/// **Example:**
///
/// ```rust,ignore
/// // Old (deprecated)
/// let client = MaestroK8sClient::new().await?;
///
/// // New
/// let client = MaestroClientBuilder::new()
/// .with_namespace("default")
/// .build()?;
/// ```
pub type MaestroK8sClient = crateMaestroK8sClient;
/// Deprecated type alias for backward compatibility.
///
/// **Migration Path:** Replace `JobExecutionMode` with `ExecutionMode`
///
/// **Example:**
///
/// ```rust,ignore
/// // Old (deprecated)
/// let mode = JobExecutionMode::Parallel(4);
///
/// // New
/// let mode = ExecutionMode::Parallel(4);
/// ```
pub type JobExecutionMode = crateExecutionMode;
/// Deprecated type alias for backward compatibility.
///
/// **Migration Path:** Replace `JobConfig` with `WorkflowMetadata`
///
/// **Example:**
///
/// ```rust,ignore
/// // Old (deprecated)
/// let config = JobConfig {
/// labels: labels.clone(),
/// annotations: annotations.clone(),
/// };
///
/// // New
/// let metadata = WorkflowMetadata {
/// labels,
/// annotations,
/// ..Default::default()
/// };
/// ```
pub type JobConfig = crateWorkflowMetadata;
/// Migration helper for converting old client initialization to new builder pattern.
///
/// This helper function provides a bridge between the old `MaestroK8sClient::new().await`
/// pattern and the new `MaestroClientBuilder` pattern.
///
/// **Deprecated:** This function is only for temporary migration purposes.
/// Use `MaestroClientBuilder::new().build()` directly in new code.
///
/// # Example
///
/// ```rust,no_run
/// use k8s_maestro::migration::create_legacy_client;
/// use k8s_maestro::MaestroClientBuilder;
///
/// #[allow(deprecated)]
/// async fn migrate() -> anyhow::Result<()> {
/// // Old pattern (via migration helper)
/// let client = create_legacy_client().await?;
///
/// // New pattern (use this in new code)
/// let client = MaestroClientBuilder::new()
/// .with_namespace("default")
/// .build()?;
///
/// Ok(())
/// }
/// ```
pub async
/// Migration helper for simulating old dry_run behavior with new client.
///
/// In the old API, `dry_run` was passed per-call to methods like `create_job(&job, namespace, dry_run)`.
/// In the new API, `dry_run` is configured once at client creation.
///
/// This helper allows you to create clients with different dry_run settings to simulate
/// the old per-call behavior.
///
/// **Deprecated:** This function is only for temporary migration purposes.
/// Configure dry_run at client creation time in new code.
///
/// # Example
///
/// ```rust,no_run
/// use k8s_maestro::migration::{create_dry_run_client, create_production_client};
///
/// #[allow(deprecated)]
/// async fn migrate() -> anyhow::Result<()> {
/// // Simulate old per-call dry_run pattern
/// let prod_client = create_production_client()?;
/// let dry_run_client = create_dry_run_client()?;
///
/// // Instead of: client.create_job(&job, ns, false)
/// prod_client.create_workflow(workflow)?;
///
/// // Instead of: client.create_job(&job, ns, true)
/// dry_run_client.create_workflow(workflow)?;
///
/// Ok(())
/// }
/// ```
/// Migration helper for creating a production client (dry_run = false).
///
/// **Deprecated:** Use `MaestroClientBuilder::new().build()` directly.
/// Migration helper for converting namespace parameter from old API calls.
///
/// In the old API, namespace was passed per-call: `client.create_job(&job, namespace, dry_run)`.
/// In the new API, namespace is configured once at client creation.
///
/// This helper creates clients with different namespaces to simulate the old per-call behavior.
///
/// **Deprecated:** Configure namespace at client creation time in new code.
///
/// # Example
///
/// ```rust,no_run
/// use k8s_maestro::migration::create_client_for_namespace;
///
/// #[allow(deprecated)]
/// async fn migrate() -> anyhow::Result<()> {
/// // Old pattern: client.create_job(&job, "default", false)
/// let default_client = create_client_for_namespace("default")?;
///
/// // Old pattern: client.create_job(&job, "production", false)
/// let prod_client = create_client_for_namespace("production")?;
///
/// Ok(())
/// }
/// ```
/// Migration macro for suppressing deprecation warnings during migration.
///
/// Use this macro to temporarily suppress deprecation warnings while migrating
/// code from the old API to the new API.
///
/// # Example
///
/// ```rust,ignore
/// use k8s_maestro::migration::allow_deprecated;
///
/// allow_deprecated! {
/// let client = MaestroK8sClient::new().await?;
/// let job = JobBuilder::new().build()?;
/// }
///
/// // Later, update to new API:
/// let client = MaestroClientBuilder::new().build()?;
/// let workflow = WorkflowBuilder::new()
/// .add_step(JobStep::new("step-1", "image:tag"))
/// .build()?;
/// ```
/// Migration checklist trait for tracking migration progress.
///
/// Implement this trait for your migration tests to ensure all migration
/// steps have been completed.
///
/// # Example
///
/// ```rust,ignore
/// use k8s_maestro::migration::MigrationChecklist;
///
/// struct MyMigrationTests;
///
/// impl MigrationChecklist for MyMigrationTests {
/// fn completed_steps() -> Vec<&'static str> {
/// vec![
/// "Updated imports",
/// "Migrated client creation",
/// "Replaced Job with Workflow",
/// "Moved dry_run to client builder",
/// ]
/// }
/// }
/// ```