class Octo::OctoEnvShow
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/octo.rb, line 839 def run if Chef::Config[:knife][:octo_instance].nil? ui.error("Please specify your Octopus Deploy instance in your knife config as -\nknife[:octo_instance] = 'MYOCTO.MYDOMAIN'") exit end if Chef::Config[:knife][:octo_apikey].nil? ui.error("Please specify your Octopus API key in your knife config as -\nknife[:octo_apikey] = 'MYKEY'\nSee Also : https://octopus.com/docs/api-and-integration/api/how-to-create-an-api-key") exit end if name_args.size > 1 ui.error("You provided two environments\nSupply only one environemnt or try quotes.") return end unless name_args.size == 1 ui.error('Provide the env name!') return end octo_methods = OctoHelperMethods.new(Chef::Config[:knife][:octo_apikey],Chef::Config[:knife][:octo_instance]) env_id = octo_methods.eid_from_name("#{name_args[0]}") if env_id['response'] == 'ok' request = octo_methods.generic_call('GET', "environments/#{env_id['message']}/machines", false) if config[:long] octo_methods.create_local_file_by_id('environments') print octo_methods.parse_env_deets(request['message'],true) print "\n" octo_methods.delete_local_file else print octo_methods.parse_env_deets(request['message'],false) print "\n" end else ui.error(env_id['message']) end end