joel74 / POSH-LTM-Rest

PowerShell module and scripts for working with F5's LTM REST API
MIT License
78 stars 48 forks source link

Do not export Private\*.ps1 functions #37

Closed vercellone closed 8 years ago

vercellone commented 8 years ago

Private*.ps1 functions are being exported, but should not be. Reference PR #36

dsolodow commented 8 years ago

I see two ways to accomplish this: 1) modify the .psm1 file only to export Public functions (http://ramblingcookiemonster.github.io/Building-A-PowerShell-Module/) 2) list the public functions in 'FunctionsToExport' in the module manifest.

Option 1 has the advantage of being a one and done, whereas 2 would require a manifest update when the cmdlet list changes. Option 2 has the advantage of fixing auto-load; currently if you try say a Get-F5Session without first importing the module it fails; 2 would fix this.

vercellone commented 8 years ago

Great stuff from @RamblingCookieMonster as usual.

I like the one and done benefit of option 1, but option 2 is probably the better long term choice.

dsolodow commented 8 years ago

@joel74, which is your preference? I'm inclined to option 2 as well, but figured would ask as you're the core dev. Once we know, I'll make the mods and a PR.

joel74 commented 8 years ago

@dsolodow, my one concern with Option 2 is that it's a manual process. What happens if a function gets missed? How would we know without doing a visual compare? RamblingCookieMonster mentions exporting $Public.Basename to dynamically get the list of public functions while the module is in active development, and it feels like that's where this module currently is. I could live with either option, though.

RamblingCookieMonster commented 8 years ago

You could theoretically have a build process (e.g. maybe hosted on AppVeyor) that reads your public functions and updates the psd1? You would get the benefits of having the functions hard coded in the psd1, without having to manually update it.

Cheers!

vercellone commented 8 years ago

Perfect. Best of both worlds. I already have a draft appveyor.yml file to run PSScriptAnalyzer and publish the module based on http://ramblingcookiemonster.github.io/Building-A-PowerShell-Module/. I'll incorporate this feature.

vercellone commented 8 years ago

@joel74 I can do a proof of concept on my fork, but ultimately you'd have to register and configure appveyor for this repository. Do you foresee any problems with that?

joel74 commented 8 years ago

I haven't used appveyor before, but I don't think it will be a problem to set it up.

vercellone commented 8 years ago

Look over appveyor.yml and the build results and let me know what you think. If you don't want to publish to powershellgallery, then I'll want to tweak the zip artifact contents so they don't include the .git\ folder nor the appveyor.yml file itself.

If you are willing to publish to PowerShell Gallery (and, i hope that you are), then I'd rather pursue that and forego the zip artifact altogether.

joel74 commented 8 years ago

I've published to the gallery, not every commit but fairly regularly, so that's fine. I'd like it to be published automatically. Does appveyor need to hook up with the existing module in the gallery? I'll check out the appveyor stuff soon.

vercellone commented 8 years ago

Publishing is as simple as:

Publish-Module -Name 'F5-LTM Module' -NuGetApiKey '[Your API Key]'
  1. [View your PowerShell Gallery profile]() to get your API Key.
  2. Encrypt it, so you can safely include the encrypted value in the appveyor.yml file.

Tip: I highly recommend AppVeyor's Validate YAML configuration form.

joel74 commented 8 years ago

Cool. So you're saying that if we publish to PSGallery, you'll remove the .7zip portion? I see where it's calling msiexec - what's the role of nuget.exe?

Does appveyor handle versioning? I know that PSGallery requires a version bump every time one publishes. The encrypted API key value is: secure: NvJlPynne4N7tJ/8DM2LFAKoZu5v9e35PvbAJNOCiXbXJRHrJ+OetTQsO/bYjNo5

vercellone commented 8 years ago
vercellone commented 8 years ago
joel74 commented 8 years ago

I'd like to move the module back into a folder named 'F5-LTM' as that will sync up with the published module in the PowerShell gallery. Any reason not to? It looks like I can't use the -name param when publishing to PSGallery from a github repo - it just takes the name from the path and uses that.

vercellone commented 8 years ago

Sounds good.

vercellone commented 8 years ago

dbb5410 of PR #43 fixes #40

The delimiter was wrong, so no Functions at all were exported. Fixing the delimiters should work. After import of the latest module from PSGallery, the following command should not include the private functions:

Get-Command | ? Source -eq 'f5-ltm' 
vercellone commented 8 years ago

This issue can be closed based on version 1.3.14.

joel74 commented 8 years ago

Confirmed