зеркало из https://github.com/github/octofacts.git
adding many more syntax fixes
This commit is contained in:
Родитель
680f1b9831
Коммит
ef8cc2ab41
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_literal_string: true
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
require "bundler/setup"
|
||||
require "octofacts_updater"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# frozen_literal_string: true
|
||||
# frozen_string_literal: true
|
||||
require "octofacts/constructors/from_file"
|
||||
require "octofacts/constructors/from_index"
|
||||
require "octofacts/manipulators"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# frozen_literal_string: true
|
||||
# frozen_string_literal: true
|
||||
module Octofacts
|
||||
module Backends
|
||||
# This is a template class to define the minimum API to be implemented
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# frozen_literal_string: true
|
||||
# frozen_string_literal: true
|
||||
require "yaml"
|
||||
require "set"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# frozen_literal_string: true
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
require "yaml"
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Octofacts
|
||||
# Octofacts.from_index(options) - Construct Octofacts::Facts from an index file.
|
||||
#
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# # frozen_string_literal: true
|
||||
# frozen_string_literal: true
|
||||
module Octofacts
|
||||
class Manipulators
|
||||
# Delete a fact from a hash.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# This class contains methods to interact with an external node classifier.
|
||||
|
||||
require "open3"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# This class reads a YAML file from the local file system so that it can be used as a source
|
||||
# in octofacts-updater. This was originally intended for a quickstart tutorial, since it requires
|
||||
# no real configuration. However it could also be used in production, if the user wants to create
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# This class interacts with puppetdb to pull the facts from the recent
|
||||
# run of Puppet on a given node. This uses octocatalog-diff on the back end to
|
||||
# pull the facts from puppetdb.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# This class interacts with a puppetserver to obtain facts from that server's YAML cache.
|
||||
# This is achieved by SSH-ing to the server and obtaining the fact file directly from the
|
||||
# puppetserver's cache. This can also be used to SSH to an actual node and run a command,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module OctofactsUpdater
|
||||
VERSION = File.read(File.expand_path("../../.version", File.dirname(__FILE__))).strip
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# coding: utf-8
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# coding: utf-8
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
## 3. Commit changes, PR, and merge to master
|
||||
## 4. Check out master branch locally
|
||||
## 5. Run `bundle exec rake gem:release`
|
||||
|
||||
# frozen_string_literal: true
|
||||
require "fileutils"
|
||||
require "open3"
|
||||
require "shellwords"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "bundler/setup"
|
||||
require "octofacts"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative "../../../../spec/spec_helper"
|
||||
|
||||
describe "test::one" do
|
||||
|
@ -7,7 +8,7 @@ describe "test::one" do
|
|||
let(:facts) do
|
||||
{
|
||||
ec2: true,
|
||||
ec2_metadata: { placement: { :"availability-zone" => "us-foo-1a" } },
|
||||
ec2_metadata: { placement: { :"availability-zone" : "us-foo-1a" } },
|
||||
gid: "root",
|
||||
id: "root"
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# spec_helper for rspec-puppet fixture
|
||||
|
||||
require_relative "../../../lib/octofacts"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe Octofacts::Backends::Index do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe Octofacts::Backends::YamlFile do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe Octofacts do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# Make sure the examples in the README document actually work. :-)
|
||||
|
||||
require "spec_helper"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe Octofacts::Facts do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe Octofacts::Manipulators do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
require "yaml"
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe Octofacts::Manipulators do
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
#
|
||||
require "spec_helper"
|
||||
|
||||
# FIXME: Remove when real specs are added
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Octofacts
|
||||
class Spec
|
||||
def self.fixture_root
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe Octofacts::Util::Config do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
describe Octofacts::Util::Keys do
|
||||
describe "#downcase_keys!" do
|
||||
let(:facts) do
|
||||
|
@ -7,8 +8,8 @@ describe Octofacts::Util::Keys do
|
|||
it "should work" do
|
||||
f = facts
|
||||
result = described_class.downcase_keys!(f)
|
||||
expect(f).to eq({"foo" => "foo-value", baz: "baz-value", "bar" => "bar-value", buzz: "buzz-value"})
|
||||
expect(result).to eq({"foo" => "foo-value", baz: "baz-value", "bar" => "bar-value", buzz: "buzz-value"})
|
||||
expect(f).to eq({"foo": "foo-value", baz: "baz-value", "bar": "bar-value", buzz: "buzz-value"})
|
||||
expect(result).to eq({"foo": "foo-value", baz: "baz-value", "bar": "bar-value", buzz: "buzz-value"})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe OctofactsUpdater::FactIndex do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe OctofactsUpdater::Fact do
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe OctofactsUpdater::Fixture do
|
||||
describe "#make" do
|
||||
let(:hostname) { "HostName" }
|
||||
let(:config) {{ "enc" => { "path" => "/foo" }, "puppetdb" => { "url" => "https://puppetdb.example.com:8081" } }}
|
||||
let(:enc_return) {{ "parameters" => { "fizz" => "buzz" }, "classes" => ["class1", "class2"] }}
|
||||
let(:fact_hash_with_values) {{ "name" => hostname, "values" => { "foo" => "bar" } }}
|
||||
let(:config) { { "enc" => { "path" => "/foo" }, "puppetdb" => { "url" => "https://puppetdb.example.com:8081" } } }
|
||||
let(:enc_return) { { "parameters" => { "fizz" => "buzz" }, "classes" => ["class1", "class2"] } }
|
||||
let(:fact_hash_with_values) { { "name" => hostname, "values" => { "foo" => "bar" } } }
|
||||
|
||||
it "should instantiate and return a fixture object with the given facts" do
|
||||
expect(OctofactsUpdater::Service::ENC).to receive(:run_enc).with(hostname, config).and_return(enc_return)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe OctofactsUpdater::VERSION do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe OctofactsUpdater::Plugin do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
require "ipaddr"
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe "sshfp_randomize plugin" do
|
||||
let(:plugin) { OctofactsUpdater::Plugin.plugins[:sshfp_randomize] }
|
||||
let(:value) { "SSHFP 1 1 0123456789abcdef0123456789abcdef01234567\nSSHFP 1 2 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" }
|
||||
let(:args) {{ "plugin" => "sshfp_randomize" }}
|
||||
let(:args) { { "plugin" => "sshfp_randomize" } }
|
||||
|
||||
it "should be defined" do
|
||||
expect(plugin).to be_a_kind_of(Proc)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe "delete plugin" do
|
||||
|
@ -112,7 +113,7 @@ end
|
|||
describe "randomize_long_string plugin" do
|
||||
let(:plugin) { OctofactsUpdater::Plugin.plugins[:randomize_long_string] }
|
||||
let(:value) { "1234567890abcdef" }
|
||||
let(:args) {{ "plugin" => "randomize_long_string" }}
|
||||
let(:args) { { "plugin" => "randomize_long_string" } }
|
||||
|
||||
it "should be defined" do
|
||||
expect(plugin).to be_a_kind_of(Proc)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
require "ostruct"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe OctofactsUpdater::Service::LocalFile do
|
||||
|
@ -8,12 +9,12 @@ describe OctofactsUpdater::Service::LocalFile do
|
|||
context "when localfile is not configured" do
|
||||
it "should raise ArgumentError when localfile is undefined" do
|
||||
config = {}
|
||||
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires localfile section/)
|
||||
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires localfile section/)
|
||||
end
|
||||
|
||||
it "should raise ArgumentError when localfile is not a hash" do
|
||||
config = {"localfile" => :do_it}
|
||||
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires localfile section/)
|
||||
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires localfile section/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -22,12 +23,12 @@ describe OctofactsUpdater::Service::LocalFile do
|
|||
|
||||
it "should raise error if the path is undefined" do
|
||||
config = { "localfile" => {} }
|
||||
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'path' in the localfile section/)
|
||||
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'path' in the localfile section/)
|
||||
end
|
||||
|
||||
it "should raise error if the path does not exist" do
|
||||
config = { "localfile" => { "path" => File.join(file_path, "missing.yaml") } }
|
||||
expect{ described_class.facts(node, config) }.to raise_error(Errno::ENOENT, /LocalFile cannot find a file at/)
|
||||
expect { described_class.facts(node, config) }.to raise_error(Errno::ENOENT, /LocalFile cannot find a file at/)
|
||||
end
|
||||
|
||||
it "should return the proper object from the parsed file" do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require "spec_helper"
|
||||
|
||||
describe OctofactsUpdater::Service::SSH do
|
||||
|
@ -8,19 +9,19 @@ describe OctofactsUpdater::Service::SSH do
|
|||
context "when ssh is not configured" do
|
||||
it "should raise ArgumentError when ssh is undefined" do
|
||||
config = {}
|
||||
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires ssh section/)
|
||||
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires ssh section/)
|
||||
end
|
||||
|
||||
it "should raise ArgumentError when ssh is not a hash" do
|
||||
config = {"ssh" => :do_it}
|
||||
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires ssh section/)
|
||||
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires ssh section/)
|
||||
end
|
||||
end
|
||||
|
||||
context "when ssh is configured" do
|
||||
it "should raise error if no server is configured" do
|
||||
config = { "ssh" => {} }
|
||||
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'server' in the ssh section/)
|
||||
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'server' in the ssh section/)
|
||||
end
|
||||
|
||||
context "when user is unspecified" do
|
||||
|
@ -38,14 +39,14 @@ describe OctofactsUpdater::Service::SSH do
|
|||
|
||||
it "should raise error if no user is configured" do
|
||||
config = { "ssh" => { "server" => "puppetserver.example.net" } }
|
||||
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'user' in the ssh section/)
|
||||
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'user' in the ssh section/)
|
||||
end
|
||||
|
||||
it "should use USER from environment if no user is configured" do
|
||||
ENV["USER"] = "ssh-user-from-env"
|
||||
config = { "ssh" => { "server" => "puppetserver.example.net" } }
|
||||
expect(Net::SSH).to receive(:start).with("puppetserver.example.net", "ssh-user-from-env", {}).and_raise(custom_exception)
|
||||
expect{ described_class.facts(node, config) }.to raise_error(custom_exception)
|
||||
expect { described_class.facts(node, config) }.to raise_error(custom_exception)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
if ENV["SPEC_NAME"]
|
||||
require "simplecov"
|
||||
require "simplecov-json"
|
||||
|
|
Загрузка…
Ссылка в новой задаче