Skip to content

Commit

Permalink
Update to latest omicron-zone-package
Browse files Browse the repository at this point in the history
  • Loading branch information
jgallagher committed Jun 23, 2022
1 parent 37b06f4 commit eb59617
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 73 deletions.
7 changes: 5 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion ddm-admin-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ slog = "2.7"

[build-dependencies]
anyhow = "1.0"
omicron-zone-package = "0.3.1"
progenitor = { git = "https://github.com/oxidecomputer/progenitor" }
quote = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.5"
30 changes: 2 additions & 28 deletions ddm-admin-client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,13 @@
use anyhow::bail;
use anyhow::Context;
use anyhow::Result;
use omicron_zone_package::config::Config;
use omicron_zone_package::config::ExternalPackageSource;
use quote::quote;
use serde::Deserialize;
use std::collections::BTreeMap;
use std::env;
use std::fs;
use std::path::Path;

// TODO-cleanup This is a copy/paste of (a subset of) omicron_package::Config.
// We ought to depend on it directly, but that creates a circular dependency
// between crates:
//
// us -> omicron_package -> omicron_sled_agent -> us
//
// omicron_package only depends on sled-agent for zone management; maybe that
// could be broken out into a separate crate?
#[derive(Deserialize, Debug)]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum ExternalPackageSource {
Prebuilt { repo: String, commit: String, sha256: String },
Manual,
}

#[derive(Deserialize, Debug)]
pub struct ExternalPackage {
pub source: ExternalPackageSource,
}

#[derive(Deserialize, Debug)]
pub struct Config {
#[serde(default, rename = "external_package")]
pub external_packages: BTreeMap<String, ExternalPackage>,
}

fn main() -> Result<()> {
// Find the current maghemite repo commit from our package manifest.
let manifest = fs::read("../package-manifest.toml")
Expand Down
2 changes: 1 addition & 1 deletion package/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ hex = "0.4.3"
indicatif = { version = "0.16.2", features = ["rayon"] }
omicron-common = { path = "../common" }
omicron-sled-agent = { path = "../sled-agent" }
omicron-zone-package = { version = "0.2.1" }
omicron-zone-package = "0.3.1"
rayon = "1.5"
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"] }
ring = "0.16"
Expand Down
7 changes: 4 additions & 3 deletions package/src/bin/omicron-package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ use futures::stream::{self, StreamExt, TryStreamExt};
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use omicron_package::{parse, BuildCommand, DeployCommand};
use omicron_sled_agent::zone;
use omicron_zone_package::config::Config;
use omicron_zone_package::config::ExternalPackage;
use omicron_zone_package::config::ExternalPackageSource;
use omicron_zone_package::package::Package;
use omicron_zone_package::package::Progress;
use rayon::prelude::*;
use ring::digest::{Context as DigestContext, Digest, SHA256};
use std::env;
Expand All @@ -20,9 +24,6 @@ use std::sync::Arc;
use tokio::io::{AsyncReadExt, AsyncWriteExt, BufReader};
use tokio::process::Command;

use omicron_package::{Config, ExternalPackage, ExternalPackageSource};
use omicron_zone_package::package::Progress;

/// All packaging subcommands.
#[derive(Debug, Subcommand)]
enum SubCommand {
Expand Down
38 changes: 0 additions & 38 deletions package/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
//! Common code shared between `omicron-package` and `thing-flinger` binaries.
use clap::Subcommand;
use omicron_zone_package::package::Package;
use serde::de::DeserializeOwned;
use serde_derive::Deserialize;
use std::collections::BTreeMap;
use std::path::Path;
use std::path::PathBuf;
use thiserror::Error;
Expand Down Expand Up @@ -78,38 +75,3 @@ pub enum DeployCommand {
install_dir: PathBuf,
},
}

/// Describes the origin of an externally-built package.
#[derive(Deserialize, Debug)]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum ExternalPackageSource {
/// Downloads the package from the following URL:
///
/// <https://buildomat.eng.oxide.computer/public/file/oxidecomputer/REPO/image/COMMIT/PACKAGE>
Prebuilt { repo: String, commit: String, sha256: String },
/// Expects that a package will be manually built and placed into the output
/// directory.
Manual,
}

/// Describes a package which originates from outside this repo.
#[derive(Deserialize, Debug)]
pub struct ExternalPackage {
#[serde(flatten)]
pub package: Package,

pub source: ExternalPackageSource,
}

/// Describes the configuration for a set of packages.
#[derive(Deserialize, Debug)]
pub struct Config {
/// Packages to be built and installed.
#[serde(default, rename = "package")]
pub packages: BTreeMap<String, Package>,

/// Packages to be installed, but which have been created outside this
/// repository.
#[serde(default, rename = "external_package")]
pub external_packages: BTreeMap<String, ExternalPackage>,
}

0 comments on commit eb59617

Please sign in to comment.