fix: skip gcloud update step if component manager is disabled (#1237)

This commit is contained in:
Alwin
2025-07-21 15:21:29 +02:00
committed by GitHub
parent c00365c19d
commit 257d202646

View File

@@ -369,15 +369,41 @@ pub fn run_gcloud_components_update(ctx: &ExecutionContext) -> Result<()> {
let gcloud = require("gcloud")?; let gcloud = require("gcloud")?;
if gcloud.starts_with("/snap") { if gcloud.starts_with("/snap") {
Ok(()) return Ok(());
} else { }
print_separator("gcloud"); print_separator("gcloud");
ctx.run_type() let output = ctx
.execute(gcloud) .run_type()
.execute(&gcloud)
.args(["components", "update", "--quiet"]) .args(["components", "update", "--quiet"])
.status_checked() .output()?;
let output = match output {
ExecutorOutput::Wet(wet) => wet,
ExecutorOutput::Dry => return Ok(()),
};
// When `gcloud` is installed via `apt`, the components update via `apt` as well
let stderr = String::from_utf8(output.stderr)?;
if stderr.contains("You cannot perform this action because the Google Cloud CLI component manager")
&& stderr.contains("is disabled for this installation")
{
return Err(
SkipStep("The Google Cloud CLI component manager is disabled for this installation".to_string()).into(),
);
} }
// Flush captured output
std::io::stdout().write_all(&output.stdout)?;
std::io::stderr().write_all(stderr.as_bytes())?;
if !output.status.success() {
return Err(eyre!("gcloud component update failed"));
}
Ok(())
} }
pub fn run_jetpack(ctx: &ExecutionContext) -> Result<()> { pub fn run_jetpack(ctx: &ExecutionContext) -> Result<()> {