|
1 | 1 | use std::{ |
2 | 2 | collections::{BTreeMap, btree_map::Entry}, |
3 | | - fmt::Debug, |
| 3 | + fmt::{Debug, Display}, |
4 | 4 | ops::{Deref, DerefMut}, |
5 | 5 | path::PathBuf, |
6 | 6 | }; |
@@ -349,7 +349,7 @@ impl Bakefile { |
349 | 349 | image_registry, |
350 | 350 | &cli_args.registry_namespace, |
351 | 351 | &image_name, |
352 | | - &cli_args.image_version, |
| 352 | + &image_version, |
353 | 353 | &metadata.vendor_tag_prefix, |
354 | 354 | &cli_args.image_version, |
355 | 355 | cli_args.target_platform.architecture(), |
@@ -568,6 +568,7 @@ impl Bakefile { |
568 | 568 | // TODO (@Techassi): Figure out of we can use borrowed data in here. This would avoid a whole bunch |
569 | 569 | // of cloning. |
570 | 570 | #[derive(Debug, Default, Serialize)] |
| 571 | +#[serde(rename_all = "kebab-case")] |
571 | 572 | pub struct BakefileTarget { |
572 | 573 | /// Defines build arguments for the target. |
573 | 574 | #[serde( |
@@ -714,22 +715,53 @@ pub struct BakefileGroup { |
714 | 715 | targets: Vec<String>, |
715 | 716 | } |
716 | 717 |
|
717 | | -#[derive(Clone, Debug, Serialize)] |
718 | | -#[serde(tag = "type", rename_all = "lowercase")] |
| 718 | +#[derive(Clone, Debug)] |
719 | 719 | pub enum CacheStorageBackend { |
720 | 720 | Registry { |
721 | 721 | /// Full name of the cache image to import. |
722 | | - #[serde(rename = "ref")] |
723 | 722 | reference: String, |
724 | 723 |
|
725 | | - #[serde(skip_serializing_if = "Option::is_none")] |
| 724 | + /// Specifies which layers to cache |
726 | 725 | mode: Option<CacheMode>, |
727 | 726 | }, |
728 | 727 | } |
729 | 728 |
|
730 | | -#[derive(Clone, Copy, Debug, Serialize)] |
731 | | -#[serde(rename_all = "lowercase")] |
| 729 | +impl Display for CacheStorageBackend { |
| 730 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 731 | + match self { |
| 732 | + CacheStorageBackend::Registry { reference, mode } => { |
| 733 | + f.write_str("type=registry")?; |
| 734 | + f.write_fmt(format_args!(",ref={reference}"))?; |
| 735 | + |
| 736 | + if let Some(mode) = mode { |
| 737 | + f.write_fmt(format_args!(",mode={mode}"))?; |
| 738 | + } |
| 739 | + |
| 740 | + Ok(()) |
| 741 | + } |
| 742 | + } |
| 743 | + } |
| 744 | +} |
| 745 | + |
| 746 | +impl Serialize for CacheStorageBackend { |
| 747 | + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> |
| 748 | + where |
| 749 | + S: serde::Serializer, |
| 750 | + { |
| 751 | + serializer.serialize_str(&self.to_string()) |
| 752 | + } |
| 753 | +} |
| 754 | + |
| 755 | +#[derive(Clone, Copy, Debug)] |
732 | 756 | pub enum CacheMode { |
733 | 757 | // We currently only support max, because we want to cache every layer |
734 | 758 | Max, |
735 | 759 | } |
| 760 | + |
| 761 | +impl Display for CacheMode { |
| 762 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 763 | + match self { |
| 764 | + CacheMode::Max => write!(f, "max"), |
| 765 | + } |
| 766 | + } |
| 767 | +} |
0 commit comments