[PATCH] [frontend] add copr modification to web api
by Matej Stuchlik
I've yet to update the API documentation page [0], I'll send the relevant patch
if this one passes the review.
[0] http://copr-fe.cloud.fedoraproject.org/api/
I've also enhanced copr-cli to make use of this newly exposed API, I'll send that
patch in a little bit.
---
Allows for:
* modification of description, instructions and repos of a copr
via POST to $copr_api_url/coprs/<username>/<coprname>/modify
* adding packages to minimal buildroot of a chroot via POST to
$copr_api_url/coprs/<username>/<coprname>/modify/<chroot>
* reading what packages are currently added to minimal buildroot of a chroot
via POST to $copr_api_url/coprs/<username>/<coprname>/details/<chroot>
---
coprs_frontend/coprs/forms.py | 15 ++++
coprs_frontend/coprs/views/api_ns/api_general.py | 90 +++++++++++++++++++++++-
2 files changed, 104 insertions(+), 1 deletion(-)
diff --git a/coprs_frontend/coprs/forms.py b/coprs_frontend/coprs/forms.py
index c5dfa42..62711d5 100644
--- a/coprs_frontend/coprs/forms.py
+++ b/coprs_frontend/coprs/forms.py
@@ -250,3 +250,18 @@ class PermissionsFormFactory(object):
coerce=int))
return F
+
+class CoprModifyForm(wtf.Form):
+ description = wtforms.TextAreaField('Description',
+ validators=[wtforms.validators.Optional()])
+
+ instructions = wtforms.TextAreaField('Instructions',
+ validators=[wtforms.validators.Optional()])
+
+ repos = wtforms.TextAreaField('Repos',
+ validators=[UrlListValidator(),
+ wtforms.validators.Optional()],
+ filters=[StringListFilter()])
+
+class ModifyChrootForm(wtf.Form):
+ buildroot_pkgs = wtforms.TextField('Additional packages to be always present in minimal buildroot')
diff --git a/coprs_frontend/coprs/views/api_ns/api_general.py b/coprs_frontend/coprs/views/api_ns/api_general.py
index 6dcdaa6..8ecdc29 100644
--- a/coprs_frontend/coprs/views/api_ns/api_general.py
+++ b/coprs_frontend/coprs/views/api_ns/api_general.py
@@ -156,7 +156,6 @@ def copr_new_build(username, coprname):
output = {'output': 'notok', 'error':
'Copr with name {0} does not exist.'.format(coprname)}
httpcode = 500
-
else:
if form.validate_on_submit() and flask.g.user.can_build_in(copr):
# we're checking authorization above for now
@@ -203,3 +202,92 @@ def build_status(build_id):
jsonout.status_code = httpcode
return jsonout
+(a)api_ns.route('/coprs/<username>/<coprname>/modify/', methods=["POST"])
+@api_login_required
+def copr_modify(username, coprname):
+ form = forms.CoprModifyForm(csrf_enabled=False)
+ copr = coprs_logic.CoprsLogic.get(flask.g.user, username, coprname).first()
+
+ if copr is None:
+ output = {'output': 'notok', 'error': 'Invalid copr name or username'}
+ httpcode = 500
+ elif not form.validate_on_submit():
+ output = {'output': 'notok', 'error': 'Invalid request'}
+ httpcode = 500
+ else:
+ # .raw_data needs to be inspected to figure out whether the field
+ # was not sent or was sent empty
+ if form.description.raw_data and len(form.description.raw_data):
+ copr.description = form.description.data
+ if form.instructions.raw_data and len(form.instructions.raw_data):
+ copr.instructions = form.instructions.data
+ if form.repos.raw_data and len(form.repos.raw_data):
+ copr.repos = form.repos.data
+
+ try:
+ coprs_logic.CoprsLogic.update(flask.g.user, copr)
+ except (exceptions.ActionInProgressException, exceptions.InsufficientRightsException) as e:
+ db.session.rollback()
+
+ output = {'output': 'notok', 'error': str(e)}
+ httpcode = 500
+ else:
+ db.session.commit()
+
+ output = {'output': 'ok',
+ 'description': copr.description,
+ 'instructions': copr.instructions,
+ 'repos': copr.repos}
+ httpcode = 200
+
+ jsonout = flask.jsonify(output)
+ jsonout.status_code = httpcode
+ return jsonout
+
+(a)api_ns.route('/coprs/<username>/<coprname>/modify/<chrootname>/', methods=["POST"])
+@api_login_required
+def copr_modify_chroot(username, coprname, chrootname):
+ form = forms.ModifyChrootForm(csrf_enabled=False)
+ copr = coprs_logic.CoprsLogic.get(flask.g.user, username, coprname).first()
+ chroot = coprs_logic.MockChrootsLogic.get_from_name(chrootname, active_only=True).first()
+
+ if copr is None:
+ output = {'output': 'notok', 'error': 'Invalid copr name or username'}
+ httpcode = 500
+ elif chroot is None:
+ output = {'output': 'notok', 'error': 'Invalid chroot name'}
+ httpcode = 500
+ elif not form.validate_on_submit():
+ output = {'output': 'notok', 'error': 'Invalid request'}
+ httpcode = 500
+ else:
+ coprs_logic.CoprChrootsLogic.update_buildroot_pkgs(copr, chroot, form.buildroot_pkgs.data)
+ db.session.commit()
+
+ ch = copr.check_copr_chroot(chroot)
+ output = {'output': 'ok', 'buildroot_pkgs': ch.buildroot_pkgs}
+ httpcode = 200
+
+ jsonout = flask.jsonify(output)
+ jsonout.status_code = httpcode
+ return jsonout
+
+(a)api_ns.route('/coprs/<username>/<coprname>/details/<chrootname>/', methods=["POST"])
+def copr_chroot_details(username, coprname, chrootname):
+ copr = coprs_logic.CoprsLogic.get(flask.g.user, username, coprname).first()
+ chroot = coprs_logic.MockChrootsLogic.get_from_name(chrootname, active_only=True).first()
+
+ if copr is None:
+ output = {'output': 'notok', 'error': 'Invalid copr name or username'}
+ httpcode = 500
+ elif chroot is None:
+ output = {'output': 'notok', 'error': 'Invalid chroot name'}
+ httpcode = 500
+ else:
+ ch = copr.check_copr_chroot(chroot)
+ output = {'output': 'ok', 'buildroot_pkgs': ch.buildroot_pkgs}
+ httpcode = 200
+
+ jsonout = flask.jsonify(output)
+ jsonout.status_code = httpcode
+ return jsonout
--
1.8.4.2
9 years, 7 months
Fwd: New version of Copr
by Miroslav Suchý
Just sent to fedora-devel:
Hi,
I just deployed new version of Copr.
Changes:
* copr-cli has been build for epel6 (no planned build for el5 due
dependency on python-requests)
* you should see less internal server errors. Especially when deleting
tasks with multiple srpm
* All packages produced by Copr now have as vendor "Fedora Project COPR
(username/project)"
* if you add new chroot to your project, you can easily resubmit
missing builds from Monitor tab.
* if you are logged in, then time in output respect your timezone which
you have in FAS.
* previously sometime yum repo was not updated after successful build -
this has been fixed
Enjoy:
http://copr.fedoraproject.org/
Mirek Suchy
9 years, 7 months
[PATCH] [frontend] fix spellings on chroot edit page
by Dominic Cleal
---
coprs_frontend/coprs/templates/coprs/detail/edit_chroot.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/coprs_frontend/coprs/templates/coprs/detail/edit_chroot.html b/coprs_frontend/coprs/templates/coprs/detail/edit_chroot.html
index 9f0905c..d0d748d 100644
--- a/coprs_frontend/coprs/templates/coprs/detail/edit_chroot.html
+++ b/coprs_frontend/coprs/templates/coprs/detail/edit_chroot.html
@@ -10,7 +10,7 @@
<form action="{{ url_for('coprs_ns.chroot_update', username = copr.owner.name, coprname = copr.name, chrootname = chroot.chroot_name) }}" method=post class=add-entry>
<dl>
{{ form.csrf_token }}
- {{ render_field(form.buildroot_pkgs, size=80, placeholder='Space separeted list of packages. E.g.: scl-utils-build rubu193-build') }}
+ {{ render_field(form.buildroot_pkgs, size=80, placeholder='Space separated list of packages. E.g.: scl-utils-build ruby193-build') }}
<dt><input type="submit" value="Update"></dt>
</dl>
</form>
--
1.8.4.2
9 years, 8 months
Re: Fedora 18 End of Life
by Miroslav Suchý
On 01/14/2014 10:31 PM, Dennis Gilmore wrote:
> As of 14th January 2014, Fedora 18 has reached its end of life for
> updates and support. No further updates, including security updates,
> will be available for Fedora 18. A previous reminder was sent on
> December 18th [0].
How does this affect Copr?
I will keep Fedora 18 for additional 3 months there. Then it will be
removed.
I'm still unsure what it will mean for existing Fedora 18 repository. I
you want to discuss it, you are welcome to copr-devel@ mailing list.
Mirek
9 years, 8 months
Re: Fedora 18 End of Life
by Rex Dieter
On 01/16/2014 10:24 AM, Stanislav Ochotnicky wrote:
> The thing is those copr repos will likely depend on EOLed Fedora
> repos. Do we keep*those* around?
Yes
-- Rex
9 years, 8 months
https on Copr
by Miroslav Suchý
I just enabled https for both frontend and backend (even -dev instances).
Right now it is self-signed certificate. Certificate signed by some known CA is on the way.
My next plan is to enable https as default url in copr-cli and in baseurl of repo file.
Please report if you experience some problems.
--
Miroslav Suchy, RHCE, RHCDS
Red Hat, Software Engineer, #brno, #devexp, #fedora-buildsys
9 years, 8 months
Re: New version of Copr
by Miroslav Suchý
On 01/14/2014 01:09 AM, Orion Poplawski wrote:
> On 01/13/2014 03:26 PM, Miroslav Suchy wrote:
>> > I just deployed new version of Copr at:
>> > http://copr.fedoraproject.org
>> >
>> > It have only one feature: you can now build in epel-7-x86_64!
>> >
>> > To be precise - the name "epel" is little bit misleading, because it is right
>> > now based on RHEL 7 Beta and does not include EPEL repo, because it does not
>> > exists yet.
> http://dl.fedoraproject.org/pub/epel/beta/7/
>
Added.
So epel-7-x86_64 is now RHEL 7 beta plus EPEL 7.
--
Miroslav Suchy, RHCE, RHCDS
Red Hat, Software Engineer, #brno, #devexp, #fedora-buildsys
9 years, 8 months
New version of Copr
by Miroslav Suchý
I just deployed new version of Copr at:
http://copr.fedoraproject.org
It have only one feature: you can now build in epel-7-x86_64!
To be precise - the name "epel" is little bit misleading, because it is
right now based on RHEL 7 Beta and does not include EPEL repo, because
it does not exists yet.
But one day I will flip to Centos 7 and EPEL 7 and I do not want you to
change chroots and configs, while I want to provide you the option of
hacking your packages on top not-yet-finished RHEL 7.
Mirek
9 years, 8 months
Removal of Fedora 18
by Miroslav Suchý
Fedora 18 will EOL very soon. How will it affect building for F18 in Copr?
It is first time event. So we have to define the default behavior.
My proposal is to keep it little bit longer available. Is 3 months enough? And then remove it from available chroots.
I.e. you will not be able to build new package for Fedora 18. But I would preserve all old builds for F18.
Do you agree? Or you have objections?
If no one answers with objections or better idea, I would stick to this plan.
--
Miroslav Suchy, RHCE, RHCDS
Red Hat, Software Engineer, #brno, #devexp, #fedora-buildsys
9 years, 8 months