Sha256: 4a570b03b14280409146cde75696577b5256f591eff49bc5b823c85624d8a606

Contents?: true

Size: 1.4 KB

Versions: 9

Compression:

Stored size: 1.4 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 '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), connection_type)

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

    private

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
uffizzi-cli-0.11.5 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-0.11.4 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-0.11.3 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-0.11.2 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-0.11.1 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-0.11.0 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-0.10.1 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-0.10.0 lib/uffizzi/cli/disconnect.rb
uffizzi-cli-0.9.0 lib/uffizzi/cli/disconnect.rb