Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openshift_secondary_metadata_parser: Add 'version' parsing #314

Merged
merged 5 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ e2e-fixtures-capture-only:
for base in "stable"; do
for version in "4.2" "4.3"; do
for arch in "amd64" "s390x"; do
for suffix in "-production"; do
just get-graph-pe"${suffix}" "${base}-${version}" "${arch}" > {{testdata_dir}}/"$(just metadata_reference_revision)_${base}-${version}_${arch}${suffix}".json
done
just get-graph-pe "${base}-${version}" "${arch}" | hack/graph-normalize.sh > {{testdata_dir}}/"$(just metadata_reference_revision)_${base}-${version}_${arch}".json
done
done
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use self::cincinnati::plugins::prelude_plugin_impl::*;
use tokio::sync::Mutex as FuturesMutex;

pub static DEFAULT_OUTPUT_WHITELIST: &[&str] = &[
"version",
"channels/.+\\.ya+ml",
"blocked-edges/.+\\.ya+ml",
"raw/metadata.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use self::cincinnati::plugins::prelude_plugin_impl::*;
use std::collections::HashSet;

pub static DEFAULT_KEY_FILTER: &str = "io.openshift.upgrades.graph";
static SUPPORTED_VERSIONS: &[&str] = &["1.0.0"];

pub mod graph_data_model {
//! This module contains the data types corresponding to the graph data files.
Expand Down Expand Up @@ -295,6 +296,24 @@ impl OpenshiftSecondaryMetadataParserPlugin {
}
}

async fn process_version(&self, data_dir: &PathBuf) -> Fallible<String> {
let path = data_dir.join("version");
let version = tokio::fs::read(&path)
.await
.context(format!("Reading {:?}", &path))?;
let string_version = String::from_utf8_lossy(&version);

if SUPPORTED_VERSIONS.contains(&string_version.trim()) {
Ok(string_version.into_owned())
} else {
Err(format_err!(
"unrecognized graph-data version {}; supported versions: {:?}",
string_version,
SUPPORTED_VERSIONS
))
}
}

async fn process_raw_metadata(
&self,
graph: &mut cincinnati::Graph,
Expand Down Expand Up @@ -563,6 +582,7 @@ impl InternalPlugin for OpenshiftSecondaryMetadataParserPlugin {
async fn run_internal(self: &Self, mut io: InternalIO) -> Fallible<InternalIO> {
let data_dir = self.get_data_directory(&io);

self.process_version(&data_dir).await?;
self.process_raw_metadata(&mut io.graph, &data_dir).await?;
self.process_blocked_edges(&mut io.graph, &data_dir).await?;
self.process_channels(&mut io.graph, &data_dir).await?;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
5 changes: 2 additions & 3 deletions e2e/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ lazy_static::lazy_static! {
#[test_case("stable-4.3", "amd64")]
#[test_case("stable-4.3", "s390x")]
fn e2e_channel_success(channel: &'static str, arch: &'static str) {
let file_suffix = "-production";
let testdata_path = format!(
"{}/{}_{}_{}{}.json",
*TESTDATA_DIR, *METADATA_REVISION, channel, arch, file_suffix,
"{}/{}_{}_{}.json",
*TESTDATA_DIR, *METADATA_REVISION, channel, arch,
);
let testdata = &std::fs::read_to_string(&testdata_path)
.context(format!("reading {}", &testdata_path))
Expand Down

Large diffs are not rendered by default.

Loading