Class: Kubes::Auth::Gcr
- Inherits:
-
Base
- Object
- Base
- Kubes::Auth::Gcr
show all
- Defined in:
- lib/kubes/auth/gcr.rb
Instance Method Summary
collapse
Methods inherited from Base
#docker_config, #ensure_dotdocker_exists, #initialize
Methods included from Logging
#logger
Instance Method Details
#authorize! ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/kubes/auth/gcr.rb', line 7
def authorize!
command = "gcloud auth configure-docker"
logger.debug "Authorizing GCR with: #{command}"
success = system(command)
unless success
logger.error "ERROR: running #{command}".color(:red)
exit $?.exitstatus if exit_on_fail
end
success
end
|
#authorized? ⇒ Boolean
18
19
20
21
22
|
# File 'lib/kubes/auth/gcr.rb', line 18
def authorized?
return false unless File.exist?(docker_config)
data = JSON.load(IO.read(docker_config))
!!data.dig('credHelpers', 'gcr.io')
end
|
#run ⇒ Object
3
4
5
|
# File 'lib/kubes/auth/gcr.rb', line 3
def run
authorize! unless authorized?
end
|