Sha256: 3d78e2fcc488c08841fa2bc50ecf8f02bd65727ee96116ef363f5bb09723c523

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

require 'sct/command_interface'
require 'sct/command_option'
require "sct/sct_folder"
require "sct/setup/helpers"

module Sct

  class Mysql_proxyCommand
    

    DEFAULT_SECRET_NAME = "gcloud-credentials"

    IS_PUBLIC_COMMAND = true
    SYNTAX = 'sct mysql_proxy'
    SUMMARY = 'adds a secret for the mysql proxy'
    DESCRIPTION = ""
    EXAMPLE = ""
    EXAMPLE_DESCRIPTION = ""

    OPTIONS = []
    
    @path
    @secret_name

    def initialize

      return unless setup

      @path = sct_file["cloud-proxy-path"]
      @secret_name = DEFAULT_SECRET_NAME
    end

    def self.options
      
    end

    def execute(args, options)

      return puts "No sct directory found".red unless setup
      
      system("kubectl delete secret gcloud-credentials")
      system("kubectl create secret generic gcloud-credentials --from-file=#{@path}")
      
      puts "Authenticated with secret-name: '#{@secret_name}'".green

      return true
    end

    def setup 

      return false unless Sct::SctFolder.setup?

      return true

    end

    def sct_file 

      return unless setup

      sct_file_string = File.read(Sct::SctFolder.sctfile_path)
    
      sct_file_hash = Sct::Helpers.to_hash(sct_file_string)
    
      return sct_file_hash
    end

    implements CommandInterface
  
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sct-0.1.2 lib/sct/commands/mysqlproxy.rb
sct-0.1.1 lib/sct/commands/mysqlproxy.rb
sct-0.1.0 lib/sct/commands/mysqlproxy.rb