Class: ChefAnalytics::Knife
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- ChefAnalytics::Knife
- Defined in:
- lib/chef-analytics/knife.rb
Instance Attribute Summary collapse
-
#analytics_server_url ⇒ Object
Returns the value of attribute analytics_server_url.
Instance Method Summary collapse
- #analytics_server_root ⇒ Object
-
#fetch_token ⇒ Object
helper functions.
-
#initialize(arg) ⇒ Knife
constructor
A new instance of Knife.
- #validate_and_set_params ⇒ Object
Constructor Details
#initialize(arg) ⇒ Knife
Returns a new instance of Knife.
25 26 27 |
# File 'lib/chef-analytics/knife.rb', line 25 def initialize(arg) super(arg) end |
Instance Attribute Details
#analytics_server_url ⇒ Object
Returns the value of attribute analytics_server_url.
23 24 25 |
# File 'lib/chef-analytics/knife.rb', line 23 def analytics_server_url @analytics_server_url end |
Instance Method Details
#analytics_server_root ⇒ Object
55 56 57 |
# File 'lib/chef-analytics/knife.rb', line 55 def analytics_server_root URI.join(@analytics_server_url, '/').to_s end |
#fetch_token ⇒ Object
helper functions
33 34 35 36 37 38 39 40 41 |
# File 'lib/chef-analytics/knife.rb', line 33 def fetch_token identity = ChefAnalytics::Identity.new(identity_server_url: @identity_server_url) token = identity.token if token.nil? ui.error "Couldn't get OAuth2 token from OC-ID server" exit 1 end token end |
#validate_and_set_params ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/chef-analytics/knife.rb', line 43 def validate_and_set_params @analytics_server_url ||= Chef::Config[:analytics_server_url] @analytics_server_url ||= config[:analytics_server_url] @identity_server_url ||= Chef::Config[:identity_server_url] @identity_server_url ||= config[:identity_server_url] unless @analytics_server_url ui.error "analytics_server_url not set in config or command line" exit 1 end end |