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