Skip to content

Commit af43f90

Browse files
committed
Remove pre-2019 references and code
Only Windows 2019 is supported. Introduce `SPEC_ROOT` and `REPO_ROOT` replacing relative path traversals.
1 parent d772dc6 commit af43f90

File tree

14 files changed

+45
-70
lines changed

14 files changed

+45
-70
lines changed

lib/packer/config/aws.rb

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,14 @@ def initialize(aws_access_key:, aws_secret_key:, aws_role_arn: nil, region:, os:
1818
def builders
1919
stemcell_builder_dir = File.expand_path('../../../../', __FILE__)
2020
packer_ci_private_key_location = ENV.fetch('PACKER_CI_PRIVATE_KEY_LOCATION', '../packer-ci-private-key/key')
21-
#TODO deleteme. Added to resolve a winrm with newer source ami (ami-0060daada4a15ad8a)
22-
source_ami = @region[:base_ami]
23-
if @os == 'windows2012R2'
24-
source_ami = "ami-067ff23da8261d1c7"
25-
end
2621
[
2722
{
2823
name: "amazon-ebs-#{@region[:name]}",
2924
type: 'amazon-ebs',
3025
access_key: @aws_access_key,
3126
secret_key: @aws_secret_key,
3227
region: @region[:name],
33-
source_ami: source_ami,
28+
source_ami: @region[:base_ami],
3429
instance_type: instance_type,
3530
ami_name: "BOSH-#{SecureRandom.uuid}-#{@region[:name]}",
3631
vpc_id: @region[:vpc_id],
@@ -69,23 +64,14 @@ def assume_role_parameters
6964
end
7065

7166
def instance_type
72-
type = 'm4.large'
73-
74-
if @os == 'windows2012R2'
75-
type = 'm4.xlarge'
76-
end
77-
78-
type
67+
'm4.large'
7968
end
8069

8170
def launch_block_device_mappings
82-
volume_size = 30
83-
volume_size = 128 if @os == 'windows2012R2'
84-
8571
[
8672
{
8773
'device_name': '/dev/sda1',
88-
'volume_size': volume_size,
74+
'volume_size': 30,
8975
'volume_type': 'gp2',
9076
'delete_on_termination': true,
9177
}

lib/packer/config/azure.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def builders
4040
'location' => @location,
4141
'vm_size' => @vm_size,
4242
'os_type' => 'Windows',
43-
'os_disk_size_gb' => os_disk_size_gb,
43+
'os_disk_size_gb' => 30,
4444
'communicator' => 'winrm',
4545
'winrm_use_ssl' => 'true',
4646
'winrm_insecure' => 'true',
@@ -60,16 +60,6 @@ def dump
6060
'provisioners' => provisioners
6161
)
6262
end
63-
64-
private
65-
66-
def os_disk_size_gb
67-
if @os == 'windows2012R2'
68-
128
69-
else
70-
30
71-
end
72-
end
7363
end
7464
end
7565
end

lib/packer/config/gcp.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def builders
2525
'source_image' => @source_image,
2626
'image_family' => @image_family,
2727
'zone' => 'us-east1-c',
28-
'disk_size' => disk_size,
28+
'disk_size' => 32,
2929
'image_name' => "packer-#{Time.now.to_i}",
3030
'machine_type' => 'n1-standard-4',
3131
'omit_external_ip' => false,
@@ -52,16 +52,6 @@ def dump
5252
'provisioners' => provisioners
5353
)
5454
end
55-
56-
private
57-
58-
def disk_size
59-
if @os == 'windows2012R2'
60-
100
61-
else
62-
32
63-
end
64-
end
6555
end
6656
end
6757
end

lib/tasks/build/azure.rake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ require 'json'
44
namespace :build do
55
desc 'Build Azure Stemcell'
66
task :azure do
7-
build_root = File.expand_path('../../../../build', __FILE__)
7+
base_dir_location = ENV.fetch('BUILD_BASE_DIR', '../../../../')
8+
base_dir = File.expand_path(base_dir_location, __FILE__)
9+
10+
build_dir = File.join(base_dir, 'build')
811
version_dir = Stemcell::Builder::validate_env_dir('VERSION_DIR')
912

1013
version = File.read(File.join(version_dir, 'number')).chomp
11-
agent_commit = File.read(File.join(build_root, 'compiled-agent', 'sha')).chomp
14+
agent_commit = File.read(File.join(build_dir, 'compiled-agent', 'sha')).chomp
1215

1316
output_directory = File.absolute_path('bosh-windows-stemcell')
1417
FileUtils.mkdir_p(output_directory)

lib/tasks/build/gcp.rake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ require 'json'
44
namespace :build do
55
desc 'Build GCP Stemcell'
66
task :gcp do
7-
build_dir = File.expand_path("../../../../build", __FILE__)
7+
base_dir_location = ENV.fetch('BUILD_BASE_DIR', '../../../../')
8+
base_dir = File.expand_path(base_dir_location, __FILE__)
9+
10+
build_dir = File.join(base_dir, 'build')
811

912
version_dir = Stemcell::Builder::validate_env_dir('VERSION_DIR')
1013
base_image_dir = Stemcell::Builder::validate_env_dir('BASE_IMAGE_DIR')

spec/integration/build/aws_spec.rb

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
require 'zlib'
88
require 's3'
99

10-
load File.expand_path('../../../../lib/tasks/build/aws.rake', __FILE__)
10+
load File.join(REPO_ROOT, 'lib/tasks/build/aws.rake')
1111

1212
describe 'Aws' do
1313
before(:each) do
1414
@original_env = ENV.to_hash
15-
@build_dir = File.expand_path('../../../../build', __FILE__)
15+
@build_dir = File.join(REPO_ROOT, 'build')
1616
@version_dir = Dir.mktmpdir('aws')
1717
@agent_dir = Dir.mktmpdir('aws')
1818
@base_amis_dir = Dir.mktmpdir('aws')
@@ -31,7 +31,7 @@
3131
ENV['PACKER_AWS_ACCESS_KEY'] = @aws_access_key = 'some-aws_access_key'
3232
ENV['PACKER_AWS_SECRET_KEY'] = @aws_secret_key = 'some-aws_secret_key'
3333
ENV['OS_VERSION'] = @os_version
34-
ENV['PATH'] = "#{File.join(File.expand_path('../../../..', __FILE__), 'spec', 'fixtures', 'aws')}:#{ENV['PATH']}"
34+
ENV['PATH'] = "#{fixture_path('aws')}:#{ENV['PATH']}"
3535
ENV['VERSION_DIR'] = @version_dir
3636
ENV['BASE_AMIS_DIR'] = @base_amis_dir
3737
ENV['OUTPUT_BUCKET_REGION'] = @output_bucket_region = 'some-output-bucket-region'
@@ -133,8 +133,7 @@
133133
)
134134

135135
ENV['DEFAULT_STEMCELL_DIR'] = @default_stemcell_dir = Dir.mktmpdir
136-
fixtures_dir = File.join('spec', 'fixtures', 'aws', 'amis')
137-
FileUtils.cp(Dir[File.join(fixtures_dir, '*1200*-us-east-1.tgz')].first, @default_stemcell_dir)
136+
FileUtils.cp(Dir[fixture_path( 'aws', 'amis', '*1200*-us-east-1.tgz')].first, @default_stemcell_dir)
138137

139138
ENV['REGIONS'] = 'us-east-2'
140139
@copied_stemcells_dir = 'copied-regional-stemcells'
@@ -236,12 +235,10 @@
236235
{'region' => 'us-east-1', 'ami_id' => 'ami-east1id'}.to_json
237236
)
238237

239-
fixtures_dir = File.join('spec', 'fixtures', 'aws', 'amis')
240-
241-
FileUtils.cp(Dir[File.join(fixtures_dir, '*1200*-some-region-1.tgz')].first, @copied1)
242-
FileUtils.cp(Dir[File.join(fixtures_dir, '*1200*-some-region-2.tgz')].first, @copied2)
243-
FileUtils.cp(Dir[File.join(fixtures_dir, '*1200*-some-region-3.tgz')].first, @copied2)
244-
FileUtils.cp(Dir[File.join(fixtures_dir, '*1200*-us-east-1.tgz')].first, @copied1)
238+
FileUtils.cp(Dir[fixture_path('aws', 'amis', '*1200*-some-region-1.tgz')].first, @copied1)
239+
FileUtils.cp(Dir[fixture_path('aws', 'amis', '*1200*-some-region-2.tgz')].first, @copied2)
240+
FileUtils.cp(Dir[fixture_path('aws', 'amis', '*1200*-some-region-3.tgz')].first, @copied2)
241+
FileUtils.cp(Dir[fixture_path('aws', 'amis', '*1200*-us-east-1.tgz')].first, @copied1)
245242
end
246243

247244
after(:each) do

spec/integration/build/azure_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
require 'yaml'
77
require 'zlib'
88

9-
load File.expand_path('../../../../lib/tasks/build/azure.rake', __FILE__)
9+
load File.join(REPO_ROOT, 'lib/tasks/build/azure.rake')
1010

1111
describe 'Azure' do
1212
before(:each) do
1313
@original_env = ENV.to_hash
14-
@build_dir = File.expand_path('../../../../build', __FILE__)
14+
@build_dir = File.join(REPO_ROOT, 'build')
1515
@output_directory = 'bosh-windows-stemcell'
1616
@version_dir = Dir.mktmpdir('azure')
1717
@stemcell_deps_dir = Dir.mktmpdir('azure')
@@ -52,7 +52,7 @@
5252
ENV['SKU'] = 'some-sku'
5353
ENV['OS_VERSION'] = os_version
5454
ENV['VERSION_DIR'] = @version_dir
55-
ENV['PATH'] = "#{File.join(@build_dir, '..', 'spec', 'fixtures', 'azure')}:#{ENV['PATH']}"
55+
ENV['PATH'] = "#{fixture_path('azure')}:#{ENV['PATH']}"
5656
ENV['BASE_IMAGE'] = 'some-base-image'
5757
ENV['BASE_IMAGE_OFFER'] = 'some-base-image-offer'
5858
ENV['STEMCELL_DEPS_DIR'] = @stemcell_deps_dir

spec/integration/build/gcp_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
require 'yaml'
77
require 'zlib'
88

9-
load File.expand_path('../../../../lib/tasks/build/gcp.rake', __FILE__)
9+
load File.join(REPO_ROOT, 'lib/tasks/build/gcp.rake')
1010

1111
describe 'Gcp' do
1212
before(:each) do
1313
@original_env = ENV.to_hash
14-
@build_dir = File.expand_path('../../../../build', __FILE__)
14+
@build_dir = File.join(REPO_ROOT, 'build')
1515
@output_directory = 'bosh-windows-stemcell'
1616
@version_dir = Dir.mktmpdir('gcp')
1717
@base_image_dir = Dir.mktmpdir('gcp')
@@ -37,7 +37,7 @@
3737

3838
ENV['ACCOUNT_JSON'] = {'project_id' => 'some-project-id'}.to_json
3939
ENV['OS_VERSION'] = os_version
40-
ENV['PATH'] = "#{File.join(@build_dir, '..', 'spec', 'fixtures', 'gcp')}:#{ENV['PATH']}"
40+
ENV['PATH'] = "#{fixture_path('gcp')}:#{ENV['PATH']}"
4141
ENV['VERSION_DIR'] = @version_dir
4242
ENV['BASE_IMAGE_DIR'] = @base_image_dir
4343
ENV['STEMCELL_DEPS_DIR'] = @stemcell_deps_dir

spec/spec_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
SimpleCov.start
1010
end
1111

12+
SPEC_ROOT = File.dirname(__FILE__).freeze
13+
REPO_ROOT = Pathname(SPEC_ROOT).parent
14+
15+
def fixture_path(*parts)
16+
File.join(SPEC_ROOT, 'fixtures', *parts)
17+
end
18+
1219
RSpec.configure do |config|
1320
config.expect_with :rspec do |expectations|
1421
expectations.include_chain_clauses_in_custom_matcher_descriptions = true

spec/stemcell/builder/aws_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
describe 'Aws' do
1818
describe 'build' do
1919
it 'builds a stemcell tarball' do
20-
os = 'windows2012R2'
20+
os = 'windows2019'
2121
version = '1234.0'
2222
amis = 'some-amis'
2323
agent_commit = 'some-agent-commit'
@@ -88,7 +88,7 @@
8888
aws_access_key = 'some-aws-access-key'
8989
aws_secret_key = 'some-aws-secret-key'
9090
packer_vars = 'some-packer-vars'
91-
os = 'windows2012R2'
91+
os = 'windows2019'
9292
vm_prefix = 'some-vm-prefix'
9393

9494
packer_config = double(:packer_config)

0 commit comments

Comments
 (0)