diff options
author | John McCrae <john.mccrae@progress.com> | 2023-05-15 16:34:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-15 16:34:39 -0700 |
commit | 24becb07f1f07b7cb04edb8d28958e56dbfc10e4 (patch) | |
tree | f24469be6f397b36cb7310625c6990145f2f2675 | |
parent | 606ca7d280680959c5aa85636f2f054c4e25e017 (diff) | |
parent | 59d21767410c8f1e940257b225dc34ab703eefeb (diff) | |
download | chef-24becb07f1f07b7cb04edb8d28958e56dbfc10e4.tar.gz |
Merge pull request #13753 from chef/jfm/chef17-eol_update
[chef-17] 26 of X - Updating EOL Support
-rw-r--r-- | EOL_override | 1 | ||||
-rw-r--r-- | lib/chef/client.rb | 19 | ||||
-rw-r--r-- | spec/unit/client_spec.rb | 7 |
3 files changed, 23 insertions, 4 deletions
diff --git a/EOL_override b/EOL_override new file mode 100644 index 0000000000..eb8ed45062 --- /dev/null +++ b/EOL_override @@ -0,0 +1 @@ +2024-1-31 diff --git a/lib/chef/client.rb b/lib/chef/client.rb index 7f184d7db4..a7f2b99f8e 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -326,12 +326,27 @@ class Chef def warn_if_eol require_relative "version" + # New Date format is YYYY-MM-DD or false + new_date = eol_override + # We make a release every year so take the version you're on + 2006 and you get # the year it goes EOL eol_year = 2006 + Gem::Version.new(Chef::VERSION).segments.first + cut_off_date = !!new_date ? Time.parse(new_date) : Time.new(eol_year, 5, 01) + + return if Time.now < cut_off_date - if Time.now > Time.new(eol_year, 5, 01) - logger.warn("This release of #{ChefUtils::Dist::Infra::PRODUCT} became end of life (EOL) on May 1st #{eol_year}. Please update to a supported release to receive new features, bug fixes, and security updates.") + logger.warn("This release of #{ChefUtils::Dist::Infra::PRODUCT} became end of life (EOL) on #{cut_off_date.strftime("%b %d, %Y")}. Please update to a supported release to receive new features, bug fixes, and security updates.") + end + + def eol_override + # If you want to override the existing EOL date, add a file in the root of Chef + # put a date in it in the form of YYYY-DD-MM. + override_file = "EOL_override" + if File.exist?(override_file) + File.read(File.expand_path(override_file)).strip + else + false end end diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index b6a321c8e8..ba25285278 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -311,8 +311,11 @@ describe Chef::Client do describe "eol release warning" do it "warns when running an EOL release" do stub_const("Chef::VERSION", 15) - allow(Time).to receive(:now).and_return(Time.new(2021, 5, 1, 5)) - expect(logger).to receive(:warn).with(/This release of.*became end of life \(EOL\) on May 1st 2021/) + # added a call to client because Time.now gets invoked multiple times during instantiation. Don't mock Time until after client initialized + client + expect(Time).to receive(:now).and_return(Time.new(2021, 5, 1, 5)) + allow(client).to receive(:eol_override).and_return(false) + expect(logger).to receive(:warn).with("This release of Chef Infra Client became end of life (EOL) on May 01, 2021. Please update to a supported release to receive new features, bug fixes, and security updates.") client.warn_if_eol end |