Class: Integrations::Harbor

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

Constant Summary

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::UnknownType

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

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, #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, 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, #initialize_properties, 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, #sections, #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_event_actionsObject


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

def supported_event_actions
  []
end

.supported_eventsObject


31
32
33
# File 'app/models/integrations/harbor.rb', line 31

def supported_events
  []
end

.to_paramObject


27
28
29
# File 'app/models/integrations/harbor.rb', line 27

def to_param
  name.demodulize.downcase
end

Instance Method Details

#ci_variablesObject


78
79
80
81
82
83
84
85
86
87
# File 'app/models/integrations/harbor.rb', line 78

def ci_variables
  return [] unless activated?

  [
    { key: 'HARBOR_URL', value: url },
    { key: 'HARBOR_PROJECT', value: project_name },
    { key: 'HARBOR_USERNAME', value: username.gsub(/^robot\$/, 'robot$$') },
    { key: 'HARBOR_PASSWORD', value: password, public: false, masked: true }
  ]
end

#descriptionObject


18
19
20
# File 'app/models/integrations/harbor.rb', line 18

def description
  s_("HarborIntegration|Use Harbor as this project's container registry.")
end

#fieldsObject


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
73
74
75
76
# File 'app/models/integrations/harbor.rb', line 44

def fields
  [
    {
      type: 'text',
      name: 'url',
      title: s_('HarborIntegration|Harbor URL'),
      placeholder: 'https://demo.goharbor.io',
      help: s_('HarborIntegration|Base URL of the Harbor instance.'),
      required: true
    },
    {
      type: 'text',
      name: 'project_name',
      title: s_('HarborIntegration|Harbor project name'),
      help: s_('HarborIntegration|The name of the project in Harbor.')
    },
    {
      type: 'text',
      name: 'username',
      title: s_('HarborIntegration|Harbor username'),
      required: true
    },
    {
      type: 'password',
      name: 'password',
      title: s_('HarborIntegration|Harbor password'),
      help: s_('HarborIntegration|Password for your Harbor username.'),
      non_empty_password_title: s_('HarborIntegration|Enter new Harbor password'),
      non_empty_password_help: s_('HarborIntegration|Leave blank to use your current password.'),
      required: true
    }
  ]
end

#helpObject


22
23
24
# File 'app/models/integrations/harbor.rb', line 22

def help
  s_("HarborIntegration|After the Harbor integration is activated, global variables ‘$HARBOR_USERNAME’, ‘$HARBOR_PASSWORD’, ‘$HARBOR_URL’ and ‘$HARBOR_PROJECT’ will be created for CI/CD use.")
end

#test(*_args) ⇒ Object


40
41
42
# File 'app/models/integrations/harbor.rb', line 40

def test(*_args)
  client.ping
end

#titleObject


14
15
16
# File 'app/models/integrations/harbor.rb', line 14

def title
  'Harbor'
end