-
Notifications
You must be signed in to change notification settings - Fork 90
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
Platform framework and detect DSL #204
Changes from 1 commit
dd0b848
b4aac00
62b9d11
922a716
f7567a7
d296abc
c7ae1a2
ab3a04c
83d4aad
efdab1d
6c27336
aff0d80
83e01ab
810b3d6
7fd444d
021e6fd
1c50340
7cc0267
453a51d
98c10dd
64a0ccd
42e6dff
0425afb
babc875
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,7 @@ def scan | |
top = Train::Platforms.top_platforms | ||
top.each do |_name, plat| | ||
next unless plat.detect | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we implement a method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added the false lambda instead of the check for detect. This way everything can be evaluated accordingly. |
||
result = instance_eval(&plat.detect) | ||
next unless result == true | ||
next unless instance_eval(&plat.detect) == true | ||
|
||
# if we have a match start looking at the children | ||
plat_result = scan_children(plat) | ||
|
@@ -44,8 +43,7 @@ def scan | |
def scan_children(parent) | ||
parent.children.each do |plat, condition| | ||
next if plat.detect.nil? | ||
result = instance_eval(&plat.detect) | ||
next unless result == true | ||
next unless instance_eval(&plat.detect) == true | ||
|
||
if plat.class == Train::Platform | ||
@platform[:family] = parent.name | ||
|
@@ -60,7 +58,7 @@ def scan_children(parent) | |
end | ||
|
||
def scan_family_children(plat) | ||
child_result = scan_children(plat) if !plat.children.nil? | ||
child_result = scan_children(plat) unless plat.children.nil? | ||
return if child_result.nil? | ||
@family_hierarchy << plat.name | ||
child_result | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,14 +69,13 @@ def close | |
# nothing to do at the moment | ||
end | ||
|
||
def os | ||
platform | ||
end | ||
|
||
def platform | ||
@platform ||= Train::Platforms::Detect.scan(self) | ||
end | ||
|
||
# we need to keep os as a method for backwards compatibility with inspec | ||
alias os platform | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we do this in our base connection? This ensures that it is consistent across all connections and the implementations can focus on using platform There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we need a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be fine, if we are not going to be using BaseConnection for API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can also move it to base for now and add a os connection, once we add api |
||
|
||
def file(path) | ||
@files[path] ||=\ | ||
if os.aix? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,14 +55,13 @@ def close | |
@session = nil | ||
end | ||
|
||
def os | ||
platform | ||
end | ||
|
||
def platform | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the method calls are more similar now, we could move that to base connection too? |
||
@platform ||= Train::Platforms::Detect.scan(self) | ||
end | ||
|
||
# we need to keep os as a method for backwards compatibility with inspec | ||
alias os platform | ||
|
||
def file(path) | ||
@files[path] ||= \ | ||
if os.aix? | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really just
run_command
now, rather than uname-specific... maybe we should change the method name and that way it can be used for other things too?