Allow project feature permissions to be overridden during import
What does this MR do?
When importing a new project to GitLab we state that it is possible to override any parameters using the API when passing the data in override_params
https://docs.gitlab.com/ee/api/project_import_export.html#import-a-file
However, when passing project feature access levels data to override_params
, those params are not being respected, and in result not being updated.
This is because of a failing check !@relation_class.attribute_method?(key)
that returns true
since these access levels are defined in ProjectFeature
class https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/import_export/attribute_cleaner.rb#L21
Adding delegation methods to Project
so that it is possible to override these values during import.
Please note that pages_access_level
is not included, since it is not available in the public API and has a dependency on project's visibility level https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/models/project_feature.rb#L89-89
To test:
curl --request POST --header "PRIVATE-TOKEN: YOUR_TOKEN" --form "override_params[snippets_access_level]=disabled" --form "override_params[merge_requests_access_level]=disabled" --form "override_params[issues_access_level]=disabled" --form "override_params[wiki_access_level]=disabled" --form "file=@/path/to/file" http://localhost:3000/api/v4/projects/import --form "path=test"
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry for user-facing changes, or community contribution. Check the link for other scenarios. - [-] Documentation created/updated or follow-up review issue created
-
Code review guidelines - [-] Merge request performance guidelines
-
Style guides - [-] Database guides
- [-] Separation of EE specific content
Performance and Testing
N/A
Security
N/A