Class: Octo::OctoEnvList

Inherits:
Chef::Knife
  • Object
show all
Defined in:
lib/chef/knife/octo.rb

Instance Method Summary collapse

Instance Method Details

#runObject



803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
# File 'lib/chef/knife/octo.rb', line 803

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
  unless name_args.size == 0
    ui.error('This command does not take any arguments')
    return
  end
  octo_methods = OctoHelperMethods.new(Chef::Config[:knife][:octo_apikey],Chef::Config[:knife][:octo_instance])
  request = octo_methods.generic_call('GET', 'environments/all', false)
  if request['response'] == 'ok'
    if config[:long]
      print octo_methods.parse_env_list(request['message'],true)
    else
      print octo_methods.parse_env_list(request['message'],false)
    end
    print "\n"
  else
    print request['message']
  end
end