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 included from Base::Integration

Base::Integration::BASE_ATTRIBUTES, Base::Integration::BASE_CLASSES, Base::Integration::DEV_INTEGRATION_NAMES, Base::Integration::ENCRYPTED_PROPERTIES_MAX_SIZE, Base::Integration::INSTANCE_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::INTEGRATION_NAMES, Base::Integration::PROJECT_AND_GROUP_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::PROJECT_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::SECTION_TYPE_CONFIGURATION, Base::Integration::SECTION_TYPE_CONNECTION, Base::Integration::SECTION_TYPE_TRIGGER, Base::Integration::SNOWPLOW_EVENT_ACTION, Base::Integration::SNOWPLOW_EVENT_LABEL, Base::Integration::UnknownType

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base::Integration

#activate!, #activate_disabled_reason, #activated?, #after_build_from_integration, #api_field_names, #async_execute, #attributes, #attribution_notice, #category, #chat?, #ci?, #configurable_events, #deactivate!, #default_test_event, #description, #dup, #editable?, #event_channel_names, #event_names, #execute, #fields, #form_fields, #group_level?, #help, #inheritable?, #instance_level?, #json_fields, #manual_activation?, #operating?, #organization_id_from_parent, #parent, #project_level?, #reencrypt_properties, #reset_updated_properties, #secret_fields, #supported_events, #supports_data_fields?, #testable?, #title, #to_database_hash, #to_param, #toggle!, #updated_properties, #validate_encrypted_properties_size_limit

Methods included from Gitlab::Utils::Override

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

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, 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 Organizations::Sharding

#sharding_organization

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Class Method Details

.descriptionObject



45
46
47
# File 'app/models/integrations/google_play.rb', line 45

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

.helpObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/models/integrations/google_play.rb', line 49

def self.help
  variable_list = [
    ActionController::Base.helpers.(:code, "SUPPLY_PACKAGE_NAME"),
    ActionController::Base.helpers.(:code, "SUPPLY_JSON_KEY_DATA")
  ]

  docs_link = ActionController::Base.helpers.link_to(
    '',
    Rails.application.routes.url_helpers.help_page_url('user/project/integrations/google_play.md'),
    target: '_blank',
    rel: 'noopener noreferrer'
  )
  tag_pair_docs_link = tag_pair(docs_link, :link_start, :link_end)

  texts = [
    s_("Use this integration to connect to Google Play with fastlane in CI/CD pipelines."),
    s_("After you enable the integration, the following protected variables are created for CI/CD use:"),
    ActionController::Base.helpers.safe_join(variable_list, ActionController::Base.helpers.tag(:br)),
    safe_format(s_("For more information, see the %{link_start}documentation%{link_end}."), tag_pair_docs_link)
  ]

  ActionController::Base.helpers.safe_join(texts, ActionController::Base.helpers.tag(:br) * 2)
end

.supported_eventsObject



77
78
79
# File 'app/models/integrations/google_play.rb', line 77

def self.supported_events
  []
end

.titleObject



41
42
43
# File 'app/models/integrations/google_play.rb', line 41

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

.to_paramObject



73
74
75
# File 'app/models/integrations/google_play.rb', line 73

def self.to_param
  'google_play'
end

Instance Method Details

#ci_variables(protected_ref:) ⇒ Object



98
99
100
101
102
103
104
105
106
# File 'app/models/integrations/google_play.rb', line 98

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

#initialize_propertiesObject



108
109
110
111
# File 'app/models/integrations/google_play.rb', line 108

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

#sectionsObject



81
82
83
84
85
86
87
88
89
# File 'app/models/integrations/google_play.rb', line 81

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

#test(*_args) ⇒ Object



91
92
93
94
95
96
# File 'app/models/integrations/google_play.rb', line 91

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