-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* development: Update module versions for release (GH-151) Download install.ps1 to temp folder. (maint) Set pester to a max version of 4.10.1 (GH-20) add cChocoConfig resource Adding comments and tests Add pull request template (doc) Add issue template configuration (doc) Remove invalid issue template (doc) Update issue templates throw if using prerelease with minimumversion quick fixes DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 adding support for specifying minimum version
- Loading branch information
Showing
16 changed files
with
603 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: Bug Report | ||
about: Create a report to help us improve cChoco | ||
title: '' | ||
labels: 0 - _Triaging, Bug, Up For Grabs | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Software (please complete the following information):** | ||
- OS: [e.g. Windows 10 1903 Build 12345] | ||
- PowerShell Version [e.g. 5.1.123] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
blank_issues_enabled: false | ||
contact_links: | ||
- name: cChoco Community Support | ||
url: https://gitter.im/chocolatey/cchoco/ | ||
about: Please ask and answer questions here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature / Enhancement Request | ||
about: Suggest an idea for improving cChoco. | ||
title: '' | ||
labels: 0 - _Triaging, Enhancement, Up For Grabs | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!--- Please ensure you have raised an issue for discussion before creating a Pull Request --> | ||
<!--- Provide a general summary of your changes in the Title above with the format `(GH-<ISSUE #>) Title` --> | ||
|
||
## Description | ||
<!--- Describe your changes in detail --> | ||
|
||
## Related Issue | ||
<!--- This project only accepts pull requests related to open issues --> | ||
<!--- If suggesting a new feature or change, please discuss it in an issue first --> | ||
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> | ||
<!--- Please link to the issue here: --> | ||
Fixes # | ||
|
||
## Motivation and Context | ||
<!--- Why is this change required? What problem does it solve? --> | ||
|
||
## How Has This Been Tested? | ||
<!--- Please describe in detail how you tested your changes. --> | ||
<!--- Include details of your testing environment, and the tests you ran to --> | ||
<!--- see how your change affects other areas of the code, etc. --> | ||
|
||
## Screenshots (if appropriate): | ||
|
||
## Types of changes | ||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> | ||
- [ ] Bug fix (non-breaking change which fixes an issue) | ||
- [ ] New feature (non-breaking change which adds functionality) | ||
- [ ] Breaking change (fix or feature that would cause existing functionality to change) | ||
|
||
## Checklist: | ||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. --> | ||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> | ||
- [ ] My code follows the code style of this project. | ||
- [ ] My change requires a change to the documentation. | ||
- [ ] I have updated the documentation accordingly. | ||
- [ ] I have read the **CONTRIBUTING** document. | ||
- [ ] I have added tests to cover my changes. | ||
- [ ] All new and existing tests passed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
# Copyright (c) 2017 Chocolatey Software, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
<# | ||
.Description | ||
Returns the configuration for cChocoConfig. | ||
.Example | ||
Get-TargetResource -ConfigName cacheLocation -Ensure 'Present' -Value 'c:\temp\choco' | ||
#> | ||
function Get-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([Hashtable])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] | ||
[string] | ||
$ConfigName, | ||
|
||
[ValidateSet('Present','Absent')] | ||
[string] | ||
$Ensure='Present', | ||
|
||
[parameter(Mandatory = $false)] | ||
[string] | ||
$Value | ||
) | ||
|
||
Write-Verbose "Starting cChocoConfig Get-TargetResource - Config Name: $ConfigName, Ensure: $Ensure" | ||
|
||
$returnValue = @{ | ||
ConfigName = $ConfigName | ||
Ensure = $Ensure | ||
Value = $Value | ||
} | ||
|
||
$returnValue | ||
|
||
} | ||
|
||
<# | ||
.Description | ||
Performs the set for the cChocoConfig resource. | ||
.Example | ||
Set-TargetResource -ConfigName cacheLocation -Ensure 'Present' -Value 'c:\temp\choco' | ||
#> | ||
function Set-TargetResource | ||
{ | ||
[CmdletBinding(SupportsShouldProcess=$true)] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] | ||
[string] | ||
$ConfigName, | ||
|
||
[ValidateSet('Present','Absent')] | ||
[string] | ||
$Ensure='Present', | ||
|
||
[parameter(Mandatory = $false)] | ||
[string] | ||
$Value | ||
) | ||
|
||
|
||
Write-Verbose "Starting cChocoConfig Set-TargetResource - Config Name: $ConfigName, Ensure: $Ensure" | ||
|
||
if ($pscmdlet.ShouldProcess("Choco config $ConfigName will be ensured $Ensure.")) | ||
{ | ||
if ($Ensure -eq 'Present') | ||
{ | ||
Write-Verbose "Setting choco config $ConfigName." | ||
choco config set --name "'$ConfigName'" --value "'$Value'" | ||
} | ||
else | ||
{ | ||
Write-Verbose "Unsetting choco config $ConfigName." | ||
choco config unset --name "'$ConfigName'" | ||
} | ||
} | ||
|
||
} | ||
|
||
<# | ||
.Description | ||
Performs the test for cChocoFeature. | ||
.Example | ||
Test-TargetResource -ConfigName cacheLocation -Ensure 'Present' -Value 'c:\temp\choco' | ||
#> | ||
function Test-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([Boolean])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] | ||
[string] | ||
$ConfigName, | ||
|
||
[ValidateSet('Present','Absent')] | ||
[string] | ||
$Ensure='Present', | ||
|
||
[parameter(Mandatory = $false)] | ||
[string] | ||
$Value | ||
) | ||
|
||
Write-Verbose "Starting cChocoConfig Test-TargetResource - Config Name: $ConfigName, Ensure: $Ensure." | ||
|
||
# validate value is given when ensure present | ||
if ($Ensure -eq 'Present' -and (-not $PSBoundParameters.ContainsKey('Value') -or [String]::IsNullOrEmpty($Value))) { | ||
throw "Missing parameter 'Value' when ensuring config is present!" | ||
} | ||
|
||
if($env:ChocolateyInstall -eq "" -or $null -eq $env:ChocolateyInstall) | ||
{ | ||
$command = Get-Command -Name choco.exe -ErrorAction SilentlyContinue | ||
|
||
if(!$command) { | ||
throw "Unable to find choco.exe. Please make sure Chocolatey is installed correctly." | ||
} | ||
|
||
$chocofolder = Split-Path $command.Source | ||
|
||
if( $chocofolder.EndsWith("bin") ) | ||
{ | ||
$chocofolder = Split-Path $chocofolder | ||
} | ||
} | ||
else | ||
{ | ||
$chocofolder = $env:ChocolateyInstall | ||
} | ||
|
||
if(!(Get-Item -Path $chocofolder -ErrorAction SilentlyContinue)) { | ||
throw "Unable to find Chocolatey installation folder. Please make sure Chocolatey is installed and configured properly." | ||
} | ||
|
||
$configfolder = Join-Path -Path $chocofolder -ChildPath "config" | ||
$configfile = Get-ChildItem -Path $configfolder | Where-Object {$_.Name -match "chocolatey.config$"} | ||
|
||
if(!(Get-Item -Path $configfile.FullName -ErrorAction SilentlyContinue)) { | ||
throw "Unable to find Chocolatey config file. Please make sure Chocolatey is installed and configured properly." | ||
} | ||
|
||
# There is currently no choco command that only returns the settings in an CSV format. | ||
# choco config list -r shows settings, sources, features and a note about API keys. | ||
$xml = [xml](Get-Content -Path $configfile.FullName) | ||
$settings = $xml.chocolatey.config.add | ||
foreach($setting in $settings) | ||
{ | ||
# If the config name matches and it should be present, check the value and | ||
# if it matches it returns true. | ||
if($setting.key -eq $ConfigName -and $Ensure -eq 'Present') | ||
{ | ||
return ($setting.value -eq $Value) | ||
} | ||
# If the config name matches and it should be absent, check the value and | ||
# if it is null or empty, return true | ||
elseif($setting.key -eq $ConfigName -and $Ensure -eq 'Absent') | ||
{ | ||
return ([String]::IsNullOrEmpty($setting.value)) | ||
} | ||
} | ||
|
||
# If we get this far, the configuraion item hasn't been found. | ||
# There is currently no value, so return false if it should be present. | ||
# True otherwise. | ||
return !($Ensure -eq 'Present') | ||
} | ||
|
||
Export-ModuleMember -Function *-TargetResource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
[ClassVersion("1.0.0.0"), FriendlyName("cChocoConfig")] | ||
class cChocoConfig : OMI_BaseResource | ||
{ | ||
[Key] String ConfigName; | ||
[Write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] String Ensure; | ||
[Write] String Value; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.