зеркало из https://github.com/github/octofacts.git
Make rubocop happy
This commit is contained in:
Родитель
580b987534
Коммит
2cd79b82af
|
@ -3,7 +3,6 @@ inherit_gem:
|
|||
- config/default.yml
|
||||
|
||||
AllCops:
|
||||
NewCops: enable
|
||||
DisplayCopNames: true
|
||||
|
||||
AllCops:
|
||||
TargetRubyVersion: 2.6
|
||||
|
|
4
Rakefile
4
Rakefile
|
@ -1,9 +1,11 @@
|
|||
#frozen_string_literal: true
|
||||
|
||||
require "rake"
|
||||
require "rspec/core/rake_task"
|
||||
require_relative "rake/gem"
|
||||
|
||||
namespace :octofacts do
|
||||
task :default => [ ":octofacts:spec:octofacts", ":octofacts:spec:octofacts_updater", ":octofacts:spec:octofacts_integration" ] do
|
||||
task default: [":octofacts:spec:octofacts", ":octofacts:spec:octofacts_updater", ":octofacts:spec:octofacts_integration"] do
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "yaml"
|
||||
require "set"
|
||||
|
||||
|
@ -7,7 +8,6 @@ module Octofacts
|
|||
class Index < Base
|
||||
attr_reader :index_path, :fixture_path, :options
|
||||
attr_writer :facts
|
||||
attr_accessor :nodes
|
||||
|
||||
def initialize(args = {})
|
||||
index_path = Octofacts::Util::Config.fetch(:octofacts_index_path, args)
|
||||
|
|
|
@ -134,12 +134,12 @@ module OctofactsUpdater
|
|||
@opts[:quick] = true
|
||||
|
||||
path = if opts[:path]
|
||||
File.expand_path(opts[:path])
|
||||
elsif @config.fetch("index", {})["node_path"]
|
||||
File.expand_path(@config.fetch("index", {})["node_path"], File.dirname(opts[:config]))
|
||||
else
|
||||
raise ArgumentError, "Must set --path, or define index:node_path to a valid directory in configuration"
|
||||
end
|
||||
File.expand_path(opts[:path])
|
||||
elsif @config.fetch("index", {})["node_path"]
|
||||
File.expand_path(@config.fetch("index", {})["node_path"], File.dirname(opts[:config]))
|
||||
else
|
||||
raise ArgumentError, "Must set --path, or define index:node_path to a valid directory in configuration"
|
||||
end
|
||||
|
||||
unless File.directory?(path)
|
||||
raise Errno::ENOENT, "--path must be a directory (#{path.inspect} is not)"
|
||||
|
|
|
@ -66,20 +66,20 @@ module OctofactsUpdater
|
|||
end
|
||||
|
||||
parts = if name_in.is_a?(String)
|
||||
name_in.split("::")
|
||||
elsif name_in.is_a?(Array)
|
||||
name_in.map do |item|
|
||||
if item.is_a?(String)
|
||||
item
|
||||
elsif item.is_a?(Hash) && item.key?("regexp")
|
||||
Regexp.new(item["regexp"])
|
||||
else
|
||||
raise ArgumentError, "Unable to interpret structure item: #{item.inspect}"
|
||||
end
|
||||
end
|
||||
else
|
||||
raise ArgumentError, "Unable to interpret structure: #{name_in.inspect}"
|
||||
end
|
||||
name_in.split("::")
|
||||
elsif name_in.is_a?(Array)
|
||||
name_in.map do |item|
|
||||
if item.is_a?(String)
|
||||
item
|
||||
elsif item.is_a?(Hash) && item.key?("regexp")
|
||||
Regexp.new(item["regexp"])
|
||||
else
|
||||
raise ArgumentError, "Unable to interpret structure item: #{item.inspect}"
|
||||
end
|
||||
end
|
||||
else
|
||||
raise ArgumentError, "Unable to interpret structure: #{name_in.inspect}"
|
||||
end
|
||||
|
||||
set_structured_value(@value, parts, new_value)
|
||||
end
|
||||
|
|
|
@ -8,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"
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ describe "test::one" do
|
|||
end
|
||||
|
||||
context "using straight octofacts from file with manipulation of symbol converted to hash" do
|
||||
let(:facts) { Octofacts.from_file("basic.yaml").replace(:"ec2_metadata::placement::availability-zone" => "us-hats-1a").facts }
|
||||
let(:facts) { Octofacts.from_file("basic.yaml").replace("ec2_metadata::placement::availability-zone": "us-hats-1a").facts }
|
||||
|
||||
it "should contain the file resource" do
|
||||
is_expected.to contain_file("/tmp/system-info.txt").with(
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
describe OctofactsUpdater::Service::Base do
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
require "ostruct"
|
||||
|
||||
describe OctofactsUpdater::Service::ENC do
|
||||
let(:config) {{ "enc" => { "path" => "/tmp/foo.enc" }}}
|
||||
let(:config) { { "enc" => { "path" => "/tmp/foo.enc" }} }
|
||||
|
||||
describe "#run_enc" do
|
||||
it "should raise ArgumentError if no configuration for the ENC is defined" do
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
require "octocatalog-diff"
|
||||
|
|
Загрузка…
Ссылка в новой задаче