Skip to content

Commit 967fce0

Browse files
committed
refactor 'latest_release' and address PR feedback
1 parent e6f73ca commit 967fce0

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

rust/stackable-cockpit/src/platform/release/spec.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ impl ReleaseSpec {
130130
}
131131

132132
impl ReleaseList {
133+
/// Checks if a value provided in the '--release' argument is in the release list
134+
pub fn contains(&self, release: &str) -> bool {
135+
self.inner().contains_key(release)
136+
}
137+
133138
/// Retrieves the latest release from the list and applies a sanity check to the release format.
134139
pub fn latest_release(&self) -> Result<String, Error> {
135140
let release = self.inner().first().context(EmptyReleaseListSnafu)?.0;

rust/stackablectl/src/cmds/demo.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ impl DemoArgs {
173173

174174
let release_branch = match &self.release {
175175
Some(release) => {
176+
if !release_list.contains(release) {
177+
return NoSuchReleaseSnafu { name: release }.fail();
178+
}
176179
if release == "dev" {
177180
"main".to_string()
178181
} else {

rust/stackablectl/src/cmds/stack.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ pub enum CmdError {
120120
#[snafu(display("failed to serialize JSON output"))]
121121
SerializeJsonOutput { source: serde_json::Error },
122122

123+
#[snafu(display("no release with name '{name}'"))]
124+
NoSuchRelease { name: String },
125+
123126
#[snafu(display("failed to get latest release"))]
124127
LatestRelease { source: platform::release::Error },
125128

@@ -155,6 +158,9 @@ impl StackArgs {
155158

156159
let release_branch = match &self.release {
157160
Some(release) => {
161+
if !release_list.contains(release) {
162+
return NoSuchReleaseSnafu { name: release }.fail();
163+
}
158164
if release == "dev" {
159165
"main".to_string()
160166
} else {

0 commit comments

Comments
 (0)