Class: Gitlab::Harbor::Client
- Inherits:
-
Object
- Object
- Gitlab::Harbor::Client
- Defined in:
- lib/gitlab/harbor/client.rb
Constant Summary collapse
- Error =
Class.new(StandardError)
- ConfigError =
Class.new(Error)
Instance Attribute Summary collapse
-
#integration ⇒ Object
readonly
Returns the value of attribute integration.
Instance Method Summary collapse
- #check_project_availability ⇒ Object
- #get_artifacts(params) ⇒ Object
- #get_repositories(params) ⇒ Object
- #get_tags(params) ⇒ Object
-
#initialize(integration) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(integration) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 |
# File 'lib/gitlab/harbor/client.rb', line 11 def initialize(integration) raise ConfigError, 'Please check your integration configuration.' unless integration @integration = integration end |
Instance Attribute Details
#integration ⇒ Object (readonly)
Returns the value of attribute integration.
9 10 11 |
# File 'lib/gitlab/harbor/client.rb', line 9 def integration @integration end |
Instance Method Details
#check_project_availability ⇒ Object
17 18 19 20 21 22 |
# File 'lib/gitlab/harbor/client.rb', line 17 def check_project_availability = { headers: headers.merge!('Accept': 'application/json') } response = Gitlab::HTTP.head(url("projects?project_name=#{integration.project_name}"), ) { success: response.success? } end |
#get_artifacts(params) ⇒ Object
28 29 30 31 |
# File 'lib/gitlab/harbor/client.rb', line 28 def get_artifacts(params) repository_name = params.delete(:repository_name) get(url("projects/#{integration.project_name}/repositories/#{repository_name}/artifacts"), params) end |
#get_repositories(params) ⇒ Object
24 25 26 |
# File 'lib/gitlab/harbor/client.rb', line 24 def get_repositories(params) get(url("projects/#{integration.project_name}/repositories"), params) end |
#get_tags(params) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/gitlab/harbor/client.rb', line 33 def (params) repository_name = params.delete(:repository_name) artifact_name = params.delete(:artifact_name) get( url("projects/#{integration.project_name}/repositories/#{repository_name}/artifacts/#{artifact_name}/tags"), params ) end |