-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updater: exposes updata functions to add migrations and updates, add/remove waves #577
Conversation
76971a2
to
9577a92
Compare
pub fn load_file(path: &Path) -> Result<Manifest> { | ||
let file = File::open(path).context(error::ManifestRead { path })?; | ||
serde_json::from_reader(file).context(error::ManifestParse) | ||
} | ||
|
||
pub fn write_file(path: &Path, manifest: &Manifest) -> Result<()> { | ||
let manifest = serde_json::to_string_pretty(&manifest).context(error::UpdateSerialize)?; | ||
fs::write(path, &manifest).context(error::ConfigWrite { path })?; | ||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should probably live in the caller (updata, unnamed-lambda-function) instead of in the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these utility functions are going to only be used for reading and writing manifest files (as in, if manifests are always going to be read/written this way with serde_json
), I feel like they can stay here close to the Manifest
struct and the rest of its methods.
Looking for more opinions on this!
Ok(_) => Ok(()), | ||
Err(e) => Err(error::Error::UpdateMetadata { source: e }), | ||
} | ||
} | ||
Command::AddUpdate(args) => args.run(), | ||
Command::AddWave(args) => args.add(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add-wave, remove-wave, and the associated validate function should also move to update_metadata as unamed-lambda-function will need them too.
@@ -88,7 +88,7 @@ where | |||
error::DuplicateVersionKey { key } | |||
); | |||
} else { | |||
return error::BadDataVersion { | |||
return error::BadVersion { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the rename here? Ohh because of the other error sourced from data_store_version. This error should still convey that we're trying to parse a data store version specifically.
@@ -15,6 +15,9 @@ serde = { version = "1.0.100", features = ["derive"] } | |||
serde_json = "1.0.40" | |||
serde_plain = "0.3.0" | |||
snafu = "0.5.0" | |||
toml = "0.5.1" | |||
tough = "0.2.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does update_metadata use tough?
#[snafu(display("Failed to write config file {}: {}", path.display(), source))] | ||
ConfigWrite { | ||
path: PathBuf, | ||
source: std::io::Error, | ||
backtrace: Backtrace, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was originally from when Updog modified its own config file; this could be rename to "ManifestWrite" for example, and update the message.
Exposes `updata` functions to add migrations, updates, add/remove waves as `Manifest` methods in the `update_metadata` library. Also tries to reconcile some duplicate errors between `updog/error.rs` and `update_metadata/error.rs`
9577a92
to
3cbc322
Compare
Addresses subset of @sam-aws 's comments:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, if we want to ensure that we're always reading from/to JSON then having the load/write methods in update_metadata seems ok.
Have you tried constructing a manifest with updata with these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍧
Tested |
Issue #, if available: Fixes #574
Description of changes:
Exposes
updata
'sadd_migration
,add_update
,add_wave
,remove_wave
functionality asManifest
methods in theupdate_metadata
library.Also tries to reconcile some duplicate errors between
updog/error.rs
andupdate_metadata/error.rs
Testing:
updog
andupdata
unit tests passRunning updata:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.