class Fastlane::Actions::GoogleCloudStorageCheckFileAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/google_cloud_storage/actions/google_cloud_storage_check_file_action.rb, line 34
def self.authors
  ["Fernando Saragoca"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/google_cloud_storage/actions/google_cloud_storage_check_file_action.rb, line 42
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :project,
                            env_name: "GOOGLE_CLOUD_STORAGE_PROJECT",
                         description: "Google Cloud Storage project identifier",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :keyfile,
                            env_name: "GOOGLE_CLOUD_STORAGE_KEYFILE",
                         description: "Google Cloud Storage keyfile",
                            optional: false,
                                type: String,
                        verify_block: proc do |value|
                                        if value.nil? || value.empty?
                                          UI.user_error!("No keyfile for Google Cloud Storage action given, pass using `keyfile_path: 'path/to/file.txt'`")
                                        elsif File.file?(value) == false
                                          UI.user_error!("Keyfile '#{value}' not found")
                                        end
                                      end),
    FastlaneCore::ConfigItem.new(key: :bucket,
                            env_name: "GOOGLE_CLOUD_STORAGE_BUCKET",
                         description: "Google Cloud Storage bucket",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :file_name,
                            env_name: "GOOGLE_CLOUD_STORAGE_DOWNLOAD_FILE_NAME",
                         description: "File name",
                            optional: false,
                                type: String)
  ]
end
description() click to toggle source
# File lib/fastlane/plugin/google_cloud_storage/actions/google_cloud_storage_check_file_action.rb, line 30
def self.description
  "Check if file exists in Google Cloud Storage"
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/google_cloud_storage/actions/google_cloud_storage_check_file_action.rb, line 74
def self.is_supported?(platform)
  true
end
return_value() click to toggle source
# File lib/fastlane/plugin/google_cloud_storage/actions/google_cloud_storage_check_file_action.rb, line 38
def self.return_value
  "Returns 'true' if object exists, 'false' if not"
end
run(params) click to toggle source
# File lib/fastlane/plugin/google_cloud_storage/actions/google_cloud_storage_check_file_action.rb, line 6
def self.run(params)
  Actions.verify_gem!('google-cloud-storage')

  storage = Helper::GoogleCloudStorageHelper.setup_storage(
    project: params[:project],
    keyfile: params[:keyfile]
  )

  bucket = Helper::GoogleCloudStorageHelper.find_bucket(
    storage: storage,
    bucket_name: params[:bucket]
  )

  begin
    Helper::GoogleCloudStorageHelper.find_file(
      bucket: bucket,
      file_name: params[:file_name]
    )
    true
  rescue
    false
  end
end