Check the `X-Atomic-Min-Version` response header and warn if the current CLI version is older than the server's minimum requirement. Prints a warning to stderr when an upgrade is needed. Silently does nothing if the header is absent, unparseable, or already satisfied.
(headers: &HeaderMap)
| 48 | /// Prints a warning to stderr when an upgrade is needed. Silently does |
| 49 | /// nothing if the header is absent, unparseable, or already satisfied. |
| 50 | pub fn check_min_version_header(headers: &HeaderMap) { |
| 51 | let header_name = reqwest::header::HeaderName::from_static("x-atomic-min-version"); |
| 52 | |
| 53 | if let Some(val) = headers.get(&header_name) { |
| 54 | if let Ok(min_ver) = val.to_str() { |
| 55 | let current = crate::VERSION; |
| 56 | if needs_upgrade(current, min_ver) { |
| 57 | eprintln!( |
| 58 | "warning: this server requires Atomic CLI >= {} (you have {}). \ |
| 59 | Run 'atomic update' to upgrade.", |
| 60 | min_ver, current |
| 61 | ); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // ============================================================================ |
| 68 | // Tests |