lib/sct/commands/cluster.rb in sct-0.1.8 vs lib/sct/commands/cluster.rb in sct-0.1.9

- old
+ new

@@ -1,52 +1,58 @@ require 'sct/command_interface' module Sct - class ClusterCommand + class ClusterCommand - IS_PUBLIC_COMMAND = true - SYNTAX = 'sct cluster up | sct cluster down | sct cluster update-config' - SUMMARY = 'Starts/stops or updates the config of the minikube cluster' - EXAMPLE = 'sct cluster up | sct cluster down | sct cluster update-config' - EXAMPLE_DESCRIPTION = 'Starts/stops or updates the config of the minikube cluster' - DESCRIPTION = "Sct cluster allows you to start, stop or update the config of the Spend Cloud minikube cluster" + IS_PUBLIC_COMMAND = true + SYNTAX = 'sct cluster up | sct cluster down | sct cluster update-config' + SUMMARY = 'Starts/stops or updates the config of the minikube cluster' + EXAMPLE = 'sct cluster up | sct cluster down | sct cluster update-config' + EXAMPLE_DESCRIPTION = 'Starts/stops or updates the config of the minikube cluster' + DESCRIPTION = "Sct cluster allows you to start, stop or update the config of the Spend Cloud minikube cluster" - OPTIONS = [] + OPTIONS = [] - def execute(args, options) - return puts "SCT has not been initialized. Run 'sct init' first.".red unless Sct::Config.exists + def execute(args, options) + return puts "SCT has not been initialized. Run 'sct init' first.".red unless Sct::Config.exists - case args[0] - when "up" - system("minikube start") - system("minikube ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'") - system("sct cluster update-config") - system("kubectl config use-context minikube") - system("kubectl delete pod -n kube-system $(kubectl get pods -n kube-system | grep registry-creds | awk '{print $1}')") - system("sudo sct hostfile") - puts "\nāœ”ļø You can now visit your environment at šŸ‘‰ https://spend-cloud.spend.cloud.local šŸ‘Œ" - when "down" - system("minikube stop") - when "update-config" - return puts "Skipping minikube config ( only needed for windows )".yellow unless Sct::Config.operatingSystem == Sct::Config::WINDOWS + if SCT::Config::Windows + minikube = "minikube.exe" + else + minikube = "minikube" + end - windows_home_path = Sct::Config.getTrueHomePath - kube_file_path = windows_home_path+"/.kube/config" + case args[0] + when "up" + system("#{minikube} start") + system("#{minikube} ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'") + system("sct cluster update-config") + system("kubectl config use-context minikube") + system("kubectl delete pod -n kube-system $(kubectl get pods -n kube-system | grep registry-creds | awk '{print $1}')") + system("sudo sct hostfile") + puts "\nāœ”ļø You can now visit your environment at šŸ‘‰ https://spend-cloud.spend.cloud.local šŸ‘Œ" + when "down" + system("#{minikube} stop") + when "update-config" + return puts "Skipping minikube config ( only needed for windows )".yellow unless Sct::Config.operatingSystem == Sct::Config::WINDOWS - if !File.exists?(kube_file_path) - return puts "#{kube_file_path} doesn't exist".red - end + windows_home_path = Sct::Config.getTrueHomePath + kube_file_path = windows_home_path+"/.kube/config" - system("sed -e 's~\\\\~/~g' -e 's~C:~/mnt/c~g' < #{kube_file_path} > ~/.kube/minikube-config") + if !File.exists?(kube_file_path) + return puts "#{kube_file_path} doesn't exist".red + end - return puts "Windows minikube config copied to ~/.kube/minikube-config".green - else - puts "Unknown or missing argument. Please run 'sct cluster up','sct cluster down' or 'sct cluster update-config'".red - end - end + system("sed -e 's~\\\\~/~g' -e 's~C:~/mnt/c~g' < #{kube_file_path} > ~/.kube/minikube-config") - implements CommandInterface + return puts "Windows minikube config copied to ~/.kube/minikube-config".green + else + puts "Unknown or missing argument. Please run 'sct cluster up','sct cluster down' or 'sct cluster update-config'".red + end + end - end + implements CommandInterface + + end end