-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: tedge cert create-csr should use cloud profile's CN #3316
base: main
Are you sure you want to change the base?
fix: tedge cert create-csr should use cloud profile's CN #3316
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files📢 Thoughts on this report? Let us know! |
Robot Results
|
@@ -97,7 +97,12 @@ impl BuildCommand for TEdgeCertCli { | |||
let cloud: Option<Cloud> = cloud.map(<_>::try_into).transpose()?; | |||
|
|||
// Use the current device id if no id is provided | |||
let id = id.unwrap_or(get_device_id_from_cloud(&config, &cloud)?); | |||
let id = if let Some(id) = id { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first, I wrote this line as below.
let id = id.unwrap_or(get_device_id_from_cloud(&config, &cloud)?);
However, it causes a problem when certificate doesn't exist but the id
has Some()
sinceunwrap_or()
evaluates the default always regardless of id is Some
or None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, and unwrap_or_else
, makes it so you can't use ?
from within the closure, which is a bit of a pain.
Signed-off-by: Rina Fujino <[email protected]>
…rofile Signed-off-by: Rina Fujino <[email protected]>
f9bab9b
to
5f6a6f2
Compare
@@ -97,7 +97,12 @@ impl BuildCommand for TEdgeCertCli { | |||
let cloud: Option<Cloud> = cloud.map(<_>::try_into).transpose()?; | |||
|
|||
// Use the current device id if no id is provided | |||
let id = id.unwrap_or(get_device_id_from_cloud(&config, &cloud)?); | |||
let id = if let Some(id) = id { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, and unwrap_or_else
, makes it so you can't use ?
from within the closure, which is a bit of a pain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -186,3 +191,17 @@ pub enum UploadCertCli { | |||
profile: Option<ProfileName>, | |||
}, | |||
} | |||
|
|||
fn get_device_id_from_cloud( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn get_device_id_from_cloud( | |
fn get_device_id_from_config( |
Since it's not always the id from a cloud profile but could be the main device.id
as well.
Proposed changes
tedge cert create-csr <cloud> --profile <profile>
should use the CN of the corresponding device certificate/private key if--device-id
is not provided.Types of changes
Paste Link to the issue
#3315
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments