module SecretServer::Commands::Cache
Command to control caching of Secret
values
Constants
- StrategyCacheThenServer
- StrategyCacheThenServerAllowExpired
- StrategyNever
rubocop:disable Naming/ConstantName
- StrategyServerThenCache
Public Instance Methods
cache_age()
click to toggle source
# File lib/secret_server/commands/cache.rb, line 27 def cache_age cache_strategy[1] end
cache_age=(age)
click to toggle source
# File lib/secret_server/commands/cache.rb, line 31 def cache_age=(age) unless age.is_a?(Integer) && age >= 0 raise ArgumentError, 'age must be a nonnegative integer' end sdkclient_exec('cache', '-a', age.to_s) end
cache_clear!()
click to toggle source
# File lib/secret_server/commands/cache.rb, line 38 def cache_clear! sdkclient_exec('cache', '-b') end
cache_strategy()
click to toggle source
rubocop:enable Naming/ConstantName
# File lib/secret_server/commands/cache.rb, line 12 def cache_strategy stdout, * = sdkclient_exec('cache', '-c') result = /Strategy : (\w+)(?:, Max Age : (\d+) minutes)?/.match(stdout) strategy = SecretServer::SdkClient.const_get("Strategy#{result[1]}") [strategy, result[2].to_i] end
cache_strategy=(value)
click to toggle source
# File lib/secret_server/commands/cache.rb, line 19 def cache_strategy=(value) strategy, age = value.is_a?(Array) ? value : [value, nil] validate_cache_strategy_args(strategy, age) args = ['cache', '-s', strategy.to_s] args += ['-a', age.to_s] unless age.nil? sdkclient_exec(*args) end
Private Instance Methods
validate_cache_strategy_args(strategy, age)
click to toggle source
# File lib/secret_server/commands/cache.rb, line 44 def validate_cache_strategy_args(strategy, age) unless strategy.is_a? Integer raise ArgumentError, 'strategy must be an integer' end unless (0..3).cover? strategy raise ArgumentError, 'strategy must be in the range 0 to 3 inclusive' end unless age.nil? || age.is_a?(Integer) && age >= 0 raise ArgumentError, 'age must be a nonnegative integer' end true end