civo / cli-rubygem

Command line interface for interacting with Civo's cloud API
https://www.civo.com
MIT License
15 stars 4 forks source link

Kube config path fix for windows. #59

Closed Johannestegner closed 4 years ago

Johannestegner commented 4 years ago

This PR should fix #58 which seems to be windows specific.

The echo %HOMEPATH%.chomp has been changed to instead just use the platform independent Dir.home which should return a more correct path than the earlier version.

Tested locally on windows 10 pro with both Cmder (conemu) and with powershell with great success!


It might also be possible to just use ENV['HOME'] seeing it is successfully used further down in the file:

    def write_file(result)
      Dir.mkdir("#{ENV['HOME']}/.kube/") unless Dir.exist?("#{ENV["HOME"]}/.kube/")
      File.write("#{ENV['HOME']}/.kube/config", result)
    end

But I'm not sure it is possible to assure that the HOME env variable is always present on windows systems.
I did not change the write_file method though, seeing it seems to work for now and could easily be changed if anyone encounters issues with it at a later point.