Skip to content
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

Add initial library for file resource #225

Merged
merged 9 commits into from
Oct 12, 2023

Conversation

miroman9364
Copy link
Contributor

PR Summary

  • Add code to compute checksums for SHA-1, SHA-256 and SHA-512 hash algorithms.
  • Add code to generalize checking the environment and prompting the user to attach a debugger.

PR Context

The file_lib contains the implementation for the file resource.

PR Summary

PR Context

## PR Summary

- Add code to compute checksums for SHA-1, SHA-256 and SHA-512 hash algorithms.
- Add code to generalize checking the environment and prompting the user to attach a debugger.

## PR Context
The `file_lib` contains the implementation for the `file` resource.
Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

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

add this project to build.ps1 so that it gets run by clippy pedantic

Comment on lines 21 to 43
pub fn check_debug(command: &String) {
if env::var("DEBUG_DSC").is_ok() {
let debug_args: Vec<String> = env::var(DEBUG_ENV_VAR)
.unwrap()
.split(',')
.map(|s| s.to_lowercase())
.collect();

if debug_args.contains(command) {
eprintln!(
"attach debugger to pid {} and press any key to continue",
std::process::id()
);
loop {
let event = event::read().unwrap();
if let event::Event::Key(_key) = event {
break;
}
eprintln!("Unexpected event: {event:?}");
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

We should probably pull this into it's own crate to be used by different projects within this repo, but that can be done as a separate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I wasn't sure where to put it. I didn't know if it belonged in dsc_lib or a standalone create, or something new like dsc_utils, and figured we could move it later. I have a similar refactor a function for the common code for reading STDIN.

Copy link
Member

Choose a reason for hiding this comment

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

@miroman9364 can you open an issue so we refactor that common code, probably a dsc_utils crate makes sense.

miroman9364 and others added 5 commits October 11, 2023 16:02
Refactor duplicate code to take advantage of common `Digest`

Co-authored-by: Steve Lee <slee@microsoft.com>
- added the `file_lib` project
- list of projects was getting long, so refactored onto multiple lines (sorted project names)
@miroman9364
Copy link
Contributor Author

Build file is updated, build and test clean.

Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

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

LGTM, please open issue for the refactoring discussion

There's some clippy pedantic issues you need to fix. Run build.ps1 -clippy locally

- Clippy was unhappy with names, potential panics, and moves.
- There is a key release for the enter key already buffered when the application starts; ignore this.
@miroman9364 miroman9364 added this pull request to the merge queue Oct 12, 2023
Merged via the queue into PowerShell:main with commit 5448e90 Oct 12, 2023
4 checks passed
@miroman9364 miroman9364 deleted the miroman/checksum branch October 12, 2023 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants