| |
@@ -119,7 +119,8 @@
|
| |
'compose_types': ["test", "nightly"]
|
| |
},
|
| |
'dev3': {
|
| |
- 'source_types': ['tag']
|
| |
+ 'source_types': ['tag'],
|
| |
+ 'target_dirs': ["releng-private"]
|
| |
}
|
| |
}
|
| |
}
|
| |
@@ -318,7 +319,8 @@
|
| |
'module_defaults_url': None,
|
| |
'label': None,
|
| |
'compose_type': 'test',
|
| |
- 'pungi_compose_id': None}
|
| |
+ 'pungi_compose_id': None,
|
| |
+ 'target_dir': 'default'}
|
| |
self.assertEqual(data, expected_json)
|
| |
|
| |
db.session.expire_all()
|
| |
@@ -534,6 +536,61 @@
|
| |
c = db.session.query(Compose).filter(Compose.id == 1).one()
|
| |
self.assertEqual(c.state, COMPOSE_STATES["wait"])
|
| |
|
| |
+ def test_submit_build_target_dir_unknown(self):
|
| |
+ with self.test_request_context(user='dev'):
|
| |
+ flask.g.oidc_scopes = [
|
| |
+ '{0}{1}'.format(conf.oidc_base_namespace, 'new-compose')
|
| |
+ ]
|
| |
+
|
| |
+ rv = self.client.post('/api/1/composes/', data=json.dumps(
|
| |
+ {'source': {'type': 'tag', 'source': 'f26'},
|
| |
+ 'target_dir': 'foo'}))
|
| |
+ data = json.loads(rv.get_data(as_text=True))
|
| |
+
|
| |
+ self.assertEqual(data['status'], 400)
|
| |
+ self.assertEqual(data['error'], 'Bad Request')
|
| |
+ self.assertEqual(data['message'], 'Unknown "target_dir" "foo"')
|
| |
+
|
| |
+ @patch.object(odcs.server.config.Config, 'extra_target_dirs',
|
| |
+ new={"releng-private": "/tmp/private"})
|
| |
+ def test_submit_build_target_not_allowed(self):
|
| |
+ with self.test_request_context(user='dev'):
|
| |
+ flask.g.oidc_scopes = [
|
| |
+ '{0}{1}'.format(conf.oidc_base_namespace, 'new-compose')
|
| |
+ ]
|
| |
+
|
| |
+ rv = self.client.post('/api/1/composes/', data=json.dumps(
|
| |
+ {'source': {'type': 'tag', 'source': 'f26'},
|
| |
+ 'target_dir': 'releng-private'}))
|
| |
+ data = json.loads(rv.get_data(as_text=True))
|
| |
+
|
| |
+ self.assertEqual(data['status'], 403)
|
| |
+ self.assertEqual(data['error'], 'Forbidden')
|
| |
+ self.assertEqual(
|
| |
+ data['message'],
|
| |
+ 'User dev not allowed to operate with compose with target_dirs=releng-private.')
|
| |
+
|
| |
+ @patch.object(odcs.server.config.Config, 'extra_target_dirs',
|
| |
+ new={"releng-private": "/tmp/private"})
|
| |
+ def test_submit_build_target_dir(self):
|
| |
+ with self.test_request_context(user='dev3'):
|
| |
+ flask.g.oidc_scopes = [
|
| |
+ '{0}{1}'.format(conf.oidc_base_namespace, 'new-compose')
|
| |
+ ]
|
| |
+
|
| |
+ rv = self.client.post('/api/1/composes/', data=json.dumps(
|
| |
+ {'source': {'type': 'tag', 'source': 'f26'},
|
| |
+ 'target_dir': 'releng-private'}))
|
| |
+ self.assertEqual(rv.status, '200 OK')
|
| |
+ data = json.loads(rv.get_data(as_text=True))
|
| |
+
|
| |
+ self.assertEqual(data['target_dir'], 'releng-private')
|
| |
+
|
| |
+ db.session.expire_all()
|
| |
+ c = db.session.query(Compose).filter(Compose.id == 3).one()
|
| |
+ self.assertEqual(c.state, COMPOSE_STATES["wait"])
|
| |
+ self.assertEqual(c.target_dir, "/tmp/private")
|
| |
+
|
| |
def test_submit_build_module_defaults_url(self):
|
| |
with self.test_request_context(user='dev'):
|
| |
flask.g.oidc_scopes = [
|
| |
@@ -1168,7 +1225,8 @@
|
| |
'module_defaults_url': None,
|
| |
'label': None,
|
| |
'compose_type': 'test',
|
| |
- 'pungi_compose_id': None}
|
| |
+ 'pungi_compose_id': None,
|
| |
+ 'target_dir': 'default'}
|
| |
self.assertEqual(data, expected_json)
|
| |
|
| |
db.session.expire_all()
|
| |
ODCS currently always store resulting compose in the single
conf.target_dir
directory. There are at least two use-casesfor which it would make sense to store some composes in different
locations:
This is needed by Fedora releng team to generate internal-only
composes with packages which cannot be publicly available because
of licensing issues.
and uses completely different NFS storage for composes. This might
be used in the future to allow CI infrastructure to use ODCS and
store the resulting composes closer to the CI VMs.
This commit allows choosing the resulting target_dir by implementing
following points:
conf.extra_target_dirs
option is introduced.conf.clients
orconf.admins
options can allow certain users/groupsto use particular target dir defined in
conf.extra_target_dirs
.target_dir
API variable is introduced to choose the target_dir.If unset, default
conf.target_dir
is used.target_dir
is stored in DB using theCompose
model.target directories and tries to remove them. If the target directory
is not available on particular backend, the compose removal is skipped.
This means that only backends which have access to particular target_dir
are able to remove expired composes.
Signed-off-by: Jan Kaluza jkaluza@redhat.com