Sha256: 59356a9ede8159f5ab41f42986f55b19e79e84fe8801a751222721ce1f5f7252

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

require 'sct/command_interface'

module Sct

  class ClusterCommand

    IS_PUBLIC_COMMAND = true
    SYNTAX = 'sct cluster up | sct cluster down'
    SUMMARY = 'Starts or stops the minikube cluster'
    EXAMPLE = 'sct cluster up | sct cluster down'
    EXAMPLE_DESCRIPTION = 'Starts or stops the spend cloud cluster'
    DESCRIPTION = "Sct cluster allows you to start and stop the Spend Cloud minikube cluster"

    OPTIONS = []

    def execute(args, options)
      return puts "SCT has not been initialized. Run 'sct init' first.".red unless Sct::Config.exists

      if `uname -a`.match?("Microsoft")
        minikube = "minikube.exe"
      else
        minikube = "minikube"
      end

      case args[0]
        when "up"
          system("#{minikube} start")
          system("sudo sct hostfile")
          system("#{minikube} ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'")
          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}')")
          puts "\nāœ”ļø  You can now visit your environment at šŸ‘‰ https://spend-cloud.spend.cloud.local šŸ‘Œ"
        when "down"
          system("#{minikube} stop")
        else
          puts "Unknown or missing argument. Please run 'sct cluster up' or 'sct cluster down'"
      end
    end

    implements CommandInterface

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sct-0.1.6 lib/sct/commands/cluster.rb
sct-0.1.5 lib/sct/commands/cluster.rb