flycastpartnersinc / FreshservicePS

Powershell Module to interface with Freshworks Freshservice REST API.
MIT License
23 stars 5 forks source link

New-FreshServiceConnection - Fails to run on macOS (and presumably any non-Windows OS) #3

Closed Siernan closed 1 year ago

Siernan commented 1 year ago

New-FreshServiceConnection references the global variable "$FreshServiceConfigPath" (defined in FreshservicePS.psm1) which itself references "$env:APPDATA". "$env:APPDATA" is an environment variable that only exists on Windows. Since it doesn't exist, it generates the path string as "/FreshservicePS/FreshservicePS.config" which tries to write to the root directory and this fails due to permissions (as expected).

Expected Behavior

New-FreshServiceConnection runs and creates config file in appropriate directory

Current Behavior

New-FreshServiceConnection fails due to lack of $env:APPDATA directory on macOS

Possible Solution

Include logic to detect non-Windows systems and reference an appropriate environment variable to store the config file in a suitable location.

Steps to Reproduce (for bugs)

  1. Install module in PowerShell Core on macOS
  2. Run New-FreshServiceConnection cmdlet with required parameters
  3. Error occurs (due to attempting to write to the root directory)

Context

Would like to actually use the module on any system.

Your Environment

rasimmers commented 1 year ago

Code merged. Thank you for the contribution.

Siernan commented 1 year ago

Code merged. Thank you for the contribution.

No problem @rasimmers . Will you be updating it on the PSGallery as well?