Sha256: 34f53983867382ea0fab844596b85918acc50a82edb5f304585d6308671eb7e3
Contents?: true
Size: 1.53 KB
Versions: 4
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true module Capistrano module DataPlaneApi # Provides helper methods module Helper # @return [Hash{String => Symbol}] ADMIN_STATE_COLORS = { 'unknown' => :on_red, 'drain' => :on_blue, 'ready' => :on_green, 'maint' => :on_yellow }.freeze # @return [Hash{String => Symbol}] OPERATIONAL_STATE_COLORS = { 'unknown' => :on_red, 'up' => :on_green, 'down' => :on_red, 'stopping' => :on_yellow }.freeze # @return [Boolean] def no_haproxy? !::ENV['NO_HAPROXY'].nil? && !::ENV['NO_HAPROXY'].empty? end # @return [Boolean] def force_haproxy? !::ENV['FORCE_HAPROXY'].nil? && !::ENV['FORCE_HAPROXY'].empty? end # @param state [String, Symbol, nil] # @return [String, nil] def humanize_admin_state(state) return unless state state = state.to_s COLORS.decorate(" #{state.upcase} ", :bold, ADMIN_STATE_COLORS[state.downcase]) end # @param state [String, Symbol, nil] # @return [String, nil] def humanize_operational_state(state) return unless state state = state.to_s COLORS.decorate(" #{state.upcase} ", :bold, OPERATIONAL_STATE_COLORS[state.downcase]) end # @param backend [Capistrano::DataPlaneApi::Configuration::Backend] # @return [String] def humanize_backend_name(backend) COLORS.decorate(" #{backend.name} ", *backend.styles) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems