Last active
February 5, 2020 18:31
-
-
Save jtimberman/7471348 to your computer and use it in GitHub Desktop.
displays whether cookbooks are frozen on the chef server for a given version. put this in ~/.chef/plugins/knife.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Author: Joshua Timberman <joshua@opscode.com> | |
# Copyright (c) 2013, Opscode, Inc <legal@opscode.com> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
# displays whether cookbooks are frozen on the chef server for a given | |
# version. | |
require 'chef/knife' | |
module KnifePlugins | |
class Cbfrozen < Chef::Knife | |
banner "knife cbfrozen [COOKBOOK] [VERSION]" | |
def run | |
if @name_args.size == 0 | |
rest.get_rest("cookbooks").each_pair do |cookbook, an_hash| | |
ui.output "#{cookbook}: #{cookbook_frozen(cookbook)}" | |
end | |
else | |
cookbook_name = @name_args[0] | |
cookbook_version = @name_args.length > 1 ? @name_args[1] : '_latest' | |
ui.output "#{cookbook_name}: #{cookbook_frozen(cookbook_name, cookbook_version)}" | |
end | |
end | |
def cookbook_frozen(cb, ver = '_latest') | |
rest.get_rest("cookbooks/#{cb}/#{ver}").frozen_version? | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks!