Skip to content

Commit

Permalink
identity: introspect basearch
Browse files Browse the repository at this point in the history
This introspects node basearch from rpm-ostree, instead of using
build-time configuration and the internal mapping table.
  • Loading branch information
lucab committed Jul 4, 2019
1 parent 025453b commit a9c98be
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 42 deletions.
38 changes: 0 additions & 38 deletions src/identity/basearch.rs

This file was deleted.

3 changes: 1 addition & 2 deletions src/identity/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod basearch;
mod platform;

use crate::config::inputs;
Expand Down Expand Up @@ -58,7 +57,7 @@ impl Identity {

/// Try to build default agent identity.
pub fn try_default() -> Fallible<Self> {
let basearch = basearch::read_basearch()?;
let basearch = rpm_ostree::basearch()?;
let current_os = rpm_ostree::booted().context("failed to introspect booted OS image")?;
let node_uuid = {
let app_id = id128::Id128::try_from_slice(APP_ID)
Expand Down
17 changes: 16 additions & 1 deletion src/rpm_ostree/cli_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct DeploymentJSON {
booted: bool,
#[serde(rename = "base-checksum")]
base_checksum: Option<String>,
#[serde(rename = "coreos-assembler.basearch")]
basearch: String,
checksum: String,
version: String,
}
Expand All @@ -39,8 +41,20 @@ impl DeploymentJSON {
}
}

/// Return base architecture for booted deployment.
pub fn basearch() -> Fallible<String> {
let json = booted_json()?;
Ok(json.basearch)
}

/// Find the booted deployment.
pub fn booted() -> Fallible<Release> {
let json = booted_json()?;
Ok(json.into_release())
}

/// Return JSON object for booted deployment.
fn booted_json() -> Fallible<DeploymentJSON> {
let cmd = std::process::Command::new("rpm-ostree")
.arg("status")
.arg("--json")
Expand All @@ -64,5 +78,6 @@ pub fn booted() -> Fallible<Release> {

ensure!(!booted.base_revision().is_empty(), "empty base revision");
ensure!(!booted.version.is_empty(), "empty version");
Ok(booted.into_release())
ensure!(!booted.basearch.is_empty(), "empty basearch");
Ok(booted)
}
2 changes: 1 addition & 1 deletion src/rpm_ostree/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod cli_deploy;
mod cli_finalize;
mod cli_status;
pub use cli_status::booted;
pub use cli_status::{basearch, booted};

mod actor;
pub use actor::{FinalizeDeployment, RpmOstreeClient, StageDeployment};
Expand Down

0 comments on commit a9c98be

Please sign in to comment.