Class: Integrations::GooglePlay

Inherits:
Integration show all
Defined in:
app/models/integrations/google_play.rb

Constant Summary collapse

PACKAGE_NAME_REGEX =
/\A[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z][A-Za-z0-9_]*){1,20}\z/
SECTION_TYPE_GOOGLE_PLAY =
'google_play'

Constants inherited from Integration

Integration::BASE_CLASSES, Integration::DEV_INTEGRATION_NAMES, Integration::INTEGRATION_NAMES, Integration::PROJECT_SPECIFIC_INTEGRATION_NAMES, Integration::SECTION_TYPE_CONFIGURATION, Integration::SECTION_TYPE_CONNECTION, Integration::SECTION_TYPE_TRIGGER, Integration::SNOWPLOW_EVENT_ACTION, Integration::SNOWPLOW_EVENT_LABEL, Integration::UnknownType

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Instance Attribute Summary

Attributes included from Importable

#imported, #importing

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Integration

#activate_disabled_reason, #activated?, #api_field_names, #async_execute, #attributes, available_integration_names, available_integration_types, boolean_accessor, build_from_integration, #category, #chat?, #ci?, #configurable_events, create_from_active_default_integrations, default_integration, default_test_event, #default_test_event, dev_integration_names, #dup, #editable?, #event_channel_names, event_description, event_names, #event_names, #execute, field, #fields, fields, find_or_initialize_all_non_project_specific, find_or_initialize_non_project_specific_integration, #form_fields, #group_level?, #inheritable?, inherited_descendants_from_self_or_ancestors_from, instance_exists_for?, #instance_level?, integration_name_to_model, integration_name_to_type, integration_names, #json_fields, #operating?, #parent, #project_level?, project_specific_integration_names, prop_accessor, #properties=, #reencrypt_properties, #reset_updated_properties, #secret_fields, #show_active_box?, #supported_events, #supports_data_fields?, #testable?, #to_database_hash, #to_param, #updated_properties

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from ResetSecretFields

#exposing_secrets_fields

Methods included from Loggable

#build_message, #log_error, #log_exception, #log_info, #logger

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Class Method Details

.supported_eventsObject



65
66
67
# File 'app/models/integrations/google_play.rb', line 65

def self.supported_events
  []
end

.to_paramObject



61
62
63
# File 'app/models/integrations/google_play.rb', line 61

def self.to_param
  'google_play'
end

Instance Method Details

#ci_variables(protected_ref:) ⇒ Object



86
87
88
89
90
91
92
93
94
# File 'app/models/integrations/google_play.rb', line 86

def ci_variables(protected_ref:)
  return [] unless activated?
  return [] if google_play_protected_refs && !protected_ref

  [
    { key: 'SUPPLY_JSON_KEY_DATA', value: , masked: true, public: false },
    { key: 'SUPPLY_PACKAGE_NAME', value: package_name, masked: false, public: false }
  ]
end

#descriptionObject



39
40
41
# File 'app/models/integrations/google_play.rb', line 39

def description
  s_('GooglePlay|Use GitLab to build and release an app in Google Play.')
end

#helpObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/integrations/google_play.rb', line 43

def help
  variable_list = [
    '<code>SUPPLY_PACKAGE_NAME</code>',
    '<code>SUPPLY_JSON_KEY_DATA</code>'
  ]

  # rubocop:disable Layout/LineLength
  texts = [
    s_("Use the Google Play integration to connect to Google Play with fastlane in CI/CD pipelines."),
    s_("After you enable the integration, the following protected variable is created for CI/CD use:"),
    variable_list.join('<br>'),
    s_(format("To generate a Google Play service account key and use this integration, see the <a href='%{url}' target='_blank'>integration documentation</a>.", url: Rails.application.routes.url_helpers.help_page_url('user/project/integrations/google_play'))).html_safe
  ]
  # rubocop:enable Layout/LineLength

  texts.join('<br><br>'.html_safe)
end

#initialize_propertiesObject



96
97
98
99
# File 'app/models/integrations/google_play.rb', line 96

def initialize_properties
  super
  self.google_play_protected_refs = true if google_play_protected_refs.nil?
end

#sectionsObject



69
70
71
72
73
74
75
76
77
# File 'app/models/integrations/google_play.rb', line 69

def sections
  [
    {
      type: SECTION_TYPE_GOOGLE_PLAY,
      title: s_('Integrations|Integration details'),
      description: help
    }
  ]
end

#test(*_args) ⇒ Object



79
80
81
82
83
84
# File 'app/models/integrations/google_play.rb', line 79

def test(*_args)
  client.list_reviews(package_name)
  { success: true }
rescue Google::Apis::ClientError => error
  { success: false, message: error }
end

#titleObject



35
36
37
# File 'app/models/integrations/google_play.rb', line 35

def title
  s_('GooglePlay|Google Play')
end