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 the option to store plugin variables in an external CSV file #728

Open
monahancj opened this issue Apr 13, 2021 · 6 comments
Open

Add the option to store plugin variables in an external CSV file #728

monahancj opened this issue Apr 13, 2021 · 6 comments

Comments

@monahancj
Copy link
Contributor

The general code logic is if a CSV file exists in the plugin directory with the same name as the plugin then import the variables from the CSV file. The code snippet would go after any variable setting in the plugin.

  1. Variables in an external CSV file would take precedence over variables set in the plugin.ps1 file and not impact anyone's current environment. If a CSV file doesn't exist
  2. Upgrading becomes much easier. Variables set in a plugin's PS1 file are lost when a new version of a plugin is copied in. This method separates the data from the code.

I'll be submitting a PR linked to this issue shortly.

Code that will be added to the plugins:

# Update settings if there is a CSV file with a name matching the plugin ps1 file name.
if (Test-Path -Path (($MyInvocation).MyCommand.Source).Replace("ps1", "csv")) {
	Import-Csv (($MyInvocation).MyCommand.Source).Replace("ps1", "csv") | ForEach-Object { Set-Variable -Name $_.Name -Value $_.Value }
}

Using '10 HA Configuration Issues.ps1' as an example.

Add a CSV file in the same directory as the plugin with the same name as the plugin but with the CSV extension:
10 HA Configuration Issues.csv

Populate the CSV file:

Name,Value
ClustersDoNotInclude,"NameOfACluster|SomeOthercluster"
CLusterHAShouldBeEnabled,$true
ClusterHAHostMonitoringShouldBeEnabled,$true
ClusterHAAdmissionControlShouldBeEnabled,$true
monahancj added a commit to monahancj/vCheck-vSphere that referenced this issue Apr 13, 2021
Issue alanrenouf#728 - Add the option to store plugin variables in an external CSV file
@monahancj
Copy link
Contributor Author

If this method is approved how should the PR be structured to update the other plugins? One PR per plugin or one PR for all the plugins?

@lucdekens
Copy link
Collaborator

That feature is included in the v7 I'm still writing

@monahancj
Copy link
Contributor Author

Awesome.

Will v7 be released soon enough that it's not worth adding to the current version?

@lucdekens
Copy link
Collaborator

I don't have a fixed target date for now, I'm afraid.
If you need it now, you could continue and we could make a new branch in the current release

@Sneddo
Copy link
Collaborator

Sneddo commented Apr 14, 2021

This is possibly a good candidate for implementing in Get-vCheckSetting, although it will probably require some tweaks as we only pass the module title and setting name to the function

Luc- have you started on v7 at all? I've got a bit of time (and more importantly, working with vSphere again), so happy to help out a bit if you want?

@lucdekens
Copy link
Collaborator

Excuse me?

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

No branches or pull requests

3 participants