8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/chef/knife/clc_base.rb', line 8
def self.included(klass)
klass.class_eval do
option :clc_username,
:long => '--username NAME',
:description => 'Name of the user to access CLC API',
:on => :head
option :clc_password,
:long => '--password PASSWORD',
:description => 'Password for CLC user account',
:on => :head
option :clc_endpoint,
:long => '--endpoint URL',
:description => 'Alternative CLC API URL',
:on => :head
def connection
@connection ||= ::Clc::Client.new(
:username => config[:clc_username],
:password => config[:clc_password],
:endpoint => config[:clc_endpoint],
:verbosity => config[:verbosity]
)
end
attr_writer :context
def context
@context ||= {}
end
def run
$stdout.sync = true
parse_and_validate_parameters
if errors.any?
show_errors
show_usage
exit 1
else
execute
end
end
def parse_and_validate_parameters
end
def execute
end
def errors
@errors ||= []
end
def show_errors
errors.each { |message| ui.error message }
end
end
end
|