Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

Commit 3c577c5

Browse files
authored
Merge pull request #1139 from flavio/change-artifacthub-scaffold
feat!: change how artifacthub scaffold works
2 parents fefb2d9 + 5a864dd commit 3c577c5

File tree

6 files changed

+47
-102
lines changed

6 files changed

+47
-102
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ k8s-openapi = { version = "0.24.0", default-features = false, features = [
2323
] }
2424
lazy_static = "1.4.0"
2525
pem = "3"
26-
policy-evaluator = { git = "https://github.com/kubewarden/policy-evaluator", tag = "v0.21.0" }
26+
policy-evaluator = { git = "https://github.com/kubewarden/policy-evaluator", tag = "v0.22.0" }
2727
prettytable-rs = "^0.10"
2828
regex = "1"
2929
rustls-pki-types = { version = "1", features = ["alloc"] }

cli-docs.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,10 @@ Scaffold an AdmissionRequest object
388388

389389
Output an artifacthub-pkg.yml file from a metadata.yml file
390390

391-
**Usage:** `kwctl scaffold artifacthub [OPTIONS] --metadata-path <PATH> --version <VALUE>`
391+
**Usage:** `kwctl scaffold artifacthub [OPTIONS] --metadata-path <PATH>`
392392

393393
###### **Options:**
394394

395-
* `-t`, `--gh-release-tag <VALUE>` — Specifies the GitHub release tag of the policy. If set, this tag will be used for generating GitHub release links instead of the version.
396395
* `-m`, `--metadata-path <PATH>` — File containing the metadata of the policy
397396
* `-o`, `--output <FILE>` — Path where the artifact-pkg.yml file will be stored
398397
* `-q`, `--questions-path <PATH>` — File containing the questions-ui content of the policy

src/cli.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,19 +423,12 @@ fn subcommand_scaffold() -> Command {
423423
.value_name("PATH")
424424
.help("File containing the metadata of the policy"),
425425
Arg::new("version")
426-
.required(true)
426+
.required(false)
427427
.long("version")
428428
.short('v')
429429
.number_of_values(1)
430430
.value_name("VALUE")
431431
.help("Semver version of the policy"),
432-
Arg::new("gh-release-tag")
433-
.required(false)
434-
.long("gh-release-tag")
435-
.short('t')
436-
.number_of_values(1)
437-
.value_name("VALUE")
438-
.help("Specifies the GitHub release tag of the policy. If set, this tag will be used for generating GitHub release links instead of the version."),
439432
Arg::new("questions-path")
440433
.long("questions-path")
441434
.short('q')

src/main.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,13 @@ async fn main() -> Result<()> {
323323
.get_one::<String>("metadata-path")
324324
.map(|output| PathBuf::from_str(output).unwrap())
325325
.unwrap();
326-
let version = artifacthub_matches.get_one::<String>("version").unwrap();
327-
let gh_release_tag = artifacthub_matches
328-
.get_one::<String>("gh-release-tag")
329-
.cloned();
326+
if artifacthub_matches.get_one::<String>("version").is_some() {
327+
tracing::warn!("The 'version' flag is deprecated and will be removed in a future release. The value of the `io.kubewarden.policy.version` field in the policy metadata file is used instead.");
328+
}
330329
let questions_file = artifacthub_matches
331330
.get_one::<String>("questions-path")
332331
.map(|output| PathBuf::from_str(output).unwrap());
333-
let content = scaffold::artifacthub(
334-
metadata_file,
335-
version,
336-
gh_release_tag.as_deref(),
337-
questions_file,
338-
)?;
332+
let content = scaffold::artifacthub(metadata_file, questions_file)?;
339333
if let Some(output) = artifacthub_matches.get_one::<String>("output") {
340334
let output_path = PathBuf::from_str(output)?;
341335
fs::write(output_path, content)?;

src/scaffold/artifacthub.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ use time::OffsetDateTime;
88

99
pub(crate) fn artifacthub(
1010
metadata_path: PathBuf,
11-
version: &str,
12-
gh_release_tag: Option<&str>,
1311
questions_path: Option<PathBuf>,
1412
) -> Result<String> {
1513
let comment_header = r#"# Kubewarden Artifacthub Package config
@@ -29,13 +27,8 @@ pub(crate) fn artifacthub(
2927
})
3028
.transpose()?;
3129

32-
let kubewarden_artifacthub_pkg = ArtifactHubPkg::from_metadata(
33-
&metadata,
34-
version,
35-
gh_release_tag,
36-
OffsetDateTime::now_utc(),
37-
questions.as_deref(),
38-
)?;
30+
let kubewarden_artifacthub_pkg =
31+
ArtifactHubPkg::from_metadata(&metadata, OffsetDateTime::now_utc(), questions.as_deref())?;
3932

4033
Ok(format!(
4134
"{}\n{}",

0 commit comments

Comments
 (0)