Sha256: c4dd0f55b860def7aaafae38112683d249963dbc2177adad394ad3f0ba4ace67

Contents?: true

Size: 1.6 KB

Versions: 31

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

require 'uffizzi'

module Uffizzi
  class Cli::Disconnect
    include ApiClient

    def run(credential_type)
      connection_type = case credential_type
                        when 'docker-hub'
                          Uffizzi.configuration.credential_types[:dockerhub]
                        when 'docker-registry'
                          Uffizzi.configuration.credential_types[:docker_registry]
                        when 'acr'
                          Uffizzi.configuration.credential_types[:azure]
                        when 'ecr'
                          Uffizzi.configuration.credential_types[:amazon]
                        when 'gcr'
                          Uffizzi.configuration.credential_types[:google]
                        when 'ghcr'
                          Uffizzi.configuration.credential_types[:github_registry]
                        else
                          raise Uffizzi::Error.new('Unsupported credential type.')
      end

      response = delete_credential(ConfigFile.read_option(:server), ConfigFile.read_option(:account, :id), connection_type)

      if ResponseHelper.no_content?(response)
        Uffizzi.ui.say("Successfully disconnected from #{connection_name(credential_type)}.")
      else
        ResponseHelper.handle_failed_response(response)
      end
    end

    private

    def connection_name(credential_type)
      {
        'docker-hub' => 'DockerHub',
        'docker-registry' => 'Docker Registry',
        'acr' => 'ACR',
        'ecr' => 'ECR',
        'gcr' => 'GCR',
        'ghcr' => 'GHCR',
      }[credential_type]
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
uffizzi-cli-2.4.11 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.4.10 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.4.9 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.4.8 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.4.7 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.4.6 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.4.5 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.4.4 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.4.3 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.4.2 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.4.1 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.4.0 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.3.4 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.3.3 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.3.2 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.3.1 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.3.0 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.2.2 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.2.1 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-2.2.0 lib/uffizzi/cli/disconnect.rb