module Gitlab::Configuration
Defines constants and methods related to configuration.
Constants
- DEFAULT_USER_AGENT
-
The user agent that will be sent to the
API
endpoint if none is set. - VALID_OPTIONS_KEYS
-
An array of valid keys in the options hash when configuring a
Gitlab::API
.
Public Class Methods
Source
# File lib/gitlab/configuration.rb, line 20 def self.extended(base) base.reset end
Sets all configuration options to their default values when this module is extended.
Public Instance Methods
Source
# File lib/gitlab/configuration.rb, line 25 def configure yield self end
Convenience method to allow configuration options to be set in a block.
Source
# File lib/gitlab/configuration.rb, line 30 def options VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end
Creates a hash of options and their values.
Source
# File lib/gitlab/configuration.rb, line 37 def reset self.endpoint = ENV['GITLAB_API_ENDPOINT'] || ENV['CI_API_V4_URL'] self.private_token = ENV['GITLAB_API_PRIVATE_TOKEN'] || ENV['GITLAB_API_AUTH_TOKEN'] self.pat_prefix = nil self.httparty = get_httparty_config(ENV['GITLAB_API_HTTPARTY_OPTIONS']) self.sudo = nil self.user_agent = DEFAULT_USER_AGENT self.body_as_json = false end
Resets all configuration options to the defaults.
Private Instance Methods
Source
# File lib/gitlab/configuration.rb, line 50 def get_httparty_config(options) return if options.nil? httparty = Gitlab::CLI::Helpers.yaml_load(options) raise ArgumentError, 'HTTParty config should be a Hash.' unless httparty.is_a? Hash Gitlab::CLI::Helpers.symbolize_keys httparty end
Allows HTTParty config to be specified in ENV using YAML hash.