Skip to content

Commit

Permalink
Merge pull request #549 from amazonlinux/model-more
Browse files Browse the repository at this point in the history
Add modeled types for URLs and Kubernetes resources
  • Loading branch information
tjkirch authored Nov 21, 2019
2 parents 4dcda39 + 4687590 commit 5b91ec5
Show file tree
Hide file tree
Showing 4 changed files with 447 additions and 16 deletions.
3 changes: 3 additions & 0 deletions workspaces/Cargo.lock

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

9 changes: 6 additions & 3 deletions workspaces/api/apiserver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ build = "build.rs"
[dependencies]
actix-web = { version = "1.0.5", default-features = false, features = ["uds"] }
base64 = "0.10"
lazy_static = "1.2"
libc = "0.2"
log = "0.4"
nix = "0.15.0"
percent-encoding = "2.1"
regex = "1.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
simplelog = "0.7"
snafu = "0.5"
systemd = { version = "0.4.0", default-features = false, features = [], optional = true }
toml = "0.5"
url = "2.1"
walkdir = "2.2"
systemd = { version = "0.4.0", default-features = false, features = [], optional = true }
nix = "0.15.0"
libc = "0.2"

[features]
default = ["sd_notify"]
Expand Down
21 changes: 12 additions & 9 deletions workspaces/api/apiserver/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::net::Ipv4Addr;

use crate::modeled_types::{SingleLineString, ValidBase64, Identifier};
use crate::modeled_types::{
Identifier, KubernetesClusterName, KubernetesLabelKey, KubernetesLabelValue,
KubernetesTaintValue, SingleLineString, Url, ValidBase64,
};

///// Primary user-visible settings

Expand Down Expand Up @@ -47,19 +50,19 @@ pub struct KubernetesSettings {
// Settings we require the user to specify, likely via user data.

#[serde(skip_serializing_if = "Option::is_none")]
pub cluster_name: Option<SingleLineString>,
pub cluster_name: Option<KubernetesClusterName>,

#[serde(skip_serializing_if = "Option::is_none")]
pub cluster_certificate: Option<ValidBase64>,

#[serde(skip_serializing_if = "Option::is_none")]
pub api_server: Option<SingleLineString>,
pub api_server: Option<Url>,

#[serde(skip_serializing_if = "Option::is_none")]
pub node_labels: Option<HashMap<SingleLineString, SingleLineString>>,
pub node_labels: Option<HashMap<KubernetesLabelKey, KubernetesLabelValue>>,

#[serde(skip_serializing_if = "Option::is_none")]
pub node_taints: Option<HashMap<SingleLineString, SingleLineString>>,
pub node_taints: Option<HashMap<KubernetesLabelKey, KubernetesTaintValue>>,

// Dynamic settings.

Expand All @@ -82,10 +85,10 @@ pub struct KubernetesSettings {
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub struct UpdatesSettings {
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata_base_url: Option<SingleLineString>,
pub metadata_base_url: Option<Url>,

#[serde(skip_serializing_if = "Option::is_none")]
pub target_base_url: Option<SingleLineString>,
pub target_base_url: Option<Url>,

#[serde(skip_serializing_if = "Option::is_none")]
pub seed: Option<u32>,
Expand All @@ -95,7 +98,7 @@ pub struct UpdatesSettings {
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub struct ContainerImage {
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option<SingleLineString>,
pub source: Option<Url>,

#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
Expand All @@ -109,7 +112,7 @@ pub struct ContainerImage {
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub struct NtpSettings {
#[serde(skip_serializing_if = "Option::is_none")]
pub time_servers: Option<Vec<SingleLineString>>,
pub time_servers: Option<Vec<Url>>,
}

///// Internal services
Expand Down
Loading

0 comments on commit 5b91ec5

Please sign in to comment.