-
Notifications
You must be signed in to change notification settings - Fork 50
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
Code Review #30
Comments
Not sure my skills are adequite, but will be happy to help. Just let me know what part you would like me to check, and I'll do my best. |
I'm sure you'll be great! Looking through the code and where you don't understand what/why something is happening will mean I need to add addition comments. If this is going to turn into a community effort, everyone needs to understand what's going on before they can join in! |
@iainbrighton @csandfeld I am going through the Code in order to learn the approach you have used here. I would like to pitch in for this effort. |
@DexterPOSH Welcome on board! If anything matches the above criteria etc, put a #TODO , a brief comment and send a PR 😄 |
@iainbrighton I will do that. Also will try to put in how it works based on my understanding, you can later enhance it. |
OK, I will jump in on a "best effort" basis :) |
@iainbrighton The Script Analyzer rule 'PSUseSingularNouns' deals with function names, not following the the 'singular noun' best practice. In this project it throws a warning about the *-LabHostDefaults and *-LabVMDefaults functions. I can start changing them to singular nouns, but wanted to run that by you before I go down that route. What's your take on it? |
@iainbrighton The Script Analyzer rule 'PSMissingModuleManifestField' complains about a missing missing module version field in the manifest:
What's your take on that warning? Can it be ignored (as a module version has no relevance in these files), or should we add a field to make the script analyzer happy? |
This sounds like it needs to filed as an issue on the PSScriptAnalyzer GitHub page. The script analyzer is assuming that all .psd1 files are module manifests when they’re just PowerShell “data files”. The most common usage is manifests, but Import-LocalizedData requires their usage too and that’s being flagged. Therefore, I think this is a bug? |
I have no problem with renaming them to singular nouns. If we add an alias then we won’t break anything – other than the tests?! |
@iainbrighton I've been reviewing the codebase over at at fork of Dev: https://github.com/ryanspletzer/Lability Did some basic cleanup / typo fix commits. Is there a reason that xHyper-V and xPendingReboot are bundled with the repo vs. being pulled in separately from PowerShell gallery? |
@ryanspletzer And xHyper-V DSC resource is needed to provision the VMs. |
@ryanspletzer Thanks for the contribution! I'm not sure all the formatting changes are necessary, but the typos are definitely gratefully received. Send the PR and we can discuss. As for the bundled modules, they are only used internally to configure the host, virtual switches and VMs. They were originally external to the module. They have been moved internally for two main reasons:
|
@ryanspletzer Whilst we're on the subject of documentation.. As you've probably read through most of the documentation, have you noticed any glaring omissions that need to be added? |
@iainbrighton Understood on the formatting, I went a little overboard there, we don't have to include all that. :) For reference some of that comes from PowerShellPracticeAndStyle which you may be familiar with, specifically Attribute Parameters: Using =$true or Not #52 but since this would only be v4+ probably not necessary. Understood on the bundled modules now, makes sense. I took a first pass through the docs to familiarize myself with the overall project, just correcting some typo / grammatical stuff as I saw it, but I'll take another pass at it shortly and see if there's anything else that should be added / touched on. I do plan on actually running the project based on your PSHSummit-Man-vs-Testlab example to see what kinks I run into so this will probably help inform which further docs might be needed. |
@ryanspletzer If you use those examples, you will now need to change Yep - I'm aware of the style guidlines and disagree with some of it. Whilst I'm not a fan of the |
@iainbrighton Yep I worked through that rename once for the Man vs Test Lab stuff, gonna try it again here soon from my fork of that. There are pieces of the style guidelines I disagree with, too. (Max 116 chars per line?! Very tough to stick to, I've tried... And for what true purpose...) But beyond that the other thing I rolled through the files and looked at was trailing whitespace. An editor like VS Code has a setting that you can turn on to auto-trim out trailing whitespace, but the ISE most likely doesn't... |
Alrighty, I've been reading through the code, couple tiny fixes in #70 pull request (I started fresh and re-forked, left out all those crazy initial reformatting stuff I did, not necessary), I'm sure more to come. I'm using an updated fork of PSHSummit-Man-vs-Testlab with the Lability renamed stuff to test through it a bit. One issue I ran into:
The xHyper-V resource included with Lability is complaining when it calls New-VM, as New-VM just expects a System.String for SwitchName but it's being passed a System.String[]. The ConfigurationData parameter for Start-LabConfiguration pulls from a file in the PSHSummit-Man-vs-Testlab fork here: TLGVirtualEngineLab.psd1 I didn't really change that file besides the VirtualEngineLab -> Lability parameter renames. The DC1 node that it's choking on doesn't seem to have multiple switches configured (unless I'm reading it wrong), so I'm not quite sure yet where in the chain the System.String[] is getting passed to New-VM... or how best to fix it. Any ideas on if I'm doing something wrong or if something here needs fixing? |
@ryanspletzer Geez, you were mighty unlucky here. What you're seeing is a result of merging the latest xVMHyper-V DSC resources in v0.9.7 and then picking up this dsccommunity/HyperVDsc#48 bug. In the short-term you can pull in this branch (or mirror the changes in In this branch, I did spend some time updating the |
@iainbrighton I synced up my fork with #72 and gave it another go with the Man vs. Test Lab example and it worked! :) I'll work off I'll continue reviewing the code and docs and let you know if I run across anything. Thanks! |
@ryanspletzer Great to hear! Let me know if you have any further problems/questions 😃 |
@iainbrighton do you have a general idea of what still needs doing when it comes to reviewing the code? |
From memory there's the ShouldProcess support to add to the Set- and Remove- cmdlets. I've done some of them. Other than that - whatever else is flagged by the Script Analyzer.
|
I can take a stab at adding ShouldProcess to those cmdlets if I can find time for it. Any thoughts on what you would prefer ConfirmImpact set to? I see that 'SupportsShouldProcess' is added to CmdletBinding() on some of them already, but for those I checked, it did not seem to be implementet in the code (no $PSCmdlet.ShouldProcess() found). Is this on pupose? |
Thanks for volunteering :) I've left the default ConfirmImpact at medium for the time being. As for the .ShouldProcess() you'll need to test as all cmdlets in any called sub functions could prompt. If you look at the ones that have it implemented already, you should see some -Confim:$false on some nested functions/cmdlets to leave just the relevant prompts.. Does this make sense? |
Yep, I think I get what you are saying :) |
Unrelated to the above, but have been wondering for some time now. Some code is placed in the 'Src' folder, while other code is placed in the 'Lib' folder. What criteria dictates where code is placed? |
I have started adding ShouldProcess support to Remove-LabConfiguration and the called sub-cmdlets. When done I would like you to review the changes before I move on. |
No hard and fast rule. Generally, Lib contains internal/generic functions and Src are the public functions.
|
No problem =)
|
Been working a bit on ShouldProcess for Remove-LabConfiguration and sub Cmdets today. Not all done yet (need to set -Confirm:$false here and there), but when you get a couple of minutes @iainbrighton, could you look through 64325ec and see if I am on the right path here? |
No problem. I'm busy this week but will hopefully get a chance of an evening. Thanks again :)
|
More of a style thing -- I noticed in certain places [string] is used where in other places the full [System.String] is used. Other examples are [System.Management.Automation.SwitchParameter] which is used largely instead of [switch]. Is the preference in this module to use the fully qualified type names wherever possible? |
Hi @ryanspletzer - I do tend to fully qualify everything, as we can never be too explicit and it's a C# habit (just like the semicolons). That's not to say that I wouldn't accept a PR that isn't fully qualified or missing semi-colons! |
Can I ask another lame question? Line 130 in TestLabGuide.ps1, what is that commented out #Router = '10.0.0.2'; all about? Even xDhcpServer doesn't have this Router parameter documented well, and I let them know about it. |
@ryanspletzer Erm - I'm not entirely sure! It could be because the default gateway didn't work in my lab environment or (judging by dsccommunity/xDhcpServer#26) it might be because it didn't work. However, if it was the latter, I'm surprised I either didn't log an issue or fix it.. Not particularly helpful, I know 😞 |
@iainbrighton - Unless I uncomment that router parameter, I was having xDhcpServer config fail (OS 2016 Server Standard) - Sorry, didn't capture the failure from the failed run. |
@brycem Yeah - a xDhcpServer DSC resource update broke that. It was fixed, but seems that it's crept back into the latter xDhcpServer releases.. |
Not sure you still need help but I spent some time on a testlab set of scripting before finding your one which is WAAAY better. |
I just noticed that Get-WindowsImageByIndex and Get-WindowsImageByName are switched in the ps1 files (i.e. ByIndex is in ByName.ps1 and vice versa). Not a big deal, but it did confuse me for a bit. |
@MikeShepard Good spot! I'll get that corrected.. |
Before publishing to the gallery, we need to perform a code review. This should (at a minimum) cover:
The text was updated successfully, but these errors were encountered: