Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

OHAI-521: Google Go language plugin #206

Closed
wants to merge 6 commits into from

4 participants

@christianvozar

Simple Ohai plugin for Google Go language compiler and toolchain.

https://tickets.opscode.com/browse/OHAI-521

@btm
Owner

Thank you for taking the time to help make Chef better! We require a Contributor License Agreement (CLA) from contributors to help protect all Chef users. It is easy to complete one online. Instructions to do so are on our wiki, which is linked below. Once your account is updated, you will have access to 'resolve' tickets that indicates to the code review team that your contribution is ready for review.

http://wiki.opscode.com/display/chef/How+to+Contribute
http://wiki.opscode.com/display/chef/Code+Review

@christianvozar

Thanks for the feedback! I am an approved contributed (https://wiki.opscode.com/display/chef/Approved+Contributors) and have opened a ticket within Jira for review.

@btm
Owner

Please see the comments on the ticket regarding the need for a unit test.

@btm
Owner
btm commented

It looks like we missed re-reviewing this. Please mark the JIRA tickets "fix provided" so that they get queued up for code review.

At the time, travis was reporting failures with the unit test that you added:

Failures:
  1) Ohai::System plugin go should get the go version
     Failure/Error: @plugin[:languages] = Mash.new
     NoMethodError:
       undefined method `[]=' for nil:NilClass
     # ./spec/unit/plugins/go_spec.rb:23:in `block (2 levels) in <top (required)>'
  2) Ohai::System plugin go should set languages[:go][:version]
     Failure/Error: @plugin[:languages] = Mash.new
     NoMethodError:
       undefined method `[]=' for nil:NilClass
     # ./spec/unit/plugins/go_spec.rb:23:in `block (2 levels) in <top (required)>'
  3) Ohai::System plugin go should not set the languages[:go] tree up if go command fails
     Failure/Error: @plugin[:languages] = Mash.new
     NoMethodError:
       undefined method `[]=' for nil:NilClass
     # ./spec/unit/plugins/go_spec.rb:23:in `block (2 levels) in <top (required)>'
@sersut
Owner

Thanks for spending time on this @christianvozar. The next step before merging this is to fix the failing specs. Let us know if you need help from our side on this.

@sersut sersut added Needs Action and removed Attack List labels
@danielsdeleo

Looks like the tests were failing because we didn't pin our rspec dependency and rspec 3 broke us. We've since fixed that, so a rebase ought to fix it. @btm is going to try rebasing the patch and re-running the tests.

@btm btm referenced this pull request
Merged

Go plugin #366

@btm
Owner

Replaced by a cherry-picked branch in #366

@btm btm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 25, 2013
  1. Google Go language plugin

    Christian Vozar authored
Commits on Nov 21, 2013
  1. @christianvozar

    Spec for Go Plugin

    christianvozar authored
Commits on Nov 22, 2013
  1. @christianvozar

    Missing require

    christianvozar authored
  2. @christianvozar

    Synxtax issue

    christianvozar authored
Commits on Jun 4, 2014
  1. @christianvozar
  2. @christianvozar

    Updated test specs

    christianvozar authored
This page is out of date. Refresh to see the latest.
View
30 lib/ohai/plugins/go.rb
@@ -0,0 +1,30 @@
+# Author:: Christian Vozar (<christian@rogueethic.com>)
+# License:: Apache License, Version 2.0
+#
+# 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.
+
+Ohai.plugin(:go) do
+ provides "languages/go"
+ depends "languages"
+
+ collect_data do
+ output = nil
+ go = Mash.new
+ so = shell_out("go version")
+ if so.exitstatus == 0
+ output = so.stdout.split
+ go[:version] = output[2].slice!(2..16)
+ languages[:go] = go if go[:version]
+ end
+ end
+end
View
30 platform_simulation_specs/plugins/go_spec.rb
@@ -0,0 +1,30 @@
+# Author:: Christian Vozar (<christian@rogueethic.com>)
+# License:: Apache License, Version 2.0
+#
+# 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.
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb'))
+require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' ))
+
+describe Ohai::System, "plugin go" do
+ test_plugin([ "languages", "go" ], [ "go" ]) do | p |
+ p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]],
+ { "languages" => { "go" => nil }})
+ p.test([ "ubuntu-13.04" ], [ "x64" ], [[]],
+ { "languages" => { "go" => nil }})
+ p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[ "go" ]],
+ { "languages" => { "go" => { "version" => "0.10.2" }}})
+ p.test([ "ubuntu-13.04" ], [ "x64" ], [[ "go" ]],
+ { "languages" => { "go" => { "version" => "0.10.2" }}})
+ end
+end
View
44 spec/unit/plugins/go_spec.rb
@@ -0,0 +1,44 @@
+# Author:: Christian Vozar (<christian@rogueethic.com>)
+# License:: Apache License, Version 2.0
+#
+# 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.
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb'))
+
+describe Ohai::System, "plugin go" do
+
+ before(:each) do
+ @plugin = get_plugin("go")
+ @plugin[:languages] = Mash.new
+ @stdout = "go version go1.1.2 darwin/amd64\n"
+ @plugin.stub(:shell_out).with("go version").and_return(mock_shell_out(0, @stdout, ""))
+ end
+
+ it "should get the go version" do
+ @plugin.should_receive(:shell_out).with("go version").and_return(mock_shell_out(0, @stdout, ""))
+ @plugin.run
+ end
+
+ it "should set languages[:go][:version]" do
+ @plugin.run
+ @plugin.languages[:go][:version].should eql("1.1.2")
+ end
+
+ it "should not set the languages[:go] tree up if go command fails" do
+ @stdout = "go version go1.1.2 darwin/amd64\n"
+ @plugin.stub(:shell_out).with("go version").and_return(mock_shell_out(1, @stdout, ""))
+ @plugin.run
+ @plugin.languages.should_not have_key(:go)
+ end
+
+end
Something went wrong with that request. Please try again.