omnibus 9.0.12 → 9.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f20cc7252db28fd200af4db5bda33950070e7156613c39009f03ca486eb0e20a
4
- data.tar.gz: 9dcd4a140bf26997769e5f125f205411ca2cb99c0baff4d3c5f8a8f5f637e45a
3
+ metadata.gz: 91e18818ba6b01864ca40a7847beb9b9cc281db69a99ad478265beb9792411fc
4
+ data.tar.gz: b25c8dca7eb871e4d1014fa61b270aa81db0653bc1a5061816e5ed8a0076c0f4
5
5
  SHA512:
6
- metadata.gz: aa23dc9ab959bf5d738ac6377b47b96f29a44ac447e0cb22bee1dcb019ca8278907986844c4333f747986dbc77eb916d513df2c22b51b6e2c8adf9a5b70a21e5
7
- data.tar.gz: f89b0e7c0d3bb79b904084de8c1b00fe9e2f4fca318335158c58ac2472de51d945c6ff641bcdf33db38d15928b7e7d30419423505af93380f546f99fc935ac74
6
+ metadata.gz: 311583baefc33f9b9ac500ff1b96c5f3b0f03897e08de2135c7dedff9e0d8abc35ed1c8b414d8f291331546063e47095f4f04386db794f0895f3154105fa7fbb
7
+ data.tar.gz: e1ed149a6899e29bdce5e26d2762ed984e74305dd4fcdf72d849f479a4dc1abf34a78fb448760df12ddc8d6b80e388ef9a396752bfe0e714e4d46d6cd076c1c1
data/README.md CHANGED
@@ -279,6 +279,10 @@ However there are several caveats to be aware of:
279
279
  1. You will almost certainly want to uncomment the `base_dir` in `omnibus.rb`,
280
280
  or at the very least change `cache_dir` and `build_dir` as otherwise it'll try
281
281
  to use `/var/cache/omnibus` and `/opt/$MY_PROJECT_NAME`, requiring root.
282
+ 1. Update software dependencies listed in the project configuration in `config/projects/$MY_PROJECT_NAME.rb`.
283
+ You can refer the software `.rb` files present in the `config/software` folder.
284
+ 1. The `install_dir` specified in the project file typically requires `root` privilege at build time.
285
+ Change it another location such as `"/tmp/#{name}"` to avoid running as `root`.
282
286
  1. The default configuration created for you references a lot of things
283
287
  that are in the default config that come from the `omnibus-software` gem.
284
288
  So you want to use those you'll need to either uncomment it in the `Gemfile`,
@@ -0,0 +1,129 @@
1
+ #
2
+ # Copyright 2012-2018 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Omnibus
18
+ # Provides methods for fetching Omnibus project build metadata from Buildkite
19
+ #
20
+ # @note Requires environment variables provided by Buildkite
21
+ #
22
+ class Buildkite
23
+
24
+ class << self
25
+
26
+ #
27
+ # Constants for the buildkite environment variables
28
+ #
29
+ AMI_ID_ENV_KEY = "BUILDKITE_AGENT_META_DATA_AWS_AMI_ID".freeze
30
+ HOSTNAME_ENV_KEY = "BUILDKITE_AGENT_META_DATA_HOSTNAME".freeze
31
+ DOCKER_VERSION_ENV_KEY = "BUILDKITE_AGENT_META_DATA_DOCKER".freeze
32
+ BUILDKITE_COMMAND_ENV_KEY = "BUILDKITE_COMMAND".freeze
33
+
34
+ #
35
+ # The AMI ID of the instance the build is happening on.
36
+ #
37
+ # @note This is only present when the instance is a Windows or Linux instance.
38
+ #
39
+ # @note Relies on presence of ENV["BUILDKITE_AGENT_META_DATA_AWS_AMI_ID"] in Buildkite build job.
40
+ #
41
+ # @return [String]
42
+ # either the AMI ID, or 'unknown'
43
+ #
44
+ def ami_id
45
+ ami_id = "unknown"
46
+ if !ENV[AMI_ID_ENV_KEY].nil? && !ENV[AMI_ID_ENV_KEY].empty?
47
+ ami_id = ENV[AMI_ID_ENV_KEY]
48
+ end
49
+ ami_id
50
+ end
51
+
52
+ #
53
+ # The hostname of the instance the build is happening on.
54
+ #
55
+ # @note This is only present when the instance is a MacOS instance.
56
+ #
57
+ # @note Relies on presence of ENV["BUILDKITE_AGENT_META_DATA_HOSTNAME"] in Buildkite build job.
58
+ #
59
+ # @return [String]
60
+ # either the hostname, or 'unknown'
61
+ #
62
+ def hostname
63
+ hostname = "unknown"
64
+ if !ENV[HOSTNAME_ENV_KEY].nil? && !ENV[HOSTNAME_ENV_KEY].empty? && ami_id == "unknown"
65
+ hostname = ENV[HOSTNAME_ENV_KEY]
66
+ end
67
+ hostname
68
+ end
69
+
70
+ #
71
+ # A boolean representing if the build is using docker or not.
72
+ #
73
+ # @note Relies on presence of ENV["BUILDKITE_AGENT_META_DATA_DOCKER"] in Buildkite build job.
74
+ #
75
+ # @return [Boolean]
76
+ #
77
+ def is_docker_build
78
+ !ENV[DOCKER_VERSION_ENV_KEY].nil? && !ENV[DOCKER_VERSION_ENV_KEY].empty? ? true : false
79
+ end
80
+
81
+ #
82
+ # The version of docker that was used in the build.
83
+ #
84
+ # @note Relies on presence of ENV["BUILDKITE_AGENT_META_DATA_DOCKER"] in Buildkite build job.
85
+ #
86
+ # @return [String]
87
+ #
88
+ def docker_version
89
+ ENV[DOCKER_VERSION_ENV_KEY] if is_docker_build
90
+ end
91
+
92
+ #
93
+ # The OS Image that is being used in the Docker build
94
+ #
95
+ # @note Relies on presence of ENV["BUILDKITE_COMMAND"] in Buildkite build job.
96
+ #
97
+ # @return [String]
98
+ # String with the parameter that was provided in the `docker build` command
99
+ #
100
+ def docker_image
101
+ buildkite_command = ENV[BUILDKITE_COMMAND_ENV_KEY]
102
+ if is_docker_build && buildkite_command && buildkite_command.include?("OS_IMAGE")
103
+ os_image = buildkite_command.match(/OS_IMAGE=(?<image_id>[\S]*)/)
104
+ os_image[:image_id]
105
+ end
106
+ end
107
+
108
+ #
109
+ # The version of Omnibus that is in `version.rb`
110
+ #
111
+ # @return [String]
112
+ #
113
+ def omnibus_version
114
+ Omnibus::VERSION
115
+ end
116
+
117
+ def to_hash
118
+ ret = {}
119
+ ret[:ami_id] = ami_id if ami_id != "unknown"
120
+ ret[:hostname] = hostname if hostname != "unknown"
121
+ ret[:is_docker_build] = is_docker_build if is_docker_build
122
+ ret[:docker_version] = docker_version if docker_version
123
+ ret[:docker_image] = docker_image if docker_image
124
+ ret[:omnibus_version] = omnibus_version
125
+ ret
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,36 @@
1
+ #
2
+ # Copyright 2012-2018 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require "omnibus/build_system_metadata/buildkite"
18
+
19
+ module Omnibus
20
+ # Provides methods for fetching Omnibus project build metadata from Buildkite
21
+ #
22
+ # @note Requires environment variables provided whichever platform metdata is being pulled from
23
+ #
24
+ class BuildSystemMetadata
25
+
26
+ class << self
27
+
28
+ def to_hash
29
+ if !ENV["BUILDKITE"].nil? && !ENV["BUILDKITE"].empty?
30
+ Omnibus::Buildkite.to_hash
31
+ end
32
+ end
33
+
34
+ end
35
+ end
36
+ end
data/lib/omnibus/cli.rb CHANGED
@@ -85,7 +85,13 @@ module Omnibus
85
85
  project = Project.load(name, manifest)
86
86
  say("Building #{project.name} #{project.build_version}...")
87
87
  Omnibus::S3Cache.populate if @options[:populate_s3_cache] && !Omnibus::S3Cache.fetch_missing.empty?
88
- project.download
88
+ begin
89
+ project.download
90
+ rescue
91
+ Config.use_s3_caching(false) if Config.use_s3_caching
92
+ project = Project.load(name, nil)
93
+ project.download
94
+ end
89
95
  project.build
90
96
 
91
97
  if @options[:output_manifest]
@@ -69,13 +69,20 @@ module Omnibus
69
69
 
70
70
  def to_hash
71
71
  software_hash = @data.inject({}) do |memo, (k, v)|
72
- memo[k] = v.to_hash
72
+ h = v.to_hash
73
+ h[:locked_source].delete(:authorization) if h[:locked_source]
74
+
75
+ memo[k] = h
73
76
  memo
74
77
  end
78
+
79
+ build_system_metadata = Omnibus::BuildSystemMetadata.to_hash
80
+
75
81
  ret = {
76
82
  manifest_format: LATEST_MANIFEST_FORMAT,
77
83
  software: software_hash,
78
84
  }
85
+ ret[:build_system_metadata] = build_system_metadata if build_system_metadata
79
86
  ret[:build_version] = build_version if build_version
80
87
  ret[:build_git_revision] = build_git_revision if build_git_revision
81
88
  ret[:license] = license
@@ -115,7 +122,9 @@ module Omnibus
115
122
  end
116
123
 
117
124
  def self.from_hash_v2(manifest_data)
118
- m = Omnibus::Manifest.new(manifest_data[:build_version], manifest_data[:build_git_revision], manifest_data[:license])
125
+ m = Omnibus::Manifest.new(manifest_data[:build_version],
126
+ manifest_data[:build_git_revision],
127
+ manifest_data[:license])
119
128
  manifest_data[:software].each do |name, entry_data|
120
129
  m.add(name, Omnibus::ManifestEntry.new(name, keys_to_syms(entry_data)))
121
130
  end
@@ -307,6 +307,30 @@ module Omnibus
307
307
  end
308
308
  expose :gem_path
309
309
 
310
+ #
311
+ # Provide a custom zip name
312
+ #
313
+ # @example
314
+ # zip_name 'chef'
315
+ #
316
+ # @param [TrueClass, FalseClass] value
317
+ # whether we're building a zip-based MSI or not
318
+ #
319
+ # @return [TrueClass, FalseClass]
320
+ # whether we're building a zip-based MSI or not
321
+ def zip_name(val = NULL)
322
+ if null?(val)
323
+ @zip_name || project.name
324
+ else
325
+ unless val.is_a?(String)
326
+ raise InvalidValue.new(:zip_name, "be an String")
327
+ end
328
+
329
+ @zip_name = val
330
+ end
331
+ end
332
+ expose :zip_name
333
+
310
334
  #
311
335
  # @!endgroup
312
336
  # --------------------------------------------------
@@ -443,7 +467,7 @@ module Omnibus
443
467
  def zip_command
444
468
  <<-EOH.split.join(" ").squeeze(" ").strip
445
469
  7z a -r
446
- #{windows_safe_path(staging_dir)}\\#{project.name}.zip
470
+ #{windows_safe_path(staging_dir)}\\#{zip_name}.zip
447
471
  #{windows_safe_path(project.install_dir)}\\*
448
472
  EOH
449
473
  end
@@ -457,7 +481,7 @@ module Omnibus
457
481
  def heat_command
458
482
  if fast_msi
459
483
  <<-EOH.split.join(" ").squeeze(" ").strip
460
- heat.exe file "#{project.name}.zip"
484
+ heat.exe file "#{zip_name}.zip"
461
485
  -cg ProjectDir
462
486
  -dr INSTALLLOCATION
463
487
  -nologo -sfrag -srd -sreg -gg
@@ -1062,7 +1062,10 @@ module Omnibus
1062
1062
  end
1063
1063
 
1064
1064
  def download
1065
- ThreadPool.new(Config.workers) do |pool|
1065
+ # Setting abort_on_exception to false because it was causing
1066
+ # errors by shutting down the main thread when encountering a cache miss
1067
+ # in S3 and falling back to the internal source repo
1068
+ ThreadPool.new(Config.workers, false) do |pool|
1066
1069
  softwares.each do |software|
1067
1070
  pool.schedule { software.fetch }
1068
1071
  end
@@ -46,14 +46,16 @@ module Omnibus
46
46
  #
47
47
  # @param [Integer] size
48
48
  # the number of items to put in the thread pool
49
+ # @param [Boolean] abort_on_exception
50
+ # if the thread should abort the main thread also on a failure
49
51
  #
50
- def initialize(size)
52
+ def initialize(size, abort_on_exception = true)
51
53
  @size = size
52
54
  @jobs = Queue.new
53
55
 
54
56
  @pool = Array.new(@size) do |i|
55
57
  Thread.new do
56
- Thread.abort_on_exception = true
58
+ Thread.abort_on_exception = abort_on_exception
57
59
  Thread.current[:id] = i
58
60
 
59
61
  catch(:exit) do
@@ -15,5 +15,5 @@
15
15
  #
16
16
 
17
17
  module Omnibus
18
- VERSION = "9.0.12".freeze
18
+ VERSION = "9.0.17".freeze
19
19
  end
@@ -62,6 +62,7 @@ AIX_WHITELIST_LIBS = [
62
62
  /librtl\.a/,
63
63
  /libsrc\.a/,
64
64
  /unix$/,
65
+ /libcrypto\.so/,
65
66
  ].freeze
66
67
 
67
68
  OMNIOS_WHITELIST_LIBS = [
data/lib/omnibus.rb CHANGED
@@ -34,34 +34,36 @@ module Omnibus
34
34
  #
35
35
  DEFAULT_CONFIG = "omnibus.rb".freeze
36
36
 
37
- autoload :Builder, "omnibus/builder"
38
- autoload :BuildVersion, "omnibus/build_version"
39
- autoload :BuildVersionDSL, "omnibus/build_version_dsl"
40
- autoload :Cleaner, "omnibus/cleaner"
41
- autoload :Compressor, "omnibus/compressor"
42
- autoload :Config, "omnibus/config"
43
- autoload :Error, "omnibus/exceptions"
44
- autoload :FileSyncer, "omnibus/file_syncer"
45
- autoload :Generator, "omnibus/generator"
46
- autoload :GitCache, "omnibus/git_cache"
47
- autoload :HealthCheck, "omnibus/health_check"
48
- autoload :Instrumentation, "omnibus/instrumentation"
49
- autoload :Library, "omnibus/library"
50
- autoload :Logger, "omnibus/logger"
51
- autoload :Logging, "omnibus/logging"
52
- autoload :Metadata, "omnibus/metadata"
53
- autoload :NullArgumentable, "omnibus/null_argumentable"
54
- autoload :Ohai, "omnibus/ohai"
55
- autoload :Package, "omnibus/package"
56
- autoload :Packager, "omnibus/packager"
57
- autoload :Project, "omnibus/project"
58
- autoload :Publisher, "omnibus/publisher"
59
- autoload :Reports, "omnibus/reports"
60
- autoload :S3Cache, "omnibus/s3_cache"
61
- autoload :Software, "omnibus/software"
62
- autoload :Templating, "omnibus/templating"
63
- autoload :ThreadPool, "omnibus/thread_pool"
64
- autoload :Licensing, "omnibus/licensing"
37
+ autoload :Builder, "omnibus/builder"
38
+ autoload :BuildVersion, "omnibus/build_version"
39
+ autoload :BuildVersionDSL, "omnibus/build_version_dsl"
40
+ autoload :BuildSystemMetadata, "omnibus/build_system_metadata"
41
+ autoload :Buildkite, "omnibus/build_system_metadata/buildkite"
42
+ autoload :Cleaner, "omnibus/cleaner"
43
+ autoload :Compressor, "omnibus/compressor"
44
+ autoload :Config, "omnibus/config"
45
+ autoload :Error, "omnibus/exceptions"
46
+ autoload :FileSyncer, "omnibus/file_syncer"
47
+ autoload :Generator, "omnibus/generator"
48
+ autoload :GitCache, "omnibus/git_cache"
49
+ autoload :HealthCheck, "omnibus/health_check"
50
+ autoload :Instrumentation, "omnibus/instrumentation"
51
+ autoload :Library, "omnibus/library"
52
+ autoload :Logger, "omnibus/logger"
53
+ autoload :Logging, "omnibus/logging"
54
+ autoload :Metadata, "omnibus/metadata"
55
+ autoload :NullArgumentable, "omnibus/null_argumentable"
56
+ autoload :Ohai, "omnibus/ohai"
57
+ autoload :Package, "omnibus/package"
58
+ autoload :Packager, "omnibus/packager"
59
+ autoload :Project, "omnibus/project"
60
+ autoload :Publisher, "omnibus/publisher"
61
+ autoload :Reports, "omnibus/reports"
62
+ autoload :S3Cache, "omnibus/s3_cache"
63
+ autoload :Software, "omnibus/software"
64
+ autoload :Templating, "omnibus/templating"
65
+ autoload :ThreadPool, "omnibus/thread_pool"
66
+ autoload :Licensing, "omnibus/licensing"
65
67
 
66
68
  autoload :GitFetcher, "omnibus/fetchers/git_fetcher"
67
69
  autoload :NetFetcher, "omnibus/fetchers/net_fetcher"
@@ -77,16 +79,16 @@ module Omnibus
77
79
  autoload :ManifestEntry, "omnibus/manifest_entry"
78
80
  autoload :ManifestDiff, "omnibus/manifest_diff"
79
81
 
80
- autoload :ChangeLog, "omnibus/changelog"
81
- autoload :GitRepository, "omnibus/git_repository"
82
+ autoload :ChangeLog, "omnibus/changelog"
83
+ autoload :GitRepository, "omnibus/git_repository"
82
84
 
83
85
  autoload :SemanticVersion, "omnibus/semantic_version"
84
86
 
85
87
  module Command
86
- autoload :Base, "omnibus/cli/base"
87
- autoload :Cache, "omnibus/cli/cache"
88
- autoload :Publish, "omnibus/cli/publish"
89
- autoload :ChangeLog, "omnibus/cli/changelog"
88
+ autoload :Base, "omnibus/cli/base"
89
+ autoload :Cache, "omnibus/cli/cache"
90
+ autoload :Publish, "omnibus/cli/publish"
91
+ autoload :ChangeLog, "omnibus/cli/changelog"
90
92
  end
91
93
 
92
94
  class << self
@@ -0,0 +1,82 @@
1
+ require "spec_helper"
2
+
3
+ module Omnibus
4
+ describe BuildSystemMetadata do
5
+
6
+ let(:ami_id) { "ami-1234ab5678cd9ef01" }
7
+ let(:hostname) { "CHF-V-ABC-DE000.local" }
8
+ let(:docker_version) { "20.0.0" }
9
+ let(:docker_image) { "artifactory-url.com/release-type/base-platform" }
10
+ let(:docker_command) { "docker build . -f images/omnibus_toolchain_containers/platform/Dockerfile -t artifactory-url.com/release-type/omnibus-toolchain-platform -t chefes/omnibus-toolchain-platform --build-arg OS_IMAGE=#{docker_image}" }
11
+
12
+ subject(:buildkite_metadata) { Omnibus::Buildkite }
13
+
14
+ describe "#to_hash" do
15
+ context "builds occur on buildkite" do
16
+
17
+ before(:each) do
18
+ clear_defaults
19
+ end
20
+
21
+ it "returns an ami_id if one is found" do
22
+ with_ami_id
23
+ expect(buildkite_metadata.to_hash[:ami_id]).to eq(ami_id)
24
+ end
25
+
26
+ it "returns an hostname if one is found" do
27
+ with_hostname
28
+ expect(buildkite_metadata.to_hash[:hostname]).to eq(hostname)
29
+ end
30
+
31
+ it "returns is_docker_build if one is found" do
32
+ with_docker
33
+ expect(buildkite_metadata.to_hash[:is_docker_build]).to eq(true)
34
+ end
35
+
36
+ it "returns a docker_version if one is found" do
37
+ with_docker
38
+ expect(buildkite_metadata.to_hash[:docker_version]).to eq(docker_version)
39
+ end
40
+
41
+ it "returns a docker_image if one is found" do
42
+ with_docker
43
+ expect(buildkite_metadata.to_hash[:docker_image]).to eq(docker_image)
44
+ end
45
+
46
+ it "returns an omnibus_version if one is found" do
47
+ expect(buildkite_metadata.to_hash[:omnibus_version]).to eq(Omnibus::VERSION)
48
+ end
49
+
50
+ end
51
+ end
52
+
53
+ def with_ami_id
54
+ stub_env("BUILDKITE_AGENT_META_DATA_AWS_AMI_ID", ami_id)
55
+ end
56
+
57
+ def with_hostname
58
+ stub_env("BUILDKITE_AGENT_META_DATA_HOSTNAME", hostname)
59
+ end
60
+
61
+ def with_docker
62
+ stub_env("BUILDKITE_AGENT_META_DATA_DOCKER", docker_version)
63
+ stub_env("BUILDKITE_COMMAND", docker_command)
64
+ end
65
+
66
+ def clear_defaults
67
+ without_ami_id_and_hostname
68
+ without_docker
69
+ end
70
+
71
+ def without_ami_id_and_hostname
72
+ stub_env("BUILDKITE_AGENT_META_DATA_AWS_AMI_ID", nil)
73
+ stub_env("BUILDKITE_AGENT_META_DATA_HOSTNAME", nil)
74
+ end
75
+
76
+ def without_docker
77
+ stub_env("BUILDKITE_AGENT_META_DATA_DOCKER", nil)
78
+ stub_env("BUILDKITE_COMMAND", nil)
79
+ end
80
+
81
+ end
82
+ end
@@ -0,0 +1,207 @@
1
+ require "spec_helper"
2
+
3
+ module Omnibus
4
+ describe Buildkite do
5
+
6
+ let(:ami_id) { "ami-1234ab5678cd9ef01" }
7
+ let(:hostname) { "CHF-V-ABC-DE000.local" }
8
+ let(:docker_version) { "20.0.0" }
9
+ let(:docker_image) { "artifactory-url.com/release-type/base-platform" }
10
+ let(:docker_command) { "docker build . -f images/omnibus_toolchain_containers/platform/Dockerfile -t artifactory-url.com/release-type/omnibus-toolchain-platform -t chefes/omnibus-toolchain-platform --build-arg OS_IMAGE=#{docker_image}" }
11
+
12
+ subject(:buildkite_metadata) { described_class }
13
+
14
+ before(:each) do
15
+ clear_defaults
16
+ end
17
+
18
+ describe "#ami_id" do
19
+ it "returns the ami_id if one is found" do
20
+ with_ami_id
21
+ expect(buildkite_metadata.ami_id).to eq(ami_id)
22
+ end
23
+
24
+ it "returns the unknown if nothing present" do
25
+ expect(buildkite_metadata.ami_id).to eq("unknown")
26
+ end
27
+ end
28
+
29
+ describe "#hostname" do
30
+ it "returns the hostname if one is found" do
31
+ with_hostname
32
+ expect(buildkite_metadata.hostname).to eq(hostname)
33
+ end
34
+
35
+ it "returns the unknown if nothing present" do
36
+ expect(buildkite_metadata.hostname).to eq("unknown")
37
+ end
38
+ end
39
+
40
+ describe "#is_docker_build" do
41
+ it "returns true if docker metadata is present" do
42
+ with_docker
43
+ expect(buildkite_metadata.is_docker_build).to eq(true)
44
+ end
45
+
46
+ it "returns false if docker metadata is missing" do
47
+ expect(buildkite_metadata.is_docker_build).to eq(false)
48
+ end
49
+ end
50
+
51
+ describe "#docker_version" do
52
+ it "returns the docker version if one is found" do
53
+ with_docker
54
+ expect(buildkite_metadata.docker_version).to eq(docker_version)
55
+ end
56
+
57
+ it "returns nothing if docker version is missing" do
58
+ expect(buildkite_metadata.docker_version).to be_nil
59
+ end
60
+ end
61
+
62
+ describe "#docker_image" do
63
+ it "returns the docker image id if one is found" do
64
+ with_docker
65
+ expect(buildkite_metadata.docker_image).to eq(docker_image)
66
+ end
67
+
68
+ it "returns nothing if docker image id is missing" do
69
+ expect(buildkite_metadata.docker_image).to be_nil
70
+ end
71
+ end
72
+
73
+ describe "#omnibus_version" do
74
+ it "returns the omnibus_version if one is found" do
75
+ expect(buildkite_metadata.omnibus_version).to eq(Omnibus::VERSION)
76
+ end
77
+ end
78
+
79
+ describe "#to_hash" do
80
+ it "returns an ami_id if one is found" do
81
+ with_ami_id
82
+ expect(buildkite_metadata.to_hash[:ami_id]).to eq(ami_id)
83
+ end
84
+
85
+ it "returns an hostname if one is found" do
86
+ with_hostname
87
+ expect(buildkite_metadata.to_hash[:hostname]).to eq(hostname)
88
+ end
89
+
90
+ it "returns is_docker_build if one is found" do
91
+ with_docker
92
+ expect(buildkite_metadata.to_hash[:is_docker_build]).to eq(true)
93
+ end
94
+
95
+ it "returns a docker_version if one is found" do
96
+ with_docker
97
+ expect(buildkite_metadata.to_hash[:docker_version]).to eq(docker_version)
98
+ end
99
+
100
+ it "returns a docker_image if one is found" do
101
+ with_docker
102
+ expect(buildkite_metadata.to_hash[:docker_image]).to eq(docker_image)
103
+ end
104
+
105
+ it "returns an omnibus_version if one is found" do
106
+ expect(buildkite_metadata.to_hash[:omnibus_version]).to eq(Omnibus::VERSION)
107
+ end
108
+ end
109
+
110
+ context "platform builds on linux" do
111
+ it "uses docker" do
112
+ with_ami_id
113
+ with_docker
114
+
115
+ expect(buildkite_metadata.ami_id).to eq(ami_id)
116
+ expect(buildkite_metadata.is_docker_build).to eq(true)
117
+ expect(buildkite_metadata.docker_version).to eq(docker_version)
118
+ expect(buildkite_metadata.docker_image).to eq(docker_image)
119
+ expect(buildkite_metadata.omnibus_version).to eq(Omnibus::VERSION)
120
+ end
121
+
122
+ it "does not use docker" do
123
+ with_ami_id
124
+
125
+ expect(buildkite_metadata.ami_id).to eq(ami_id)
126
+ expect(buildkite_metadata.is_docker_build).to eq(false)
127
+ expect(buildkite_metadata.docker_version).to be_nil
128
+ expect(buildkite_metadata.docker_image).to be_nil
129
+ expect(buildkite_metadata.omnibus_version).to eq(Omnibus::VERSION)
130
+ end
131
+ end
132
+
133
+ context "platform builds on windows" do
134
+ it "uses docker" do
135
+ with_ami_id
136
+ with_docker
137
+
138
+ expect(buildkite_metadata.ami_id).to eq(ami_id)
139
+ expect(buildkite_metadata.is_docker_build).to eq(true)
140
+ expect(buildkite_metadata.docker_version).to eq(docker_version)
141
+ expect(buildkite_metadata.docker_image).to eq(docker_image)
142
+ expect(buildkite_metadata.omnibus_version).to eq(Omnibus::VERSION)
143
+ end
144
+
145
+ it "does not use docker" do
146
+ with_ami_id
147
+
148
+ expect(buildkite_metadata.ami_id).to eq(ami_id)
149
+ expect(buildkite_metadata.is_docker_build).to eq(false)
150
+ expect(buildkite_metadata.docker_version).to be_nil
151
+ expect(buildkite_metadata.docker_image).to be_nil
152
+ expect(buildkite_metadata.omnibus_version).to eq(Omnibus::VERSION)
153
+ end
154
+ end
155
+
156
+ describe "platform builds on macOS" do
157
+ it "uses docker" do
158
+ with_hostname
159
+ with_docker
160
+
161
+ expect(buildkite_metadata.hostname).to eq(hostname)
162
+ expect(buildkite_metadata.is_docker_build).to eq(true)
163
+ expect(buildkite_metadata.docker_version).to eq(docker_version)
164
+ expect(buildkite_metadata.docker_image).to eq(docker_image)
165
+ expect(buildkite_metadata.omnibus_version).to eq(Omnibus::VERSION)
166
+ end
167
+
168
+ it "does not use docker" do
169
+ with_hostname
170
+
171
+ expect(buildkite_metadata.hostname).to eq(hostname)
172
+ expect(buildkite_metadata.is_docker_build).to eq(false)
173
+ expect(buildkite_metadata.docker_version).to be_nil
174
+ expect(buildkite_metadata.docker_image).to be_nil
175
+ expect(buildkite_metadata.omnibus_version).to eq(Omnibus::VERSION)
176
+ end
177
+ end
178
+
179
+ def with_ami_id
180
+ stub_env("BUILDKITE_AGENT_META_DATA_AWS_AMI_ID", ami_id)
181
+ end
182
+
183
+ def with_hostname
184
+ stub_env("BUILDKITE_AGENT_META_DATA_HOSTNAME", hostname)
185
+ end
186
+
187
+ def with_docker
188
+ stub_env("BUILDKITE_AGENT_META_DATA_DOCKER", docker_version)
189
+ stub_env("BUILDKITE_COMMAND", docker_command)
190
+ end
191
+
192
+ def clear_defaults
193
+ without_ami_id_and_hostname
194
+ without_docker
195
+ end
196
+
197
+ def without_ami_id_and_hostname
198
+ stub_env("BUILDKITE_AGENT_META_DATA_AWS_AMI_ID", nil)
199
+ stub_env("BUILDKITE_AGENT_META_DATA_HOSTNAME", nil)
200
+ end
201
+
202
+ def without_docker
203
+ stub_env("BUILDKITE_AGENT_META_DATA_DOCKER", nil)
204
+ stub_env("BUILDKITE_COMMAND", nil)
205
+ end
206
+ end
207
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnibus
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.0.12
4
+ version: 9.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-17 00:00:00.000000000 Z
11
+ date: 2023-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -372,6 +372,8 @@ files:
372
372
  - lib/omnibus.rb
373
373
  - lib/omnibus/assets/README-logo.png
374
374
  - lib/omnibus/assets/logo.psd
375
+ - lib/omnibus/build_system_metadata.rb
376
+ - lib/omnibus/build_system_metadata/buildkite.rb
375
377
  - lib/omnibus/build_version.rb
376
378
  - lib/omnibus/build_version_dsl.rb
377
379
  - lib/omnibus/builder.rb
@@ -522,9 +524,11 @@ files:
522
524
  - spec/support/output_helpers.rb
523
525
  - spec/support/path_helpers.rb
524
526
  - spec/support/shell_helpers.rb
527
+ - spec/unit/build_system_metadata_spec.rb
525
528
  - spec/unit/build_version_dsl_spec.rb
526
529
  - spec/unit/build_version_spec.rb
527
530
  - spec/unit/builder_spec.rb
531
+ - spec/unit/buildkite_spec.rb
528
532
  - spec/unit/changelog_spec.rb
529
533
  - spec/unit/changelogprinter_spec.rb
530
534
  - spec/unit/cleanroom_spec.rb
@@ -626,9 +630,11 @@ test_files:
626
630
  - spec/support/output_helpers.rb
627
631
  - spec/support/path_helpers.rb
628
632
  - spec/support/shell_helpers.rb
633
+ - spec/unit/build_system_metadata_spec.rb
629
634
  - spec/unit/build_version_dsl_spec.rb
630
635
  - spec/unit/build_version_spec.rb
631
636
  - spec/unit/builder_spec.rb
637
+ - spec/unit/buildkite_spec.rb
632
638
  - spec/unit/changelog_spec.rb
633
639
  - spec/unit/changelogprinter_spec.rb
634
640
  - spec/unit/cleanroom_spec.rb