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

(#3201 #3225) Re-instate setting of config properties #3223

Merged
merged 2 commits into from Jun 26, 2023

Conversation

gep13
Copy link
Member

@gep13 gep13 commented Jun 22, 2023

Description Of Changes

Previously, in this commit:

da19356#diff-cb6a0471e41268b22a928bd57a59d51b70b7024e9beb30e89a330e193a089eba

The usage of the top level CacheLocation and
CommandExecutionTimeoutSeconds values had been removed, since these top
level properties within the chocolatey.config had been replaced with
values contained within the config section of the chocolatey.config
file.

However, the changes in that commit were too aggressive, and removed
the call to the set_config_item (which has subsequently been renamed to
SetConfigItem). The method call does the work of taking any value that
is defined in the chocolatey.config for a given property name, and
adding it to the ChocolateyConfiguration instance. When this method
call was removed, it stopped setting the property value on the
instance, and as a result, values that had been configured in the
chocolatey.config file were ignored. They were still in play when the
configuration was passed in via a command line option, but not when
defining them in the chocolatey.config file.

The removal of this call to the set_config_item method also explains
why it was necessary to apply this bug fix in Chocolatey GUI:

chocolatey/ChocolateyGUI#1003

The method call also had the effect of setting the description on the
configuration value, which would have meant that Chocolatey GUI
wouldn't have thrown a null reference exception. The change in
Chocolatey GUI is still valid though, as there are times when a config
value can have a missing description, so it makes sense to leave that
fix in place.

Motivation and Context

Fix a problem that was introduced when usage of the deprecated properties was removed.

Testing

  1. Clone and build the changes in this PR
  2. Install the innosetup package
  3. Verify that a .InnoInstall.log file is created in the root of the %TEMP% folder
  4. Uninstall the innosetup package
  5. Once again install the innosetup package, this time adding the --cache-location c:\choco-cache option
  6. Verify that a .InnoInstall.log file is created in the root of the c:\choco-cache folder
  7. Uninstall the innosetup package
  8. Run the command choco config set --name=cachelocation --value c:\choco-cache2
  9. Once again install the innosetup package
  10. Verify that a .InnoInstall.log file is created in the root of the c:\choco-cache2 folder
  11. Open up the file %ChocolateyInstall%\config\chocolatey.config
  12. See the top three items have descriptions

These steps are working on the assumption that setting the cache-location value to "something" then results in the TEMP environment variable being set with this value, which is then used within the innosetup package to determine where the log file is created. This previously would not have worked and the log file would never have been created in the choco-cache folder.

Operating Systems Testing

  • Windows 10

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v2 compatibility checked?

Related Issue

Fixes #3201
Fixes #3225

@gep13 gep13 requested a review from AdmiringWorm June 22, 2023 12:35
@gep13 gep13 marked this pull request as draft June 22, 2023 15:34
@gep13
Copy link
Member Author

gep13 commented Jun 22, 2023

@AdmiringWorm happy for you to review this PR, but I am now thinking that we need a separate issue to cover the changes in this PR, rather than tagging it against the original issue. Since this is a problem introduced in 2.0.0, we should cover the change in a separate issue in 2.1.0.

@gep13 gep13 changed the title (#2630) Re-instate setting of config properties (#3201 #3225) Re-instate setting of config properties Jun 23, 2023
@gep13 gep13 marked this pull request as ready for review June 23, 2023 11:31
@gep13
Copy link
Member Author

gep13 commented Jun 23, 2023

@AdmiringWorm I believe that this is now ready for review.

Previously, in this commit:

chocolatey@da19356#diff-cb6a0471e41268b22a928bd57a59d51b70b7024e9beb30e89a330e193a089eba

The usage of the top level CacheLocation and
CommandExecutionTimeoutSeconds values had been removed, since these top
level properties within the chocolatey.config had been replaced with
values contained within the config section of the chocolatey.config
file.

However, the changes in that commit were too aggressive, and removed
the call to the set_config_item (which has subsequently been renamed to
SetConfigItem).  The method call does the work of taking any value that
is defined in the chocolatey.config for a given property name, and
adding it to the ChocolateyConfiguration instance.  When this method
call was removed, it stopped setting the property value on the
instance, and as a result, values that had been configured in the
chocolatey.config file were ignored.  They were still in play when the
configuration was passed in via a command line option, but not when
defining them in the chocolatey.config file.

The removal of this call to the set_config_item method also explains
why it was necessary to apply this bug fix in Chocolatey GUI:

chocolatey/ChocolateyGUI#1003

The method call also had the effect of setting the description on the
configuration value, which would have meant that Chocolatey GUI
wouldn't have thrown a null reference exception.  The change in
Chocolatey GUI is still valid though, as there are times when a config
value can have a missing description, so it makes sense to leave that
fix in place.
$cacheArg = "--cachedir='$cacheDir'"
}
}
$Output = Invoke-Choco install test-environment --version 1.0.0 $cacheArg
Copy link
Member

Choose a reason for hiding this comment

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

@corbob just to note in case you have a need for it.

I have pushed another version of this package to the test packages repository.
It uses a non-normalized version of 0.9 (needed it for my own tests), and it also outputs environment variables during before modify, and uninstalls as well.

@corbob corbob force-pushed the cache-location-fix branch 2 times, most recently from 770e841 to b95592c Compare June 23, 2023 16:22
Make use of the test-environment package that already exists to get the
environment variables set by Chocolatey and ensure that key variables
are set as they should be.
Copy link
Member

@AdmiringWorm AdmiringWorm left a comment

Choose a reason for hiding this comment

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

LGTM

@AdmiringWorm AdmiringWorm merged commit 10a91ef into chocolatey:release/2.1.0 Jun 26, 2023
5 checks passed
@AdmiringWorm
Copy link
Member

Thanks for getting this fixed. Great work @gep13 and @corbob

@gep13 gep13 deleted the cache-location-fix branch June 28, 2023 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants