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

os_env resource returns only user's environment variable on Windows #2945

Merged

Conversation

omar-irizarry
Copy link
Contributor

Enhance os_env resource to deal with scenario explained in issue #2940

os_env resource may be called with one parameter, this keeps the current functionality

describe os_env('variablename') do
  its('content') {should eq 'content' }
end

os_env resource may be called with two parameters

describe os_env('variablename', 'target') do
  its('content') {should eq 'content' }
end

target values may be system or user

added new target parameter to os_env.
Signed-off-by: Omar J Irizarry <[email protected]>
integration tests
Signed-off-by: Omar J Irizarry <[email protected]>
Signed-off-by: Omar J Irizarry <[email protected]>
@omar-irizarry omar-irizarry requested a review from a team as a code owner April 11, 2018 13:57
Copy link
Contributor

@jquick jquick left a comment

Choose a reason for hiding this comment

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

Thanks @omar-irizarry! This is a great enhancement. Would you mind adding an example here?https://github.com/chef/inspec/blob/master/docs/resources/os_env.md.erb

Signed-off-by: Omar J Irizarry <[email protected]>
Copy link
Contributor

@clintoncwolfe clintoncwolfe left a comment

Choose a reason for hiding this comment

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

There's a conditional in there that is, um, unorthodox, but it's sounds. I tested it on win2016 on an EC2 instance, all's well. Thanks @omar-irizarry !

@osenv = env
@target = unless target.nil?
Copy link
Contributor

Choose a reason for hiding this comment

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

An inline unless with a block dual-arm if block. Yes!

@clintoncwolfe clintoncwolfe merged commit 2495fd8 into inspec:master Apr 26, 2018
@clintoncwolfe clintoncwolfe added Type: New Feature Adds new functionality Platform: Windows Windows-specific issues Component: Core Resources Resources shipped with InSpec. labels Apr 26, 2018
@omar-irizarry omar-irizarry deleted the omar-irizarry/fix-issue-2940 branch April 26, 2018 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Resources Resources shipped with InSpec. Platform: Windows Windows-specific issues Type: New Feature Adds new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants