Skip to content

Commit 1af4353

Browse files
authored
Derive Serialize for Config (#74)
I have a tool that writes out package manifests, so I'd like to upstream this derivation :)
1 parent 92f3b32 commit 1af4353

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/config/imp.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use crate::package::{Package, PackageOutput, PackageSource};
88
use crate::target::TargetMap;
99
use serde_derive::Deserialize;
10+
use serde_derive::Serialize;
1011
use std::collections::BTreeMap;
1112
use std::path::Path;
1213
use thiserror::Error;
@@ -101,7 +102,7 @@ impl<'a> Iterator for PackageDependencyIter<'a> {
101102
}
102103

103104
/// Describes the configuration for a set of packages.
104-
#[derive(Clone, Deserialize, Debug)]
105+
#[derive(Clone, Deserialize, Serialize, Debug)]
105106
pub struct Config {
106107
/// Packages to be built and installed.
107108
#[serde(default, rename = "package")]
@@ -139,7 +140,7 @@ impl Config {
139140
}
140141

141142
/// Configuration for targets, including preset configuration.
142-
#[derive(Clone, Deserialize, Debug, Default)]
143+
#[derive(Clone, Deserialize, Serialize, Debug, Default)]
143144
pub struct TargetConfig {
144145
/// Preset configuration for targets.
145146
#[serde(default, rename = "preset")]

src/package.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub struct PrebuiltBlob {
7878
}
7979

8080
/// Describes the origin of an externally-built package.
81-
#[derive(Clone, Deserialize, Debug, PartialEq)]
81+
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)]
8282
#[serde(tag = "type", rename_all = "lowercase")]
8383
pub enum PackageSource {
8484
/// Describes a package which should be assembled locally.
@@ -149,7 +149,7 @@ impl PackageSource {
149149
}
150150

151151
/// Describes the output format of the package.
152-
#[derive(Deserialize, Debug, Clone, PartialEq)]
152+
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
153153
#[serde(tag = "type", rename_all = "lowercase")]
154154
pub enum PackageOutput {
155155
/// A complete zone image, ready to be deployed to the target.
@@ -166,7 +166,7 @@ pub enum PackageOutput {
166166
}
167167

168168
/// A single package.
169-
#[derive(Clone, Deserialize, Debug, PartialEq)]
169+
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)]
170170
pub struct Package {
171171
/// The name of the service name to be used on the target OS.
172172
pub service_name: ServiceName,
@@ -840,7 +840,7 @@ impl Package {
840840
}
841841

842842
/// Describes configuration for a package which contains a Rust binary.
843-
#[derive(Clone, Deserialize, Debug, PartialEq)]
843+
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)]
844844
pub struct RustPackage {
845845
/// The name of the compiled binary to be used.
846846
// TODO: Could be extrapolated to "produced build artifacts", we don't
@@ -864,7 +864,7 @@ impl RustPackage {
864864
}
865865

866866
/// A string which can be modified with key-value pairs.
867-
#[derive(Clone, Deserialize, Debug, PartialEq)]
867+
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)]
868868
pub struct InterpolatedString(String);
869869

870870
impl InterpolatedString {
@@ -903,7 +903,7 @@ impl InterpolatedString {
903903
///
904904
/// These paths may require target-specific interpretation before being
905905
/// transformed to an actual [MappedPath].
906-
#[derive(Clone, Deserialize, Debug, PartialEq)]
906+
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)]
907907
pub struct InterpolatedMappedPath {
908908
/// Source path.
909909
pub from: InterpolatedString,

src/target.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
use crate::package::Package;
66
use serde::Deserialize;
7+
use serde::Serialize;
78
use std::collections::BTreeMap;
89

910
/// Describes what platform and configuration we're trying to deploy on.
1011
///
1112
/// For flexibility, this is an arbitrary key-value map without any attached
1213
/// semantics to particular keys. Those semantics are provided by the consumers
1314
/// of this tooling within omicron.
14-
#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
15+
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
1516
#[serde(transparent)]
1617
pub struct TargetMap(pub BTreeMap<String, String>);
1718

0 commit comments

Comments
 (0)