Skip to content

Commit 4c32783

Browse files
committed
feat(module-if): Add support for conditional modules
1 parent 3c40da8 commit 4c32783

12 files changed

Lines changed: 799 additions & 37 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
# yaml-language-server: $schema=https://schema.blue-build.org/module-list-v1.json
3+
modules:
4+
- type: apt
5+
source: ghcr.io/blue-build/modules/apt:pr-523
6+
if:
7+
os-release:
8+
ID:
9+
- ubuntu
10+
- debian
11+
install:
12+
packages:
13+
- git
14+
- type: dnf
15+
if:
16+
os-release:
17+
ID:
18+
- fedora
19+
- centos
20+
- rhel
21+
install:
22+
packages:
23+
- git
24+
- type: apk
25+
source: ghcr.io/blue-build/modules/apk:pr-523
26+
if:
27+
os-release:
28+
ID: alpine
29+
install:
30+
packages:
31+
- git
32+
- type: pacman
33+
source: ghcr.io/blue-build/modules/pacman:pr-523
34+
if:
35+
os-release:
36+
ID: archlinux
37+
install:
38+
packages:
39+
- git
40+
- type: zypper
41+
source: ghcr.io/blue-build/modules/zypper:pr-523
42+
if:
43+
os-release:
44+
ID: opensuse
45+
install:
46+
packages:
47+
- git

integration-tests/test-repo/recipes/stages.yml

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,26 @@ stages:
55
from: docker.io/library/ubuntu
66
modules:
77
- from-file: stages.yml
8-
- type: apt
9-
source: ghcr.io/blue-build/modules/apt:pr-523
10-
install:
11-
packages:
12-
- git
138
- name: debian-test
149
from: docker.io/library/debian
1510
modules:
1611
- from-file: stages.yml
17-
- type: apt
18-
source: ghcr.io/blue-build/modules/apt:pr-523
19-
install:
20-
packages:
21-
- git
2212
- name: fedora-test
2313
from: docker.io/library/fedora
2414
modules:
2515
- from-file: stages.yml
26-
- type: dnf
27-
install:
28-
packages:
29-
- git
3016
- name: alpine-test
3117
from: docker.io/library/alpine
3218
modules:
3319
- from-file: stages.yml
34-
- type: apk
35-
source: ghcr.io/blue-build/modules/apk:pr-523
36-
install:
37-
packages:
38-
- git
3920
- name: arch-test
4021
from: docker.io/archlinux/archlinux
4122
modules:
4223
- from-file: stages.yml
43-
- type: pacman
44-
source: ghcr.io/blue-build/modules/pacman:pr-523
45-
install:
46-
packages:
47-
- git
4824
- name: suse-test
4925
from: docker.io/opensuse/tumbleweed
5026
modules:
5127
- from-file: stages.yml
52-
- type: zypper
53-
source: ghcr.io/blue-build/modules/zypper:pr-523
54-
install:
55-
packages:
56-
- git
5728
modules:
5829
- type: files
5930
files:
@@ -79,3 +50,4 @@ modules:
7950
- is
8051
- a
8152
- test
53+
- from-file: git.yml

recipe/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ blue-build-utils = { version = "=0.9.27", path = "../utils" }
1313

1414
cached.workspace = true
1515
colored.workspace = true
16+
comlexr.workspace = true
1617
log.workspace = true
1718
miette.workspace = true
1819
oci-client.workspace = true
@@ -23,5 +24,9 @@ serde_yaml.workspace = true
2324
serde_json.workspace = true
2425
bon.workspace = true
2526

27+
[dev-dependencies]
28+
rstest.workspace = true
29+
pretty_assertions.workspace = true
30+
2631
[lints]
2732
workspace = true

recipe/src/module.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ use serde_yaml::Value;
1313

1414
use crate::{AkmodsInfo, ModuleExt, base_recipe_path};
1515

16+
mod module_if;
1617
mod type_ver;
1718

19+
pub use module_if::*;
1820
pub use type_ver::*;
1921

2022
#[derive(Serialize, Deserialize, Debug, Clone, Builder)]
@@ -39,6 +41,10 @@ pub struct ModuleRequiredFields {
3941
#[serde(skip_serializing_if = "Vec::is_empty", default)]
4042
pub secrets: Vec<Secret>,
4143

44+
#[serde(rename = "if")]
45+
#[serde(skip_serializing_if = "Option::is_none")]
46+
pub if_check: Option<ModuleIf>,
47+
4248
#[serde(flatten)]
4349
#[builder(default, into)]
4450
pub config: IndexMap<String, Value>,

0 commit comments

Comments
 (0)