Skip to content

Commit

Permalink
models: use settings SDK for models
Browse files Browse the repository at this point in the history
  • Loading branch information
cbgbt committed Jun 14, 2024
1 parent ee53570 commit 1fd7235
Show file tree
Hide file tree
Showing 180 changed files with 521 additions and 9,323 deletions.
496 changes: 193 additions & 303 deletions sources/Cargo.lock

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,6 @@ members = [
"settings-defaults/vmware-dev",
"settings-defaults/vmware-k8s-1.30",

"settings-extensions/autoscaling",
"settings-extensions/aws",
"settings-extensions/bootstrap-containers",
"settings-extensions/cloudformation",
"settings-extensions/container-registry",
"settings-extensions/container-runtime",
"settings-extensions/dns",
"settings-extensions/ecs",
"settings-extensions/host-containers",
"settings-extensions/kernel",
"settings-extensions/metrics",
"settings-extensions/motd",
"settings-extensions/network",
"settings-extensions/ntp",
"settings-extensions/oci-defaults",
"settings-extensions/oci-hooks",
"settings-extensions/pki",
"settings-extensions/updates",

"settings-plugins/aws-dev",
"settings-plugins/aws-ecs-1",
"settings-plugins/aws-ecs-2",
Expand Down
6 changes: 5 additions & 1 deletion sources/api/bootstrap-containers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ exclude = ["README.md"]
base64 = "0.21"
constants = { path = "../../constants", version = "0.1" }
log = "0.4"
modeled-types = { path = "../../models/modeled-types", version = "0.1" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
simplelog = "0.12"
snafu = "0.8"
toml = "0.8"

[dependencies.bottlerocket-modeled-types]
git = "https://github.com/cbgbt/bottlerocket-settings-sdk"
tag = "bottlerocket-settings-models-v0.1.0"
version = "0.1.0"

[build-dependencies]
generate-readme = { version = "0.1", path = "../../generate-readme" }
6 changes: 4 additions & 2 deletions sources/api/bootstrap-containers/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ use std::path::{Path, PathBuf};
use std::process::{self, Command};
use std::str::FromStr;

use modeled_types::{BootstrapContainerMode, Identifier, Url, ValidBase64};
use bottlerocket_modeled_types::{BootstrapContainerMode, Identifier, Url, ValidBase64};

const ENV_FILE_DIR: &str = "/etc/bootstrap-containers";
const DROPIN_FILE_DIR: &str = "/etc/systemd/system";
Expand Down Expand Up @@ -607,7 +607,9 @@ mod error {

// `try_from` in `BootstrapContainerMode` already returns a useful error message
#[snafu(display("Failed to parse mode: {}", source))]
BootstrapContainerMode { source: modeled_types::error::Error },
BootstrapContainerMode {
source: bottlerocket_modeled_types::error::Error,
},

#[snafu(display("'{}' failed - stderr: {}",
bin_path, String::from_utf8_lossy(&output.stderr)))]
Expand Down
6 changes: 4 additions & 2 deletions sources/api/bork/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ exclude = ["README.md"]
[dependencies]
serde_json = "1"

# generation logic moved to updates settings extension
settings-extension-updates = { path = "../../settings-extensions/updates", version = "0.1" }
[dependencies.settings-extension-updates]
git = "https://github.com/cbgbt/bottlerocket-settings-sdk"
tag = "bottlerocket-settings-models-v0.1.0"
version = "0.1.0"
6 changes: 5 additions & 1 deletion sources/api/certdog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ argh = "0.1"
base64 = "0.21"
constants = { path = "../../constants", version = "0.1" }
log = "0.4"
modeled-types = { path = "../../models/modeled-types", version = "0.1" }
serde = { version = "1.0", features = ["derive"] }
simplelog = "0.12"
snafu = "0.8"
toml = "0.8"
x509-parser = "0.16"

[dependencies.bottlerocket-modeled-types]
git = "https://github.com/cbgbt/bottlerocket-settings-sdk"
tag = "bottlerocket-settings-models-v0.1.0"
version = "0.1.0"

[dev-dependencies]
tempfile = "3"

Expand Down
6 changes: 3 additions & 3 deletions sources/api/certdog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::io::{BufRead, Seek};
use std::path::{Path, PathBuf};
use std::process;

use modeled_types::{Identifier, PemCertificateString};
use bottlerocket_modeled_types::{Identifier, PemCertificateString};

// Default location of the config file
const DEFAULT_CONFIG_FILE: &str = "/etc/certdog.toml";
Expand Down Expand Up @@ -304,12 +304,12 @@ type Result<T> = std::result::Result<T, error::Error>;
#[cfg(test)]
mod test_certdog {
use super::*;
use modeled_types::{Identifier, PemCertificateString};
use bottlerocket_modeled_types::{Identifier, PemCertificateString};
use std::collections::HashMap;
use std::convert::TryFrom;
use std::fs::File;

static TEST_PEM: &str = include_str!("../../../models/tests/data/test-pem");
static TEST_PEM: &str = include_str!("../tests/data/test-pem");

#[test]
fn bundles_splitted() {
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion sources/api/corndog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ exclude = ["README.md"]

[dependencies]
log = "0.4"
modeled-types = { path = "../../models/modeled-types", version = "0.1" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
simplelog = "0.12"
snafu = "0.8"
toml = "0.8"

[dependencies.bottlerocket-modeled-types]
git = "https://github.com/cbgbt/bottlerocket-settings-sdk"
tag = "bottlerocket-settings-models-v0.1.0"
version = "0.1.0"

[build-dependencies]
generate-readme = { version = "0.1", path = "../../generate-readme" }
2 changes: 1 addition & 1 deletion sources/api/corndog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ It sets kernel-related settings, for example:
* lockdown mode, based on the value of `settings.kernel.lockdown`
*/

use bottlerocket_modeled_types::{Lockdown, SysctlKey};
use log::{debug, error, info, trace, warn};
use modeled_types::{Lockdown, SysctlKey};
use serde::{Deserialize, Serialize};
use simplelog::{Config as LogConfig, LevelFilter, SimpleLogger};
use snafu::ResultExt;
Expand Down
6 changes: 5 additions & 1 deletion sources/api/host-containers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ exclude = ["README.md"]
base64 = "0.21"
constants = { path = "../../constants", version = "0.1" }
log = "0.4"
modeled-types = { path = "../../models/modeled-types", version = "0.1" }
serde = { version = "1", features = ["derive"] }
simplelog = "0.12"
snafu = "0.8"
toml = "0.8"

[dependencies.bottlerocket-modeled-types]
git = "https://github.com/cbgbt/bottlerocket-settings-sdk"
tag = "bottlerocket-settings-models-v0.1.0"
version = "0.1.0"

[dev-dependencies]
tempfile = "3"

Expand Down
2 changes: 1 addition & 1 deletion sources/api/host-containers/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use modeled_types::{Identifier, Url, ValidBase64};
use bottlerocket_modeled_types::{Identifier, Url, ValidBase64};
use serde::Deserialize;
use std::collections::HashMap;

Expand Down
4 changes: 2 additions & 2 deletions sources/api/host-containers/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use std::path::{Path, PathBuf};
use std::process::{self, Command};
use std::str::FromStr;

use modeled_types::Identifier;
use bottlerocket_modeled_types::Identifier;

const ENV_FILE_DIR: &str = "/etc/host-containers";
const CONFIG_FILE: &str = "/etc/host-containers/host-containers.toml";
Expand Down Expand Up @@ -496,7 +496,7 @@ fn main() {
#[cfg(test)]
mod test {
use super::*;
use modeled_types::{Identifier, Url, ValidBase64};
use bottlerocket_modeled_types::{Identifier, Url, ValidBase64};

#[test]
fn test_get_host_containers() {
Expand Down
6 changes: 5 additions & 1 deletion sources/api/pluto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ http = "0.2"
hyper = "0.14"
hyper-rustls = { version = "0.24", default-features = false, features = ["http2", "native-tokio", "tls12", "logging"] }
imdsclient = { path = "../../imdsclient", version = "0.1" }
modeled-types = { path = "../../models/modeled-types", version = "0.1" }
aws-config = "1"
aws-sdk-eks = "1"
aws-sdk-ec2 = "1"
Expand All @@ -34,5 +33,10 @@ tokio-rustls = "0.24"
url = "2"
log = "0.4.21"

[dependencies.bottlerocket-modeled-types]
git = "https://github.com/cbgbt/bottlerocket-settings-sdk"
tag = "bottlerocket-settings-models-v0.1.0"
version = "0.1.0"

[build-dependencies]
generate-readme = { version = "0.1", path = "../../generate-readme" }
4 changes: 2 additions & 2 deletions sources/api/pluto/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(crate) struct AwsK8sInfo {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) cluster_name: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) cluster_dns_ip: Option<modeled_types::KubernetesClusterDnsIp>,
pub(crate) cluster_dns_ip: Option<bottlerocket_modeled_types::KubernetesClusterDnsIp>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) node_ip: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand All @@ -44,7 +44,7 @@ pub(crate) struct Kubernetes {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) cluster_name: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) cluster_dns_ip: Option<modeled_types::KubernetesClusterDnsIp>,
pub(crate) cluster_dns_ip: Option<bottlerocket_modeled_types::KubernetesClusterDnsIp>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) node_ip: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand Down
2 changes: 1 addition & 1 deletion sources/api/pluto/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ mod hyper_proxy;
mod proxy;

use api::AwsK8sInfo;
use bottlerocket_modeled_types::KubernetesClusterDnsIp;
use imdsclient::ImdsClient;
use modeled_types::KubernetesClusterDnsIp;
use snafu::{ensure, OptionExt, ResultExt};
use std::fs::File;
use std::io::{BufRead, BufReader};
Expand Down
6 changes: 5 additions & 1 deletion sources/api/prairiedog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ bytes = "1"
constants = { path = "../../constants", version = "0.1" }
log = "0.4"
nix = "0.26"
modeled-types = { path = "../../models/modeled-types", version = "0.1" }
schnauzer = { path = "../schnauzer", version = "0.1" }
signpost = { path = "../../updater/signpost", version = "0.1" }
simplelog = "0.12"
Expand All @@ -23,6 +22,11 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.8"

[dependencies.bottlerocket-modeled-types]
git = "https://github.com/cbgbt/bottlerocket-settings-sdk"
tag = "bottlerocket-settings-models-v0.1.0"
version = "0.1.0"

[dev-dependencies]
maplit = "1"

Expand Down
4 changes: 2 additions & 2 deletions sources/api/prairiedog/src/bootconfig.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::error;
use crate::error::Result;
use crate::initrd::generate_initrd;
use modeled_types::{BootConfigKey, BootConfigValue};
use bottlerocket_modeled_types::{BootConfigKey, BootConfigValue};
use serde::{Deserialize, Serialize};
use snafu::{ensure, ResultExt};
use std::collections::HashMap;
Expand Down Expand Up @@ -352,8 +352,8 @@ mod boot_settings_tests {
boot_config_to_boot_settings_json, boot_settings_change_requires_reboot,
serialize_boot_settings_to_boot_config, DEFAULT_BOOTCONFIG_STR,
};
use bottlerocket_modeled_types::{BootConfigKey, BootConfigValue};
use maplit::hashmap;
use modeled_types::{BootConfigKey, BootConfigValue};
use serde_json::json;
use serde_json::value::Value;
use std::collections::HashMap;
Expand Down
8 changes: 6 additions & 2 deletions sources/api/prairiedog/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,17 @@ pub(super) enum Error {
InvalidBootConfig,

#[snafu(display("Failed to parse boot config key: {}", source))]
ParseBootConfigKey { source: modeled_types::error::Error },
ParseBootConfigKey {
source: bottlerocket_modeled_types::error::Error,
},

#[snafu(display("Invalid boot config value '{}'. Boot config values may only contain ASCII printable characters except for delimiters such as ';', '\n', ',', '#', and '}}'", input))]
InvalidBootConfigValue { input: String },

#[snafu(display("Failed to parse boot config value: {}", source))]
ParseBootConfigValue { source: modeled_types::error::Error },
ParseBootConfigValue {
source: bottlerocket_modeled_types::error::Error,
},

#[snafu(display("Unsupported boot config key '{}'. `BootSettings` currently only supports boot configuration for 'kernel' and 'init'", key))]
UnsupportedBootConfigKey { key: String },
Expand Down
10 changes: 10 additions & 0 deletions sources/api/schnauzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ tokio = { version = "~1.32", default-features = false, features = ["macros", "rt
toml = "0.8"
url = "2"

[dependencies.bottlerocket-modeled-types]
git = "https://github.com/cbgbt/bottlerocket-settings-sdk"
tag = "bottlerocket-settings-models-v0.1.0"
version = "0.1.0"

[dependencies.settings-extension-oci-defaults]
git = "https://github.com/cbgbt/bottlerocket-settings-sdk"
tag = "bottlerocket-settings-models-v0.1.0"
version = "0.1.0"

[dev-dependencies]
# Workaround to enable a feature during integration tests.
schnauzer = { path = ".", version = "0.1.0", features = ["testfakes"] }
Expand Down
Loading

0 comments on commit 1fd7235

Please sign in to comment.