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

Add OSX support for host resource #1608

Merged
merged 4 commits into from
Apr 13, 2017
Merged

Add OSX support for host resource #1608

merged 4 commits into from
Apr 13, 2017

Conversation

RyanJarv
Copy link
Contributor

  • Ping on OSX uses -W instead of -w
  • Can use nc for testing TCP connections. There is also a UDP mode for this but doesn't seem to work (and would be unreliable anyways) so following the behavior on windows here.

Signed-off-by: Ryan Gerstenkorn <ryan_gerstenkorn@fastmail.fm>
Copy link
Contributor

@adamleff adamleff left a comment

Choose a reason for hiding this comment

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

Thanks for your submission, @RyanJarv! This looks like a reasonable approach to me, and the TCP check is something we need to do for Linux as well.

We need to get your tests green, and it appears it should hopefully be as easy as fixing the parameter named for your #ping method.

@@ -93,6 +95,30 @@ def initialize(inspec)
end
end

class DarwinHostProvider < HostProvider
def ping(hostname, _port = nil, _proto = nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefixing a parameter name with an underscore is generally used to indicate that the parameter is not going to be used. Now that we're using it, we should change _proto to proto, and _port to port. This is a Rubocop check, and appears to be the reason why the Travis tests are failing for your change, as well. 🙂

@adamleff adamleff requested a review from chris-rock April 3, 2017 19:32
Copy link
Contributor

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

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

@RyanJarv Thank you for this great addition! I added a minor improvement request.

@@ -48,6 +48,8 @@ def initialize(hostname, params = {})
@host_provider = LinuxHostProvider.new(inspec)
elsif inspec.os.windows?
@host_provider = WindowsHostProvider.new(inspec)
elsif inspec.os.darwin?
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add a check for the proto and skip the resource if udp is used, since we do not support if for darwin. Same should be true for Linux but this is not related to this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just copied this behavior from the windows resource, but yeah I see what you're saying.. Going to put a skip_resource in the beginning of the initialize for UDP since this isn't supported on any platform if that makes sense.

Copy link
Contributor Author

@RyanJarv RyanJarv Apr 4, 2017

Choose a reason for hiding this comment

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

Also I kinda feel like you shouldn't really be checking for UDP remotely.. just going to lead to confusing results half the time. But that's kinda a different issue.

Signed-off-by: Ryan Gerstenkorn <ryan_gerstenkorn@fastmail.fm>
Signed-off-by: Ryan Gerstenkorn <ryan_gerstenkorn@fastmail.fm>
Signed-off-by: Ryan Gerstenkorn <ryan_gerstenkorn@fastmail.fm>
@RyanJarv
Copy link
Contributor Author

RyanJarv commented Apr 4, 2017

Thanks! Pushed a change for the variable names (guess I was looking at rake rubocop before which isn't used maybe?). Also went ahead and moved the check for UDP out to the initializer since none of the checks support it currently. Windows was just returning nil in that case rather then skipping the resource, I imagine there wasn't a good reason for that but I'm not to familiar with Inspec so correct me if I'm wrong.

Edit: nvm rake rubocop is all green now.. I must be confused

@RyanJarv
Copy link
Contributor Author

RyanJarv commented Apr 4, 2017

Looks like the travis build fail is unrelated? Not getting that running the tests locally.

@adamleff
Copy link
Contributor

adamleff commented Apr 4, 2017

@RyanJarv Yes, likely unrelated. The functional tests are a bit fragile at the moment. I've rerun the Travis job.

@adamleff adamleff merged commit 5e0cab0 into inspec:master Apr 13, 2017
@adamleff
Copy link
Contributor

Thanks for your contribution @RyanJarv!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants