Skip to content

Commit a36799b

Browse files
committed
feat(k8s-sample-crds): add dummy crate to autogen sample crds
Adds crate k8s-sample-crds which, at build time, uses the utils in k8s-intf to generate json/yaml "samples" (templates) that are up-to-date with the CRD definitions in k8s-intf. Signed-off-by: Fredi Raspall <[email protected]>
1 parent 3ff6302 commit a36799b

File tree

7 files changed

+777
-3
lines changed

7 files changed

+777
-3
lines changed

Cargo.lock

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ members = [
1818
"init",
1919
"interface-manager",
2020
"k8s-intf",
21+
"k8s-sample-crds",
2122
"k8s-sample-derive",
2223
"left-right-tlcache",
2324
"mgmt",
@@ -64,6 +65,8 @@ id = { path = "./id", package = "dataplane-id", features = [] }
6465
init = { path = "./init", package = "dataplane-init", features = [] }
6566
interface-manager = { path = "./interface-manager", package = "dataplane-interface-manager", features = [] }
6667
k8s-intf = { path = "./k8s-intf", package = "dataplane-k8s-intf", features = [] }
68+
k8s-sample-crds = { path = "./k8s-sample-crds", package = "dataplane-k8s-sample-crds", features = [] }
69+
k8s-sample-derive = { path = "./k8s-sample-derive", package = "dataplane-k8s-sample-derive", features = [] }
6770
left-right-tlcache = { path = "./left-right-tlcache", package = "dataplane-left-right-tlcache", features = [] }
6871
lpm = { path = "./lpm", package = "dataplane-lpm", features = [] }
6972
mgmt = { path = "./mgmt", package = "dataplane-mgmt", features = [] }
@@ -73,7 +76,6 @@ pipeline = { path = "./pipeline", package = "dataplane-pipeline", features = []
7376
pkt-meta = { path = "./pkt-meta", package = "dataplane-pkt-meta", features = [] }
7477
rekon = { path = "./rekon", package = "dataplane-rekon", features = [] }
7578
routing = { path = "./routing", package = "dataplane-routing", features = [] }
76-
k8s-sample-derive = { path = "./k8s-sample-derive", package = "dataplane-k8s-sample-derive", features = [] }
7779
stats = { path = "./stats", package = "dataplane-stats", features = [] }
7880
sysfs = { path = "./sysfs", package = "dataplane-sysfs", features = [] }
7981
test-utils = { path = "./test-utils", package = "dataplane-test-utils", features = [] }

k8s-sample-crds/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "dataplane-k8s-sample-crds"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
publish.workspace = true
7+
repository.workspace = true
8+
9+
[dependencies]
10+
k8s-intf = { workspace = true }
11+
12+
[build-dependencies]
13+
k8s-intf = { workspace = true }

k8s-sample-crds/build.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// Copyright Open Network Fabric Authors
3+
4+
//! Autogenerated CRD sample/templates
5+
6+
use k8s_intf::samplegen::generate_samples;
7+
8+
const SAMPLES_OUT_DIR: &str = "generated-samples";
9+
const SAMPLE_FILE_NAME: &str = "sample";
10+
11+
fn main() {
12+
if let Err(e) = generate_samples(SAMPLES_OUT_DIR, SAMPLE_FILE_NAME) {
13+
eprintln!("Failed to generate CRD JSON/YAML samples: {e}");
14+
std::process::exit(1);
15+
}
16+
println!("Successfully generated CRD JSON + YAML samples in folder '{SAMPLES_OUT_DIR}'");
17+
}

0 commit comments

Comments
 (0)