mirror of
https://github.com/inspec/inspec
synced 2024-11-25 06:00:29 +00:00
CHEF-17239: Fix tests to restore green verify pipeline (#7208)
* chore: fix chefstyle lint offense Signed-off-by: Sonu Saha <sonu.saha@progress.com> * chore: update deprecation config to pass logging_test functional test Signed-off-by: Sonu Saha <sonu.saha@progress.com> * fix: implement podman_object module (which was docker_object) it was moved out to docker resource pack Signed-off-by: Sonu Saha <sonu.saha@progress.com> * chore: remove mongodb resources require Signed-off-by: Sonu Saha <sonu.saha@progress.com> --------- Signed-off-by: Sonu Saha <sonu.saha@progress.com>
This commit is contained in:
parent
04bc12af63
commit
86f541dd67
7 changed files with 63 additions and 11 deletions
|
@ -51,6 +51,7 @@ module Inspec::DSL
|
|||
unless cfg.final_options[:auto_install_gems]
|
||||
raise Inspec::Plugin::V2::InstallRequiredError, "resource pack gem '#{gem_name}' is required for resource '#{id}' support (consider --auto-install-gems)"
|
||||
end
|
||||
|
||||
Inspec::Plugin::V2::Installer.instance.ensure_installed gem_name
|
||||
|
||||
# Load the gem, add gemspecs to the path, load any deps, load resource libraries into registry
|
||||
|
@ -65,7 +66,7 @@ module Inspec::DSL
|
|||
gem_path = loader.find_gem_directory(gem_name)
|
||||
resources_path = File.join(gem_path, "lib", gem_name, "resources", "*.rb")
|
||||
legacy_library_path = File.join(gem_path, "libraries", "*.rb")
|
||||
Dir.glob([resources_path,legacy_library_path]).each do |resource_lib|
|
||||
Dir.glob([resources_path, legacy_library_path]).each do |resource_lib|
|
||||
require resource_lib
|
||||
end
|
||||
# Resources now available in Inspec::Resource.registry
|
||||
|
|
|
@ -57,9 +57,6 @@ require "inspec/resources/key_rsa"
|
|||
require "inspec/resources/ksh"
|
||||
require "inspec/resources/limits_conf"
|
||||
require "inspec/resources/login_defs"
|
||||
require "inspec/resources/mongodb"
|
||||
require "inspec/resources/mongodb_conf"
|
||||
require "inspec/resources/mongodb_session"
|
||||
require "inspec/resources/mount"
|
||||
require "inspec/resources/mssql_session"
|
||||
require "inspec/resources/mssql_sys_conf"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require "inspec/resources/podman"
|
||||
require_relative "docker_object"
|
||||
require_relative "podman_object"
|
||||
|
||||
# Change module if required
|
||||
module Inspec::Resources
|
||||
class PodmanContainer < Inspec.resource(1)
|
||||
include Inspec::Resources::DockerObject
|
||||
include Inspec::Resources::PodmanObject
|
||||
name "podman_container"
|
||||
supports platform: "unix"
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require "inspec/resources/command"
|
||||
require_relative "docker_object"
|
||||
require_relative "podman_object"
|
||||
require "inspec/utils/podman"
|
||||
|
||||
module Inspec::Resources
|
||||
class PodmanImage < Inspec.resource(1)
|
||||
include Inspec::Resources::DockerObject
|
||||
include Inspec::Resources::PodmanObject
|
||||
include Inspec::Utils::Podman
|
||||
|
||||
name "podman_image"
|
||||
|
|
48
lib/inspec/resources/podman_object.rb
Normal file
48
lib/inspec/resources/podman_object.rb
Normal file
|
@ -0,0 +1,48 @@
|
|||
module Inspec::Resources::PodmanObject
|
||||
def exist?
|
||||
object_info.exists?
|
||||
end
|
||||
|
||||
def id
|
||||
object_info.ids[0] if object_info.entries.size == 1
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse_components_from_image(image_string)
|
||||
# if the user did not supply an image string, they likely supplied individual
|
||||
# option parameters, such as repo and tag. Return empty data back to the caller.
|
||||
return {} if image_string.nil?
|
||||
|
||||
first_colon = image_string.index(":") || -1
|
||||
first_slash = image_string.index("/") || -1
|
||||
|
||||
if image_string.count(":") == 2
|
||||
# If there are two colons in the image string, it contains a repo-with-port and a tag.
|
||||
# example: localhost:5000/chef/inspec:1.46.3
|
||||
partitioned_string = image_string.rpartition(":")
|
||||
repo = partitioned_string.first
|
||||
tag = partitioned_string.last
|
||||
image_name = repo.split("/")[1..-1].join
|
||||
elsif image_string.count(":") == 1 && first_colon < first_slash
|
||||
# If there's one colon in the image string, and it comes before a forward-slash,
|
||||
# it contains a repo-with-port but no tag.
|
||||
# example: localhost:5000/ubuntu
|
||||
repo = image_string
|
||||
tag = nil
|
||||
image_name = repo.split("/")[1..-1].join
|
||||
else
|
||||
# If there's one colon in the image string and it doesn't preceed a slash, or if
|
||||
# there is no colon at all, then it separates the repo from the tag, if there is a tag.
|
||||
# example: chef/inspec:1.46.3
|
||||
# example: chef/inspec
|
||||
# example: ubuntu:14.04
|
||||
repo, tag = image_string.split(":")
|
||||
image_name = repo
|
||||
end
|
||||
|
||||
# return the repo, image_name and tag parsed from the string, which can be merged into
|
||||
# the rest of the user-supplied options
|
||||
{ repo: repo, image_name: image_name, tag: tag }
|
||||
end
|
||||
end
|
|
@ -5,14 +5,20 @@ class DeprecationTester < Inspec.resource(1)
|
|||
|
||||
DEPRECATION_CFG = <<~EOC
|
||||
{
|
||||
"file_version": "1.0.0",
|
||||
"file_version": "2.0.0",
|
||||
"unknown_group_action": "warn",
|
||||
"groups": {
|
||||
"a_group_that_will_warn": { "action": "warn" },
|
||||
"a_group_that_will_exit": { "action": "exit" },
|
||||
"a_group_that_will_exit": { "action": "exit" },
|
||||
"a_group_that_will_exit_with_a_code": { "action": "exit", "exit_status": 8 },
|
||||
"an_ignored_group": { "action": "ignore" },
|
||||
"a_group_that_will_fail": { "action": "fail_control" }
|
||||
},
|
||||
"fallback_resource_packs": {
|
||||
"somepath.+": {
|
||||
"gem": "inspec-stuff-resources",
|
||||
"message": "Words"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOC
|
||||
|
|
|
@ -35,7 +35,7 @@ describe "profiles with missing resources" do
|
|||
|
||||
it "installs the gem dependencies and load them if --auto-install-gems is provided." do
|
||||
# TODO - this work if you have a private rubygems server and upload inspec-test-resources to it
|
||||
skip
|
||||
skip
|
||||
out = inspec_with_env("exec #{fallback_profile_path} --no-create-lockfile --auto-install-gems")
|
||||
|
||||
_(out.stderr).must_equal ""
|
||||
|
|
Loading…
Reference in a new issue