Commit 1ce999db authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents 9245db7c 8a153abd
...@@ -120,7 +120,7 @@ class Service < ApplicationRecord ...@@ -120,7 +120,7 @@ class Service < ApplicationRecord
end end
def self.event_names def self.event_names
self.supported_events.map { |event| "#{event}_events" } self.supported_events.map { |event| ServicesHelper.service_event_field_name(event) }
end end
def event_field(event) def event_field(event)
...@@ -152,7 +152,7 @@ class Service < ApplicationRecord ...@@ -152,7 +152,7 @@ class Service < ApplicationRecord
end end
def self.supported_events def self.supported_events
%w(push tag_push issue confidential_issue merge_request wiki_page) %w(commit push tag_push issue confidential_issue merge_request wiki_page)
end end
def execute(data) def execute(data)
......
---
title: Refresh service_account_token for kubernetes_namespaces
merge_request: 29657
author:
type: fixed
---
title: Expose all current events properly on services API
merge_request: 29736
author: Zsolt Kovari
type: fixed
...@@ -22,6 +22,7 @@ Parameters: ...@@ -22,6 +22,7 @@ Parameters:
| --------- | ---- | -------- | ----------- | | --------- | ---- | -------- | ----------- |
| `api_key` | string | true | User API token. User must have access to task, all comments will be attributed to this user. | | `api_key` | string | true | User API token. User must have access to task, all comments will be attributed to this user. |
| `restrict_to_branch` | string | false | Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches. | | `restrict_to_branch` | string | false | Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches. |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete Asana service ### Delete Asana service
...@@ -57,6 +58,7 @@ Parameters: ...@@ -57,6 +58,7 @@ Parameters:
| --------- | ---- | -------- | ----------- | | --------- | ---- | -------- | ----------- |
| `token` | string | true | The authentication token | `token` | string | true | The authentication token
| `subdomain` | string | false | The subdomain setting | | `subdomain` | string | false | The subdomain setting |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete Assembla service ### Delete Assembla service
...@@ -96,6 +98,7 @@ Parameters: ...@@ -96,6 +98,7 @@ Parameters:
| `build_key` | string | true | Bamboo build plan key like KEY | | `build_key` | string | true | Bamboo build plan key like KEY |
| `username` | string | true | A user with API access, if applicable | | `username` | string | true | A user with API access, if applicable |
| `password` | string | true | Password of the user | | `password` | string | true | Password of the user |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete Atlassian Bamboo CI service ### Delete Atlassian Bamboo CI service
...@@ -134,6 +137,7 @@ Parameters: ...@@ -134,6 +137,7 @@ Parameters:
| `project_url` | string | true | Project url | | `project_url` | string | true | Project url |
| `description` | string | false | Description | | `description` | string | false | Description |
| `title` | string | false | Title | | `title` | string | false | Title |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete Bugzilla Service ### Delete Bugzilla Service
...@@ -170,6 +174,7 @@ Parameters: ...@@ -170,6 +174,7 @@ Parameters:
| `token` | string | true | Buildkite project GitLab token | | `token` | string | true | Buildkite project GitLab token |
| `project_url` | string | true | `https://buildkite.com/example/project` | | `project_url` | string | true | `https://buildkite.com/example/project` |
| `enable_ssl_verification` | boolean | false | Enable SSL verification | | `enable_ssl_verification` | boolean | false | Enable SSL verification |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete Buildkite service ### Delete Buildkite service
...@@ -206,6 +211,7 @@ Parameters: ...@@ -206,6 +211,7 @@ Parameters:
| `token` | string | true | Campfire token | | `token` | string | true | Campfire token |
| `subdomain` | string | false | Campfire subdomain | | `subdomain` | string | false | Campfire subdomain |
| `room` | string | false | Campfire room | | `room` | string | false | Campfire room |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete Campfire service ### Delete Campfire service
...@@ -244,6 +250,7 @@ Parameters: ...@@ -244,6 +250,7 @@ Parameters:
| `project_url` | string | true | Project url | `project_url` | string | true | Project url
| `description` | string | false | Description | `description` | string | false | Description
| `title` | string | false | Title | `title` | string | false | Title
| `push_events` | boolean | false | Enable notifications for push events |
### Delete Custom Issue Tracker service ### Delete Custom Issue Tracker service
...@@ -280,6 +287,10 @@ Parameters: ...@@ -280,6 +287,10 @@ Parameters:
| `token` | string | true | Drone CI project specific token | | `token` | string | true | Drone CI project specific token |
| `drone_url` | string | true | `http://drone.example.com` | | `drone_url` | string | true | `http://drone.example.com` |
| `enable_ssl_verification` | boolean | false | Enable SSL verification | | `enable_ssl_verification` | boolean | false | Enable SSL verification |
| `push_events` | boolean | false | Enable notifications for push events |
| `merge_requests_events` | boolean | false | Enable notifications for merge request events |
| `tag_push_events` | boolean | false | Enable notifications for tag push events |
### Delete Drone CI service ### Delete Drone CI service
...@@ -316,6 +327,8 @@ Parameters: ...@@ -316,6 +327,8 @@ Parameters:
| `recipients` | string | true | Emails separated by whitespace | | `recipients` | string | true | Emails separated by whitespace |
| `disable_diffs` | boolean | false | Disable code diffs | | `disable_diffs` | boolean | false | Disable code diffs |
| `send_from_committer_email` | boolean | false | Send from committer | | `send_from_committer_email` | boolean | false | Send from committer |
| `push_events` | boolean | false | Enable notifications for push events |
| `tag_push_events` | boolean | false | Enable notifications for tag push events |
### Delete Emails on push service ### Delete Emails on push service
...@@ -384,6 +397,7 @@ Parameters: ...@@ -384,6 +397,7 @@ Parameters:
| Parameter | Type | Required | Description | | Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- | | --------- | ---- | -------- | ----------- |
| `token` | string | true | Flowdock Git source token | | `token` | string | true | Flowdock Git source token |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete Flowdock service ### Delete Flowdock service
...@@ -471,6 +485,14 @@ Parameters: ...@@ -471,6 +485,14 @@ Parameters:
| `room` | string | false |Room name or ID | | `room` | string | false |Room name or ID |
| `api_version` | string | false | Leave blank for default (v2) | | `api_version` | string | false | Leave blank for default (v2) |
| `server` | string | false | Leave blank for default. For example, `https://hipchat.example.com`. | | `server` | string | false | Leave blank for default. For example, `https://hipchat.example.com`. |
| `push_events` | boolean | false | Enable notifications for push events |
| `issues_events` | boolean | false | Enable notifications for issue events |
| `confidential_issues_events` | boolean | false | Enable notifications for confidential issue events |
| `merge_requests_events` | boolean | false | Enable notifications for merge request events |
| `tag_push_events` | boolean | false | Enable notifications for tag push events |
| `note_events` | boolean | false | Enable notifications for note events |
| `confidental_note_events` | boolean | false | Enable notifications for confidential note events |
| `pipeline_events` | boolean | false | Enable notifications for pipeline events |
### Delete HipChat service ### Delete HipChat service
...@@ -511,6 +533,7 @@ Parameters: ...@@ -511,6 +533,7 @@ Parameters:
| `server_host` | string | false | localhost | | `server_host` | string | false | localhost |
| `server_port` | integer | false | 6659 | | `server_port` | integer | false | 6659 |
| `colorize_messages` | boolean | false | Colorize messages | | `colorize_messages` | boolean | false | Colorize messages |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete Irker (IRC gateway) service ### Delete Irker (IRC gateway) service
...@@ -562,6 +585,8 @@ Parameters: ...@@ -562,6 +585,8 @@ Parameters:
| `password` | string | yes | The password of the user created to be used with GitLab/JIRA. | | `password` | string | yes | The password of the user created to be used with GitLab/JIRA. |
| `active` | boolean | no | Activates or deactivates the service. Defaults to false (deactivated). | | `active` | boolean | no | Activates or deactivates the service. Defaults to false (deactivated). |
| `jira_issue_transition_id` | string | no | The ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (**Administration > Issues > Workflows**) by selecting **View** under **Operations** of the desired workflow of your project. The ID of each state can be found inside the parenthesis of each transition name under the **Transitions (id)** column ([see screenshot][trans]). By default, this ID is set to `2`. | | `jira_issue_transition_id` | string | no | The ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (**Administration > Issues > Workflows**) by selecting **View** under **Operations** of the desired workflow of your project. The ID of each state can be found inside the parenthesis of each transition name under the **Transitions (id)** column ([see screenshot][trans]). By default, this ID is set to `2`. |
| `commit_events` | boolean | false | Enable notifications for commit events |
| `merge_requests_events` | boolean | false | Enable notifications for merge request events |
### Delete JIRA service ### Delete JIRA service
...@@ -715,9 +740,14 @@ PUT /projects/:id/services/packagist ...@@ -715,9 +740,14 @@ PUT /projects/:id/services/packagist
Parameters: Parameters:
- `username` (**required**) | Parameter | Type | Required | Description |
- `token` (**required**) | --------- | ---- | -------- | ----------- |
- `server` (optional) | `username` | string | yes | The username of a Packagist account |
| `token` | string | yes | API token to the Packagist server |
| `server` | boolean | no | URL of the Packagist server. Leave blank for default: https://packagist.org |
| `push_events` | boolean | false | Enable notifications for push events |
| `merge_requests_events` | boolean | false | Enable notifications for merge request events |
| `tag_push_events` | boolean | false | Enable notifications for tag push events |
### Delete Packagist service ### Delete Packagist service
...@@ -755,6 +785,7 @@ Parameters: ...@@ -755,6 +785,7 @@ Parameters:
| `add_pusher` | boolean | no | Add pusher to recipients list | | `add_pusher` | boolean | no | Add pusher to recipients list |
| `notify_only_broken_pipelines` | boolean | no | Notify only broken pipelines | | `notify_only_broken_pipelines` | boolean | no | Notify only broken pipelines |
| `notify_only_default_branch` | boolean | no | Send notifications only for the default branch ([introduced in GitLab 12.0](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28271)) | | `notify_only_default_branch` | boolean | no | Send notifications only for the default branch ([introduced in GitLab 12.0](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28271)) |
| `pipeline_events` | boolean | false | Enable notifications for pipeline events |
### Delete Pipeline-Emails service ### Delete Pipeline-Emails service
...@@ -790,6 +821,7 @@ Parameters: ...@@ -790,6 +821,7 @@ Parameters:
| --------- | ---- | -------- | ----------- | | --------- | ---- | -------- | ----------- |
| `token` | string | true | The PivotalTracker token | | `token` | string | true | The PivotalTracker token |
| `restrict_to_branch` | boolean | false | Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches. | | `restrict_to_branch` | boolean | false | Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches. |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete PivotalTracker service ### Delete PivotalTracker service
...@@ -862,6 +894,7 @@ Parameters: ...@@ -862,6 +894,7 @@ Parameters:
| `priority` | string | true | The priority | | `priority` | string | true | The priority |
| `device` | string | false | Leave blank for all active devices | | `device` | string | false | Leave blank for all active devices |
| `sound` | string | false | The sound of the notification | | `sound` | string | false | The sound of the notification |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete Pushover service ### Delete Pushover service
...@@ -899,6 +932,7 @@ Parameters: ...@@ -899,6 +932,7 @@ Parameters:
| `project_url` | string | true | Project url | | `project_url` | string | true | Project url |
| `issues_url` | string | true | Issue url | | `issues_url` | string | true | Issue url |
| `description` | string | false | Description | | `description` | string | false | Description |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete Redmine service ### Delete Redmine service
...@@ -989,6 +1023,15 @@ Parameters: ...@@ -989,6 +1023,15 @@ Parameters:
| Parameter | Type | Required | Description | | Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- | | --------- | ---- | -------- | ----------- |
| `webhook` | string | true | The Microsoft Teams webhook. For example, `https://outlook.office.com/webhook/...` | | `webhook` | string | true | The Microsoft Teams webhook. For example, `https://outlook.office.com/webhook/...` |
| `push_events` | boolean | false | Enable notifications for push events |
| `issues_events` | boolean | false | Enable notifications for issue events |
| `confidential_issues_events` | boolean | false | Enable notifications for confidential issue events |
| `merge_requests_events` | boolean | false | Enable notifications for merge request events |
| `tag_push_events` | boolean | false | Enable notifications for tag push events |
| `note_events` | boolean | false | Enable notifications for note events |
| `confidental_note_events` | boolean | false | Enable notifications for confidential note events |
| `pipeline_events` | boolean | false | Enable notifications for pipeline events |
| `wiki_page_events` | boolean | false | Enable notifications for wiki page events |
### Delete Microsoft Teams service ### Delete Microsoft Teams service
...@@ -1084,6 +1127,7 @@ Parameters: ...@@ -1084,6 +1127,7 @@ Parameters:
| `build_type` | string | true | Build configuration ID | | `build_type` | string | true | Build configuration ID |
| `username` | string | true | A user with permissions to trigger a manual build | | `username` | string | true | A user with permissions to trigger a manual build |
| `password` | string | true | The password of the user | | `password` | string | true | The password of the user |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete JetBrains TeamCity CI service ### Delete JetBrains TeamCity CI service
...@@ -1230,6 +1274,7 @@ Parameters: ...@@ -1230,6 +1274,7 @@ Parameters:
| `issues_url` | string | true | Issue url | | `issues_url` | string | true | Issue url |
| `project_url` | string | true | Project url | | `project_url` | string | true | Project url |
| `description` | string | false | Description | | `description` | string | false | Description |
| `push_events` | boolean | false | Enable notifications for push events |
### Delete YouTrack Service ### Delete YouTrack Service
......
...@@ -997,7 +997,7 @@ module API ...@@ -997,7 +997,7 @@ module API
class ProjectService < Grape::Entity class ProjectService < Grape::Entity
expose :id, :title, :created_at, :updated_at, :active expose :id, :title, :created_at, :updated_at, :active
expose :push_events, :issues_events, :confidential_issues_events expose :commit_events, :push_events, :issues_events, :confidential_issues_events
expose :merge_requests_events, :tag_push_events, :note_events expose :merge_requests_events, :tag_push_events, :note_events
expose :confidential_note_events, :pipeline_events, :wiki_page_events expose :confidential_note_events, :pipeline_events, :wiki_page_events
expose :job_events expose :job_events
......
...@@ -9,7 +9,7 @@ module Gitlab ...@@ -9,7 +9,7 @@ module Gitlab
deployment_cluster.present? && deployment_cluster.present? &&
deployment_cluster.managed? && deployment_cluster.managed? &&
!deployment_cluster.project_type? && !deployment_cluster.project_type? &&
kubernetes_namespace.new_record? (kubernetes_namespace.new_record? || kubernetes_namespace.service_account_token.blank?)
end end
def complete! def complete!
......
...@@ -16,5 +16,9 @@ FactoryBot.define do ...@@ -16,5 +16,9 @@ FactoryBot.define do
trait :with_token do trait :with_token do
service_account_token { FFaker::Lorem.characters(10) } service_account_token { FFaker::Lorem.characters(10) }
end end
trait :without_token do
service_account_token nil
end
end end
end end
...@@ -35,9 +35,15 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do ...@@ -35,9 +35,15 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
end end
context 'and a namespace is already created for this project' do context 'and a namespace is already created for this project' do
let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, cluster: cluster, project: build.project) } let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, :with_token, cluster: cluster, project: build.project) }
it { is_expected.to be_falsey } it { is_expected.to be_falsey }
context 'and the service_account_token is blank' do
let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, :without_token, cluster: cluster, project: build.project) }
it { is_expected.to be_truthy }
end
end end
context 'and cluster is project type' do context 'and cluster is project type' do
......
...@@ -19,13 +19,22 @@ describe API::Services do ...@@ -19,13 +19,22 @@ describe API::Services do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
current_service = project.services.first current_service = project.services.first
event = current_service.event_names.empty? ? "foo" : current_service.event_names.first events = current_service.event_names.empty? ? ["foo"].freeze : current_service.event_names
state = current_service[event] || false query_strings = []
events.each do |event|
query_strings << "#{event}=#{!current_service[event]}"
end
query_strings = query_strings.join('&')
put api("/projects/#{project.id}/services/#{dashed_service}?#{event}=#{!state}", user), params: service_attrs put api("/projects/#{project.id}/services/#{dashed_service}?#{query_strings}", user), params: service_attrs
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(project.services.first[event]).not_to eq(state) unless event == "foo" events.each do |event|
next if event == "foo"
expect(project.services.first[event]).not_to eq(current_service[event]),
"expected #{!current_service[event]} for event #{event} for service #{current_service.title}, got #{current_service[event]}"
end
end end
it "returns if required fields missing" do it "returns if required fields missing" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment