Skip to content

Commit

Permalink
Merge pull request #2182 from Ruadhri17/tedge-connect-test-fix
Browse files Browse the repository at this point in the history
Fix the wrong exit code after the cloud connection test failure
  • Loading branch information
didier-wenzek authored Aug 23, 2023
2 parents 763f0a9 + 6d231b8 commit 3e37b35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
12 changes: 2 additions & 10 deletions crates/core/tedge/src/cli/connect/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,8 @@ impl Command for ConnectCommand {
println!("Connection check to {} cloud is successful.\n", cloud);
Ok(())
}
Ok(DeviceStatus::Unknown) | Err(_) => {
println!(
"Connection check to {} cloud failed.\n",
self.cloud.as_str()
);
Ok(())
}
Ok(DeviceStatus::Unknown) => Err(ConnectError::UnknownDeviceStatus.into()),
Err(err) => Err(err.into()),
};
} else {
return Err((ConnectError::DeviceNotConnected {
Expand Down Expand Up @@ -283,7 +278,6 @@ fn check_device_status_c8y(tedge_config: &TEdgeConfig) -> Result<DeviceStatus, C
Ok(DeviceStatus::Unknown)
} else {
// The request has not even been sent
println!("\nMake sure mosquitto is running.");
Err(ConnectError::TimeoutElapsedError)
}
}
Expand Down Expand Up @@ -359,7 +353,6 @@ fn check_device_status_azure(tedge_config: &TEdgeConfig) -> Result<DeviceStatus,
Ok(DeviceStatus::Unknown)
} else {
// The request has not even been sent
println!("Make sure mosquitto is running.");
Err(ConnectError::TimeoutElapsedError)
}
}
Expand Down Expand Up @@ -426,7 +419,6 @@ fn check_device_status_aws(tedge_config: &TEdgeConfig) -> Result<DeviceStatus, C
Ok(DeviceStatus::Unknown)
} else {
// The request has not even been sent
println!("Make sure mosquitto is running.");
Err(ConnectError::TimeoutElapsedError)
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/core/tedge/src/cli/connect/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ pub enum ConnectError {
#[error("Device is not connected to {cloud} cloud")]
DeviceNotConnected { cloud: String },

#[error("Unknown device status")]
UnknownDeviceStatus,

#[error(
"The JWT token received from Cumulocity is invalid.\nToken: {token}\nReason: {reason}"
)]
Expand Down

1 comment on commit 3e37b35

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
257 0 5 257 100

Please sign in to comment.