Sha256: 933cc70f16317f8a9d2215b703ce0286891cde58dc530739a9f00322a046d7b5

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require "thor"
require "byebug"

require_relative "../session"
require_relative "./constants"

module NeetoDeploy
  class CLI
    module Redis
      class Set < CLI::Base
        include Constants
        include Session

        attr_reader :addon_name, :key, :value

        def initialize(options)
          super()
          @addon_name = options[:addon_name]
          @key = options[:key]
          @value = options[:value]
        end

        def run
          unless valid_config?
            ui.error("Could not set cofig \"#{key}\". Please refer manageable redis configs: #{AVAILABLE_REDIS_CONFIGS_TO_EDIT}")
            return
          end

          response = send_patch_request(
            redis_addon_url, {
              addon_name:,
              command: "CONFIG set #{key} #{value}"
            }
          )

          ui.error(response) and return unless response.success?

          ui.success("Done")
        end

        private

          def valid_config?
            AVAILABLE_REDIS_CONFIGS_TO_EDIT.include?(key)
          end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
neetodeploy-1.1.4 lib/neeto_deploy/cli/redis/set.rb
neetodeploy-1.1.3 lib/neeto_deploy/cli/redis/set.rb