Class: Fastlane::Actions::GoogleCloudStorageCheckFileAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/google_cloud_storage_rebooted/actions/google_cloud_storage_check_file_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



34
35
36
# File 'lib/fastlane/plugin/google_cloud_storage_rebooted/actions/google_cloud_storage_check_file_action.rb', line 34

def self.authors
  ["Fernando Saragoca"]
end

.available_optionsObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fastlane/plugin/google_cloud_storage_rebooted/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

.descriptionObject



30
31
32
# File 'lib/fastlane/plugin/google_cloud_storage_rebooted/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) ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/fastlane/plugin/google_cloud_storage_rebooted/actions/google_cloud_storage_check_file_action.rb', line 74

def self.is_supported?(platform)
  true
end

.return_valueObject



38
39
40
# File 'lib/fastlane/plugin/google_cloud_storage_rebooted/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) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fastlane/plugin/google_cloud_storage_rebooted/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