Top Level Namespace
Defined Under Namespace
Modules: Mixlib, OssStats
Instance Method Summary
collapse
Instance Method Details
#get_buildkite_token(options) ⇒ Object
1
2
3
4
5
|
# File 'lib/oss_stats/buildkite_token.rb', line 1
def get_buildkite_token(options)
return options[:buildkite_token] if options[:buildkite_tokne]
return ENV['BUILDKITE_API_TOKEN'] if ENV['BUILDKITE_API_TOKEN']
nil
end
|
#get_buildkite_token!(config = OssStats::CiStatsConfig) ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'lib/oss_stats/buildkite_token.rb', line 7
def get_buildkite_token!(config = OssStats::CiStatsConfig)
token = get_buildkite_token(config)
unless token
raise ArgumentError,
'Buildkite token not found. Set via --buildkite-token CLI option, ' +
'in the conifg, or as BUILDKITE_API_TOKEN environment variable.'
end
token
end
|
#get_github_token(options) ⇒ Object
looks for :github_token in ‘options`, falling back to $GITHUB_TOKEN, and then gh’s auth.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/oss_stats/github_token.rb', line 5
def get_github_token(options)
if options[:github_token]
log.debug('Using GH token from CLI')
return options[:github_token]
elsif ENV['GITHUB_TOKEN']
log.debug('Using GH token from env')
return ENV['GITHUB_TOKEN']
end
config_path = File.expand_path('~/.config/gh/hosts.yml')
if File.exist?(config_path)
config = YAML.load_file(config_path)
token = config.dig('github.com', 'oauth_token')
if token
log.debug('Using GH token from gh cli config')
return token
end
end
nil
end
|
#get_github_token!(options) ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/oss_stats/github_token.rb', line 26
def get_github_token!(options)
token = get_github_token(options)
unless token
raise ArgumentError,
'GitHub token is missing. Please provide a token using ' +
'--github-token, or set $GITHUB_TOKEN, or run `gh auth login`'
end
token
end
|
#log ⇒ Object
23
24
25
|
# File 'lib/oss_stats/log.rb', line 23
def log
OssStats::Log
end
|