Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/integrations/harbor.rb')
-rw-r--r--app/models/integrations/harbor.rb71
1 files changed, 23 insertions, 48 deletions
diff --git a/app/models/integrations/harbor.rb b/app/models/integrations/harbor.rb
index 58eabcfd378..01a04743d5d 100644
--- a/app/models/integrations/harbor.rb
+++ b/app/models/integrations/harbor.rb
@@ -3,14 +3,33 @@ require 'uri'
module Integrations
class Harbor < Integration
- prop_accessor :url, :project_name, :username, :password
-
validates :url, public_url: true, presence: true, addressable_url: { allow_localhost: false, allow_local_network: false }, if: :activated?
validates :project_name, presence: true, if: :activated?
validates :username, presence: true, if: :activated?
validates :password, format: { with: ::Ci::Maskable::REGEX }, if: :activated?
- before_validation :reset_username_and_password
+ field :url,
+ title: -> { s_('HarborIntegration|Harbor URL') },
+ placeholder: 'https://demo.goharbor.io',
+ help: -> { s_('HarborIntegration|Base URL of the Harbor instance.') },
+ exposes_secrets: true,
+ required: true
+
+ field :project_name,
+ title: -> { s_('HarborIntegration|Harbor project name') },
+ help: -> { s_('HarborIntegration|The name of the project in Harbor.') }
+
+ field :username,
+ title: -> { s_('HarborIntegration|Harbor username') },
+ required: true
+
+ field :password,
+ type: '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
def title
'Harbor'
@@ -21,7 +40,7 @@ module Integrations
end
def help
- s_("HarborIntegration|After the Harbor integration is activated, global variables '$HARBOR_USERNAME', '$HARBOR_HOST', '$HARBOR_OCI', '$HARBOR_PASSWORD', '$HARBOR_URL' and '$HARBOR_PROJECT' will be created for CI/CD use.")
+ s_("HarborIntegration|After the Harbor integration is activated, global variables `$HARBOR_USERNAME`, `$HARBOR_HOST`, `$HARBOR_OCI`, `$HARBOR_PASSWORD`, `$HARBOR_URL` and `$HARBOR_PROJECT` will be created for CI/CD use.")
end
def hostname
@@ -46,40 +65,6 @@ module Integrations
client.ping
end
- 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
-
def ci_variables
return [] unless activated?
@@ -100,15 +85,5 @@ module Integrations
def client
@client ||= ::Gitlab::Harbor::Client.new(self)
end
-
- def reset_username_and_password
- if url_changed? && !password_touched?
- self.password = nil
- end
-
- if url_changed? && !username_touched?
- self.username = nil
- end
- end
end
end