mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
Merged change fa4f930a-67af-4eee-ac06-fc05a365ba6b
From review branch _reviews/master/dockerized-tests/1 into master Signed-off-by: chartmann <chartmann@chef.io>
This commit is contained in:
commit
1e94135304
17 changed files with 54 additions and 28 deletions
|
@ -1,5 +1,8 @@
|
|||
name 'build-cookbook'
|
||||
maintainer 'The Authors'
|
||||
maintainer_email 'you@example.com'
|
||||
maintainer 'Dominik Richter'
|
||||
maintainer_email 'drichter@chef.io'
|
||||
license 'all_rights'
|
||||
version '0.1.0'
|
||||
|
||||
depends 'docker', '~> 1.0'
|
||||
depends 'fancy_execute'
|
||||
|
|
|
@ -1,5 +1,23 @@
|
|||
#
|
||||
# encoding: utf-8
|
||||
# Cookbook Name:: build-cookbook
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright (c) 2015 The Authors, All Rights Reserved.
|
||||
# Copyright (c) 2015 Chef Software Inc., All Rights Reserved.
|
||||
|
||||
group 'docker' do
|
||||
members [node['delivery_builder']['build_user']]
|
||||
end
|
||||
|
||||
package 'build-essential'
|
||||
|
||||
docker_service 'dockerd' do
|
||||
action [:delete, :create, :start]
|
||||
host 'unix:///var/run/docker.sock'
|
||||
group 'docker'
|
||||
provider Chef::Provider::DockerService::Execute
|
||||
end
|
||||
|
||||
log 'system info' do
|
||||
message `uname -a; docker --version; ls -lha /var/run/docker.sock`
|
||||
level :warn
|
||||
end
|
||||
|
|
|
@ -7,8 +7,16 @@
|
|||
|
||||
include_recipe 'build-cookbook::prepare'
|
||||
|
||||
home = node['delivery_builder']['repo']
|
||||
|
||||
execute 'rake test' do
|
||||
command 'bundle exec rake'
|
||||
cwd node['delivery_builder']['repo']
|
||||
command 'bundle exec rake test'
|
||||
cwd home
|
||||
user node['delivery_builder']['build_user']
|
||||
end
|
||||
|
||||
execute 'dockerized rake' do
|
||||
command 'bundle exec rake test:resources config=test/test.yaml'
|
||||
cwd home
|
||||
user node['delivery_builder']['build_user']
|
||||
end
|
||||
|
|
|
@ -11,5 +11,7 @@
|
|||
"smoke",
|
||||
"deploy"
|
||||
],
|
||||
"build_nodes": {}
|
||||
"build_nodes": {
|
||||
"default": ["name:builder-7.delivery.chef.co"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class AuditDaemonConf < Vulcano.resource(1)
|
|||
private
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
|
||||
# read the file
|
||||
file = vulcano.file(@conf_path)
|
||||
|
|
|
@ -12,7 +12,7 @@ class GemPackage < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def info
|
||||
return @info unless @info.nil?
|
||||
return @info if defined?(@info)
|
||||
|
||||
cmd = vulcano.run_command("gem list --local -a -q \^#{@package_name}\$")
|
||||
@info = {
|
||||
|
|
|
@ -28,7 +28,7 @@ class InetdConf < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
|
||||
# read the file
|
||||
file = vulcano.file(@conf_path)
|
||||
|
|
|
@ -26,7 +26,7 @@ class LimitsConf < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
|
||||
# read the file
|
||||
file = vulcano.file(@conf_path)
|
||||
|
|
|
@ -32,7 +32,7 @@ class LoginDef < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
|
||||
# read the file
|
||||
file = vulcano.file(@conf_path)
|
||||
|
|
|
@ -13,7 +13,7 @@ class NpmPackage < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def info
|
||||
return @info unless @info.nil?
|
||||
return @info if defined?(@info)
|
||||
|
||||
cmd = vulcano.run_command("npm ls -g --json #{@package_name}")
|
||||
@info = {
|
||||
|
|
|
@ -32,7 +32,7 @@ class NtpConf < Vulcano.resource(1)
|
|||
private
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
|
||||
if !vulcano.file(@conf_path).file?
|
||||
skip_resource "Can't find file \"#{@conf_path}\""
|
||||
|
|
|
@ -15,7 +15,7 @@ class OneGetPackage < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def info
|
||||
return @info unless @info.nil?
|
||||
return @info if defined?(@info)
|
||||
|
||||
@info = {}
|
||||
@info[:type] = 'oneget'
|
||||
|
|
|
@ -12,7 +12,7 @@ class PipPackage < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def info
|
||||
return @info unless @info.nil?
|
||||
return @info if defined?(@info)
|
||||
|
||||
@info = {}
|
||||
@info[:type] = 'pip'
|
||||
|
|
|
@ -176,7 +176,7 @@ class LinuxPorts < PortsInfo
|
|||
ip6addr = ip6[1]
|
||||
ip6addr = '::' if /^:::$/.match(ip6addr)
|
||||
# build uri
|
||||
ip_addr = URI('addr://[' + ip6addr +']:' + ip6[2])
|
||||
ip_addr = URI("addr://[#{ip6addr}]:#{ip6[2]}")
|
||||
# replace []
|
||||
host = ip_addr.host[1..ip_addr.host.size-2]
|
||||
port = ip_addr.port
|
||||
|
@ -248,7 +248,7 @@ class FreeBsdPorts < PortsInfo
|
|||
# extract port
|
||||
ip6 = /^(\S+):(\d+)$/.match(net_addr)
|
||||
ip6addr = ip6[1]
|
||||
ip_addr = URI('addr://[' + ip6addr +']:' + ip6[2])
|
||||
ip_addr = URI("addr://[#{ip6addr}]:#{ip6[2]}")
|
||||
# replace []
|
||||
host = ip_addr.host[1..ip_addr.host.size-2]
|
||||
port = ip_addr.port
|
||||
|
|
|
@ -38,7 +38,7 @@ class SshConf < Vulcano.resource(1)
|
|||
private
|
||||
|
||||
def read_content
|
||||
return @content if @content_read
|
||||
return @content if defined?(@content)
|
||||
file = vulcano.file(@conf_path)
|
||||
if !file.file?
|
||||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
|
@ -49,12 +49,11 @@ class SshConf < Vulcano.resource(1)
|
|||
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||
end
|
||||
|
||||
@content_read = true
|
||||
@content
|
||||
end
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
return @params = {} if read_content.nil?
|
||||
conf = SimpleConfig.new(
|
||||
read_content,
|
||||
|
|
|
@ -32,10 +32,6 @@ module Vulcano::Resources
|
|||
class Yum < Vulcano.resource(1)
|
||||
name 'yum'
|
||||
|
||||
def initialize
|
||||
@cache = nil
|
||||
end
|
||||
|
||||
# returns all repositories
|
||||
# works as following:
|
||||
# search for Repo-id
|
||||
|
@ -43,7 +39,7 @@ module Vulcano::Resources
|
|||
# store data in object
|
||||
# until \n
|
||||
def repositories
|
||||
return @cache if !@cache.nil?
|
||||
return @cache if defined?(@cache)
|
||||
# parse the repository data from yum
|
||||
# we cannot use -C, because this is not reliable and may lead to errors
|
||||
@command_result = vulcano.run_command('yum -v repolist all')
|
||||
|
@ -111,7 +107,7 @@ class YumRepo
|
|||
end
|
||||
|
||||
def info
|
||||
return @cache if !@cache.nil?
|
||||
return @cache if defined?(@cache)
|
||||
selection = @yum.repositories.select { |e| e['id'] == @reponame || shortname(e['id']) == @reponame }
|
||||
@cache = selection[0] if !selection.nil? && selection.length == 1
|
||||
@cache
|
||||
|
|
|
@ -26,7 +26,7 @@ class Vulcano::Plugins::Backend
|
|||
end
|
||||
|
||||
def lsb
|
||||
return @lsb unless @lsb.nil?
|
||||
return @lsb if defined?(@lsb)
|
||||
@lsb = {}
|
||||
if !(raw = get_config('/etc/lsb-release')).nil?
|
||||
@lsb = lsb_config(raw)
|
||||
|
|
Loading…
Reference in a new issue