File: storage.rb

package info (click to toggle)
ruby-fog-google 1.29.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,160 kB
  • sloc: ruby: 14,258; makefile: 3
file content (34 lines) | stat: -rw-r--r-- 946 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Fog
  module Google
    class Storage < Fog::Service
      GOOGLE_STORAGE_HOST = "storage.googleapis.com".freeze

      # Shared utilities for both JSON and XML storage implementations
      module Utils
        def self.storage_host_for_universe(universe_domain)
          domain = universe_domain.to_s.strip
          if !domain.empty? && domain != "googleapis.com"
            "storage.#{domain}"
          else
            GOOGLE_STORAGE_HOST
          end
        end
      end

      def self.new(options = {})
        begin
          fog_creds = Fog.credentials
        rescue StandardError
          fog_creds = nil
        end

        if options.keys.include?(:google_storage_access_key_id) ||
           (!fog_creds.nil? && fog_creds.keys.include?(:google_storage_access_key_id))
          Fog::Google::StorageXML.new(options)
        else
          Fog::Google::StorageJSON.new(options)
        end
      end
    end
  end
end