Class: Kubes::Auth
- Inherits:
-
Object
- Object
- Kubes::Auth
- Defined in:
- lib/kubes/auth/ecr.rb,
lib/kubes/auth.rb,
lib/kubes/auth/gcr.rb,
lib/kubes/auth/base.rb
Overview
Normally, you must authorized to AWS ECR to push to their registry with:
eval $(aws ecr get-login --no-include-email)
If you haven’t ever ran the ecr get-login command before then you’ll get this error:
no basic auth credentials
If you have ran it before but the auto token has expired you’ll get this message:
denied: Your Authorization Token has expired. Please run 'aws ecr get-login' to fetch a new one.
This class updates the ~/.docker/config.json file which is an internal docker file to automatically update the auto token for you. If that format changes, the update will need to be updated.
Defined Under Namespace
Instance Method Summary collapse
- #auth? ⇒ Boolean
-
#initialize(image) ⇒ Auth
constructor
A new instance of Auth.
- #run ⇒ Object
-
#strategy_class ⇒ Object
Currently only support ECR and GCR TODO: consider moving this to plugin gems.
Constructor Details
#initialize(image) ⇒ Auth
Returns a new instance of Auth.
3 4 5 |
# File 'lib/kubes/auth.rb', line 3 def initialize(image) @image = image end |
Instance Method Details
#auth? ⇒ Boolean
25 26 27 28 29 30 31 |
# File 'lib/kubes/auth.rb', line 25 def auth? if ENV['KUBES_REPO_AUTO_AUTH'].nil? Kubes.config.repo_auto_auth else %w[1 true].include?(ENV['KUBES_REPO_AUTO_AUTH']) end end |
#run ⇒ Object
7 8 9 10 11 |
# File 'lib/kubes/auth.rb', line 7 def run klass = strategy_class return unless klass klass.new(@image).run end |
#strategy_class ⇒ Object
Currently only support ECR and GCR TODO: consider moving this to plugin gems
15 16 17 18 19 20 21 22 23 |
# File 'lib/kubes/auth.rb', line 15 def strategy_class return unless auth? case @image when /\.amazonaws\.com/ # IE: 112233445566.dkr.ecr.us-west-2.amazonaws.com/demo/sinatra Ecr when /gcr\.io/ Gcr end end |