Skip to content

Commit

Permalink
migration-helpers: add new template migrator
Browse files Browse the repository at this point in the history
This replaces ReplaceTemplateMigration with SchnauzerTemplateMigration,
which uses the new template rendering machinery to perform the same
behavior as the previous migrations.
  • Loading branch information
cbgbt committed Dec 1, 2023
1 parent 7cac449 commit 560ac62
Show file tree
Hide file tree
Showing 8 changed files with 513 additions and 41 deletions.
2 changes: 2 additions & 0 deletions sources/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions sources/api/migration/migration-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ handlebars = "4"
schnauzer = { path = "../../schnauzer", version = "0.1" }
serde = "1"
serde_json = "1"
shlex = "1"
snafu = "0.7"
tokio = { version = "~1.32", default-features = false, features = ["rt-multi-thread"] }

[dev-dependencies]
maplit = "1"
534 changes: 493 additions & 41 deletions sources/api/migration/migration-helpers/src/common_migrations.rs

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions sources/api/migration/migration-helpers/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ pub enum Error {
#[snafu(display("Unable to serialize Value: {}", source))]
Serialize { source: datastore::ScalarError },

#[snafu(display("Unable to serialize datastore for rendering templates: {}", source))]
SerializeTemplateData { source: serde_json::Error },

#[snafu(display("Unable to serialize release data: {}", source))]
SerializeRelease {
source: datastore::serialization::Error,
Expand Down Expand Up @@ -85,6 +88,12 @@ pub enum Error {
source: Box<handlebars::RenderError>,
},

#[snafu(display("Unable to render template command '{}': {}", cmdline, source))]
RenderSchnauzerV2Template {
cmdline: String,
source: schnauzer::v2::cli::CLIError,
},

#[snafu(display("'{}' is set to non-string value", setting))]
NonStringSettingDataType { setting: String },

Expand Down Expand Up @@ -119,6 +128,9 @@ pub enum Error {
path: PathBuf,
source: std::io::Error,
},

#[snafu(display("Failed to create async runtime: {}", source))]
CreateTokioRuntime { source: std::io::Error },
}

/// Result alias containing our Error type.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(deprecated)]
use migration_helpers::common_migrations::ReplaceTemplateMigration;
use migration_helpers::{migrate, Result};
use std::process;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(deprecated)]
use migration_helpers::common_migrations::ReplaceTemplateMigration;
use migration_helpers::{migrate, Result};
use std::process;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(deprecated)]
use migration_helpers::common_migrations::ReplaceTemplateMigration;
use migration_helpers::{migrate, Result};
use std::process;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(deprecated)]
use migration_helpers::common_migrations::ReplaceTemplateMigration;
use migration_helpers::{migrate, Result};
use std::process;
Expand Down

0 comments on commit 560ac62

Please sign in to comment.