(PE-21479) Drop use of pe_family/pe_upgrade_family
The pe_family and pe_upgrade_family environment variables were only
being used as a means of signaling that we want pe_dir to be
archives/releases. (If pe_version and pe_family were equal, we'd return
archives/releases for pe_dir). This behavior was changed in the
previous commit to instead base the tarball source on the version string
format.
The only other behavior that passing family had was that if either
verison or family were nil, pe_dir would be nil. So theoretically, if
you only set pe_version to some valid version, you would get a beaker
config with no pe_dir set, and Beaker could then set pe_dir based on
BEAKER_PE_DIR or pe_dist_dir environment variables.
This commit removes family so that we can clean up pipelines which would
otherwise be setting pe_family just for the purpose of avoiding this
behavior.
It is potentially a breaking change if someone was relying on the
absence of pe_family to allow Beaker to set pe_dir as mentioned above.
Josh Partlow
6 years ago
19 | 19 | ENV['pe_version'] |
20 | 20 | end |
21 | 21 | |
22 | def pe_family | |
23 | ENV['pe_family'] | |
24 | end | |
25 | ||
26 | 22 | def pe_upgrade_version |
27 | 23 | ENV['pe_upgrade_version'] |
28 | 24 | end |
29 | 25 | |
30 | def pe_upgrade_family | |
31 | ENV['pe_upgrade_family'] | |
32 | end | |
33 | ||
34 | def pe_dir(version, family) | |
35 | # XXX family is no longer used, but it is possible that a job relied on the | |
36 | # behavior that not setting family would return nil for pe_dir(), allowing beaker | |
37 | # to pick up from ENV['BEAKER_PE_DIR'] or ENV['pe_dist_dir'] | |
38 | # https://github.com/puppetlabs/beaker/blob/3f52daf76b8b0a47a101a8ea76fbe4ace1e8efaf/lib/beaker/options/presets.rb#L25 | |
39 | if version && family | |
40 | base_regex = '(\A\d+\.\d+)\.\d+' | |
41 | source = case version | |
42 | when /#{base_regex}\Z/ | |
43 | then "#{PE_TARBALL_SERVER}/archives/releases/#{version}/" | |
44 | when /#{base_regex}-rc\d+\Z/ | |
45 | then "#{PE_TARBALL_SERVER}/archives/internal/%s/" | |
46 | when /#{base_regex}-.*PEZ_.*/ | |
47 | then "#{PE_TARBALL_SERVER}/%s/feature/ci-ready" | |
48 | when /#{base_regex}-.*/ | |
49 | then "#{PE_TARBALL_SERVER}/%s/ci-ready" | |
50 | end | |
51 | return sprintf(source, $1) | |
26 | def pe_dir(version) | |
27 | return if version.nil? | |
28 | ||
29 | base_regex = '(\A\d+\.\d+)\.\d+' | |
30 | source = case version | |
31 | when /#{base_regex}\Z/ | |
32 | then "#{PE_TARBALL_SERVER}/archives/releases/#{version}/" | |
33 | when /#{base_regex}-rc\d+\Z/ | |
34 | then "#{PE_TARBALL_SERVER}/archives/internal/%s/" | |
35 | when /#{base_regex}-.*PEZ_.*/ | |
36 | then "#{PE_TARBALL_SERVER}/%s/feature/ci-ready" | |
37 | when /#{base_regex}-.*/ | |
38 | then "#{PE_TARBALL_SERVER}/%s/ci-ready" | |
52 | 39 | end |
40 | return sprintf(source, $1) | |
53 | 41 | end |
54 | 42 | |
55 | 43 | PE_USE_WIN32 = ENV['pe_use_win32'] |
64 | 52 | |
65 | 53 | def base_host_config(options) |
66 | 54 | { |
67 | 'pe_dir' => options[:pe_dir] || pe_dir(pe_version, pe_family), | |
55 | 'pe_dir' => options[:pe_dir] || pe_dir(pe_version), | |
68 | 56 | 'pe_ver' => options[:pe_ver] || pe_version, |
69 | 'pe_upgrade_dir' => options[:pe_upgrade_dir] || pe_dir(pe_upgrade_version, pe_upgrade_family), | |
57 | 'pe_upgrade_dir' => options[:pe_upgrade_dir] || pe_dir(pe_upgrade_version), | |
70 | 58 | 'pe_upgrade_ver' => options[:pe_upgrade_ver] || pe_upgrade_version, |
71 | 59 | } |
72 | 60 | end |
6 | 6 | module Utils |
7 | 7 | module_function |
8 | 8 | |
9 | def pe_dir(version, family) | |
10 | BeakerHostGenerator::Data.pe_dir(version, family) | |
9 | def pe_dir(version, family = nil) | |
10 | BeakerHostGenerator::Data.pe_dir(version) | |
11 | 11 | end |
12 | 12 | |
13 | 13 | def fixup_node(cfg) |
96 | 96 | let(:rc_version) { '2017.3.0-rc4' } |
97 | 97 | |
98 | 98 | it "returns ci-ready for a dev version" do |
99 | expect(BeakerHostGenerator::Data.pe_dir(dev_version, '2017.3')).to match(%r{2017\.3/ci-ready}) | |
100 | expect(BeakerHostGenerator::Data.pe_dir(dev_version_no_rc, '2017.3')).to match(%r{2017\.3/ci-ready}) | |
101 | end | |
102 | ||
103 | it "returns ci-ready even if pe_family matches" do | |
104 | expect(BeakerHostGenerator::Data.pe_dir(dev_version, dev_version)).to match(%r{2017\.3/ci-ready}) | |
105 | expect(BeakerHostGenerator::Data.pe_dir(dev_version_no_rc, dev_version_no_rc)).to match(%r{2017\.3/ci-ready}) | |
99 | expect(BeakerHostGenerator::Data.pe_dir(dev_version)).to match(%r{2017\.3/ci-ready}) | |
100 | expect(BeakerHostGenerator::Data.pe_dir(dev_version_no_rc)).to match(%r{2017\.3/ci-ready}) | |
106 | 101 | end |
107 | 102 | |
108 | 103 | it "returns archives/releases for a release version" do |
109 | expect(BeakerHostGenerator::Data.pe_dir(release_version, '2017.3')).to match(%r{archives/releases/2017\.2}) | |
104 | expect(BeakerHostGenerator::Data.pe_dir(release_version)).to match(%r{archives/releases/2017\.2}) | |
110 | 105 | end |
111 | 106 | |
112 | 107 | it "returns archives/internal for an rc version" do |
113 | expect(BeakerHostGenerator::Data.pe_dir(rc_version, '2017.3')).to match(%r{archives/internal/2017\.3}) | |
114 | end | |
115 | ||
116 | it "returns archives/internal for an rc version even if pe_family matches" do | |
117 | expect(BeakerHostGenerator::Data.pe_dir(rc_version, rc_version)).to match(%r{archives/internal/2017\.3}) | |
108 | expect(BeakerHostGenerator::Data.pe_dir(rc_version)).to match(%r{archives/internal/2017\.3}) | |
118 | 109 | end |
119 | 110 | |
120 | 111 | it "returns feature/ci-ready for a PEZ version" do |
121 | expect(BeakerHostGenerator::Data.pe_dir(pez_version, '2017.3')).to match(%r{2017\.3/feature/ci-ready}) | |
112 | expect(BeakerHostGenerator::Data.pe_dir(pez_version)).to match(%r{2017\.3/feature/ci-ready}) | |
122 | 113 | end |
123 | 114 | |
124 | it "(backwards compatible) returns archives/release if pe_version matches pe_family" do | |
125 | expect(BeakerHostGenerator::Data.pe_dir(release_version, release_version)).to match(%r{archives/releases/2017\.2\.2}) | |
126 | end | |
127 | ||
128 | it "(backwords compatible) returns nil if eiher argument is nil" do | |
129 | expect(BeakerHostGenerator::Data.pe_dir(nil, '2017.3')).to be_nil | |
130 | expect(BeakerHostGenerator::Data.pe_dir(dev_version, nil)).to be_nil | |
115 | it "returns nil if version is nil" do | |
116 | expect(BeakerHostGenerator::Data.pe_dir(nil)).to be_nil | |
131 | 117 | end |
132 | 118 | end |
133 | 119 | end |