-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce templates for new packages #14144
base: master
Are you sure you want to change the base?
Conversation
Review app will appear here: http://obs-reviewlab.opensuse.org/hellcp-work-templates |
This would require code changes and deployments for every template change. I'm not sure this is such a good idea. |
61b1d91
to
fe22bfd
Compare
I went for a similar mechanism to image templates now. I implemented basic templating with liquid, in order to prefill some metadata, to avoid having to do that manually |
4a651d3
to
aa445da
Compare
aa445da
to
40c68c1
Compare
17b5427
to
76716a8
Compare
76716a8
to
24185cc
Compare
24185cc
to
954f830
Compare
954f830
to
89e39f9
Compare
cedb51a
to
ff8cab2
Compare
Review app will appear here: http://obs-reviewlab.opensuse.org/hellcp-work-templates |
def set_template | ||
return unless params['template'] | ||
|
||
template_project, template_package = params['template'].split('/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if params['template']
does not have a '/' inside?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't work, I should do some validation here
@@ -105,6 +105,7 @@ def staging_history | |||
scope :related_to_user, ->(user_id) { joins(:relationships).where(relationships: { user_id: user_id }) } | |||
scope :for_group, ->(group_id) { joins(:relationships).where(relationships: { group_id: group_id, role_id: Role.hashed['maintainer'] }) } | |||
scope :related_to_group, ->(group_id) { joins(:relationships).where(relationships: { group_id: group_id }) } | |||
scope :with_package_templates, -> { joins(:attribs).where(attribs: { attrib_type_id: AttribType.joins(:attrib_namespace).where(attrib_namespace: { name: 'OBS' }, attrib_types: { name: 'PackageTemplates' }) }) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can do the same without subqueries by adding :attrib_types
into the join, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, let me check
You should do that in |
It's done in |
I don't get it, is replacing Package/Project/User data the "feature" of those templates? Do we need to code and commit |
Yes, all data accessible from the template is specified by those drops. I wanted to avoid presenting data that we don't want to present, like User#password. The things in a form will be available via PackageDrop, since that's the package the user created with that metadata. Templates are unfortunately code, and keeping a minimal amount of access to the database is a good idea, since this feature if not done carefully, is an easy attack vector. |
Introduces a simple template support to new project creation. Currently only supports one type of a package, SUSE style RPM, but it can be easily expanded to support everything that may be needed.
To verify:
{{ package.name }}.extension.liquid
and contents like{{ user.name }}
(other options are insrc/api/app/services/package_service/templater/{project,package,user}_drop.rb files
)TODO: