-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[api] Adding support to wipe via token
Introduce a Wipe token, esp to allow to rebuild patchinfo's which require a wipe in non-incident projects.
- Loading branch information
1 parent
3483817
commit 478c5da
Showing
12 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
class Token::Wipe < Token | ||
def call(options) | ||
set_triggered_at | ||
package_name = options[:package].to_param | ||
package_name += ":#{options[:multibuild_flavor]}" if options[:multibuild_flavor] | ||
if package_name.present? | ||
Backend::Api::Sources::Package.wipe_binaries(options[:project].to_param, | ||
package_name, | ||
options.slice(:repository, :arch).compact) | ||
else | ||
Backend::Api::Build::Project.wipe_binaries(options[:project].to_param, | ||
options.slice(:repository, :arch).compact) | ||
end | ||
end | ||
|
||
def package_find_options | ||
{ use_source: false, follow_multibuild: true } | ||
end | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: tokens | ||
# | ||
# id :integer not null, primary key | ||
# description :string(64) default("") | ||
# scm_token :string(255) indexed | ||
# string :string(255) indexed | ||
# triggered_at :datetime | ||
# type :string(255) | ||
# workflow_configuration_path :string(255) default(".obs/workflows.yml") | ||
# workflow_configuration_url :string(8192) | ||
# executor_id :integer not null, indexed | ||
# package_id :integer indexed | ||
# | ||
# Indexes | ||
# | ||
# index_tokens_on_scm_token (scm_token) | ||
# index_tokens_on_string (string) UNIQUE | ||
# package_id (package_id) | ||
# user_id (executor_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# tokens_ibfk_1 (executor_id => users.id) | ||
# tokens_ibfk_2 (package_id => packages.id) | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Token::WipePolicy < TokenPolicy | ||
def trigger? | ||
return false unless user.is_active? | ||
return PackagePolicy.new(user, record.object_to_authorize).update? if record.object_to_authorize.is_a?(Package) | ||
|
||
ProjectPolicy.new(user, record.object_to_authorize).update? if record.object_to_authorize.is_a?(Project) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
post: | ||
summary: Trigger a wipe of binary artifacts | ||
description: | | ||
This endpoint behaves exactly as the [/trigger](#/Trigger/post_trigger) endpoint but | ||
only allows API tokens with the operation 'wipe' to be triggered. | ||
security: | ||
- GitLab_key_authentication: [] | ||
tags: | ||
- Trigger |