Skip to content

Commit 606bfb1

Browse files
committed
Removed the chef-cli license command
Signed-off-by: Ashique Saidalavi <Ashique.saidalavi@progress.com>
1 parent 33b8aa5 commit 606bfb1

File tree

7 files changed

+269
-269
lines changed

7 files changed

+269
-269
lines changed

chef-cli.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ Gem::Specification.new do |gem|
5050
gem.add_dependency "diff-lcs", ">= 1.2.4", "!= 1.4.0", "< 1.6.0" # 1.4 breaks output. Used in lib/chef/util/diff
5151
gem.add_dependency "pastel", "~> 0.7" # used for policyfile differ
5252
gem.add_dependency "license-acceptance", ">= 1.0.11", "< 3"
53-
gem.add_dependency "chef-licensing", "~> 1.0"
53+
# gem.add_dependency "chef-licensing", "~> 1.0"
5454
end

lib/chef-cli/builtin_commands.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757

5858
c.builtin "describe-cookbook", :DescribeCookbook, require_path: "chef-cli/command/describe_cookbook",
5959
desc: "Prints cookbook checksum information used for cookbook identifier"
60-
c.builtin "license", :License, require_path: "chef-cli/command/license",
61-
desc: "Create & install a new license on the system or view installed license(s)."
60+
# c.builtin "license", :License, require_path: "chef-cli/command/license",
61+
# desc: "Create & install a new license on the system or view installed license(s)."
6262
end

lib/chef-cli/command/license.rb

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -16,95 +16,95 @@
1616
# limitations under the License.
1717
#
1818

19-
require_relative "base"
20-
require "chef-cli/licensing/base"
21-
require_relative "../configurable"
22-
23-
module ChefCLI
24-
module Command
25-
26-
# This class will manage the license command in the chef-cli
27-
class License < Base
28-
29-
include Configurable
30-
31-
MAIN_COMMAND_HELP = <<~HELP.freeze
32-
Usage: #{ChefCLI::Dist::EXEC} license [SUBCOMMAND]
33-
34-
`#{ChefCLI::Dist::EXEC} license` command will validate the existing license
35-
or will help you interactively generate new free/trial license and activate the
36-
commercial license the chef team has sent you through email.
37-
HELP
38-
39-
SUB_COMMANDS = [
40-
{ name: "list", description: "List details of the license(s) installed on the system." },
41-
{ name: "add", description: "Create & install a Free/ Trial license or install a Commercial license on the system." },
42-
].freeze
43-
44-
option :chef_license_key,
45-
long: "--chef-license-key LICENSE",
46-
description: "New license key to accept and store in the system"
47-
48-
attr_accessor :ui
49-
50-
def self.banner
51-
<<~BANNER
52-
#{MAIN_COMMAND_HELP}
53-
Subcommands:
54-
#{SUB_COMMANDS.map do |c|
55-
" #{c[:name].ljust(7)}#{c[:description]}"
56-
end.join("\n") }
57-
58-
Options:
59-
BANNER
60-
end
61-
62-
def initialize
63-
super
64-
65-
@ui = UI.new
66-
end
67-
68-
def run(params)
69-
config_license_debug if debug?
70-
remaining_args = parse_options(params)
71-
return 1 unless validate_params!(remaining_args)
72-
73-
if remaining_args.blank?
74-
ChefCLI::Licensing::Base.validate
75-
else
76-
ChefCLI::Licensing::Base.send(remaining_args[0])
77-
end
78-
rescue ChefLicensing::LicenseKeyFetcher::LicenseKeyNotFetchedError
79-
ui.msg("License key not fetched. Please try again.")
80-
end
81-
82-
def debug?
83-
!!config[:debug]
84-
end
85-
86-
def validate_params!(args)
87-
if args.length > 1
88-
ui.err("Too many arguments")
89-
return false
90-
end
91-
92-
valid_subcommands = SUB_COMMANDS.collect { |c| c[:name] }
93-
args.each do |arg|
94-
next if valid_subcommands.include?(arg)
95-
96-
ui.err("Invalid option: #{arg}")
97-
return false
98-
end
99-
100-
true
101-
end
102-
103-
private
104-
105-
def config_license_debug
106-
ChefLicensing.output = ui
107-
end
108-
end
109-
end
110-
end
19+
# require_relative "base"
20+
# require "chef-cli/licensing/base"
21+
# require_relative "../configurable"
22+
23+
# module ChefCLI
24+
# module Command
25+
26+
# # This class will manage the license command in the chef-cli
27+
# class License < Base
28+
29+
# include Configurable
30+
31+
# MAIN_COMMAND_HELP = <<~HELP.freeze
32+
# Usage: #{ChefCLI::Dist::EXEC} license [SUBCOMMAND]
33+
34+
# `#{ChefCLI::Dist::EXEC} license` command will validate the existing license
35+
# or will help you interactively generate new free/trial license and activate the
36+
# commercial license the chef team has sent you through email.
37+
# HELP
38+
39+
# SUB_COMMANDS = [
40+
# { name: "list", description: "List details of the license(s) installed on the system." },
41+
# { name: "add", description: "Create & install a Free/ Trial license or install a Commercial license on the system." },
42+
# ].freeze
43+
44+
# option :chef_license_key,
45+
# long: "--chef-license-key LICENSE",
46+
# description: "New license key to accept and store in the system"
47+
48+
# attr_accessor :ui
49+
50+
# def self.banner
51+
# <<~BANNER
52+
# #{MAIN_COMMAND_HELP}
53+
# Subcommands:
54+
# #{SUB_COMMANDS.map do |c|
55+
# " #{c[:name].ljust(7)}#{c[:description]}"
56+
# end.join("\n") }
57+
58+
# Options:
59+
# BANNER
60+
# end
61+
62+
# def initialize
63+
# super
64+
65+
# @ui = UI.new
66+
# end
67+
68+
# def run(params)
69+
# config_license_debug if debug?
70+
# remaining_args = parse_options(params)
71+
# return 1 unless validate_params!(remaining_args)
72+
73+
# if remaining_args.blank?
74+
# ChefCLI::Licensing::Base.validate
75+
# else
76+
# ChefCLI::Licensing::Base.send(remaining_args[0])
77+
# end
78+
# rescue ChefLicensing::LicenseKeyFetcher::LicenseKeyNotFetchedError
79+
# ui.msg("License key not fetched. Please try again.")
80+
# end
81+
82+
# def debug?
83+
# !!config[:debug]
84+
# end
85+
86+
# def validate_params!(args)
87+
# if args.length > 1
88+
# ui.err("Too many arguments")
89+
# return false
90+
# end
91+
92+
# valid_subcommands = SUB_COMMANDS.collect { |c| c[:name] }
93+
# args.each do |arg|
94+
# next if valid_subcommands.include?(arg)
95+
96+
# ui.err("Invalid option: #{arg}")
97+
# return false
98+
# end
99+
100+
# true
101+
# end
102+
103+
# private
104+
105+
# def config_license_debug
106+
# ChefLicensing.output = ui
107+
# end
108+
# end
109+
# end
110+
# end

lib/chef-cli/licensing/base.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@
1616
# limitations under the License.
1717
#
1818

19-
require "chef-licensing"
20-
require_relative "config"
19+
# require "chef-licensing"
20+
# require_relative "config"
2121

22-
module ChefCLI
23-
module Licensing
24-
class Base
25-
class << self
26-
def validate
27-
ChefLicensing.fetch_and_persist.each do |license_key|
28-
puts "License Key: #{license_key}"
29-
end
30-
end
22+
# module ChefCLI
23+
# module Licensing
24+
# class Base
25+
# class << self
26+
# def validate
27+
# ChefLicensing.fetch_and_persist.each do |license_key|
28+
# puts "License Key: #{license_key}"
29+
# end
30+
# end
3131

32-
def list
33-
ChefLicensing.list_license_keys_info
34-
end
32+
# def list
33+
# ChefLicensing.list_license_keys_info
34+
# end
3535

36-
def add
37-
ChefLicensing.add_license
38-
end
39-
end
40-
end
41-
end
42-
end
36+
# def add
37+
# ChefLicensing.add_license
38+
# end
39+
# end
40+
# end
41+
# end
42+
# end

lib/chef-cli/licensing/config.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
# limitations under the License.
1717
#
1818

19-
require "chef-licensing"
19+
# require "chef-licensing"
2020

21-
ChefLicensing.configure do |config|
22-
config.chef_product_name = "workstation"
23-
config.chef_entitlement_id = "x6f3bc76-a94f-4b6c-bc97-4b7ed2b045c0"
24-
config.chef_executable_name = "chef"
25-
config.license_server_url = "https://services.chef.io/licensing"
26-
end
21+
# ChefLicensing.configure do |config|
22+
# config.chef_product_name = "workstation"
23+
# config.chef_entitlement_id = "x6f3bc76-a94f-4b6c-bc97-4b7ed2b045c0"
24+
# config.chef_executable_name = "chef"
25+
# config.license_server_url = "https://services.chef.io/licensing"
26+
# end

spec/unit/cli_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def mock_shell_out(exitstatus, stdout, stderr)
9090
commands_map.builtin "example", :TestCommand, require_path: "unit/fixtures/command/cli_test_command",
9191
desc: "Example subcommand for testing"
9292

93-
allow(ChefCLI::Licensing::Base).to receive(:validate).and_return(true)
93+
# allow(ChefCLI::Licensing::Base).to receive(:validate).and_return(true)
9494
end
9595

9696
context "given no arguments or options" do

0 commit comments

Comments
 (0)