Skip to content

Commit

Permalink
NAS-129590 / 24.10 / Fix querying apps for readonly user (#14172)
Browse files Browse the repository at this point in the history
* Fix app.query with readonly role

* Use correct schema name

* Cover usages of app_query schema name

* Fix schema for active workloads
  • Loading branch information
sonicaj authored Aug 9, 2024
1 parent 3696d96 commit f9ebf17
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/middlewared/middlewared/plugins/apps/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Config:
role_prefix = 'APPS'

ENTRY = Dict(
'app_query',
'app_entry',
Str('name'),
Str('id'),
Str('state', enum=['STOPPED', 'DEPLOYING', 'RUNNING']),
Expand All @@ -49,22 +49,27 @@ class Config:
Str('host_port'),
Str('host_ip'),
)]),
additional_attrs=True,
)]),
List('container_details', items=[Dict(
'container_detail',
Str('id'),
Str('service_name'),
Str('image'),
List('port_config'),
Str('state', enum=['running', 'starting', 'exited']),
List('volume_mounts'),
additional_attrs=True,
)]),
List('volumes', items=[Dict(
'volume',
Str('source'),
Str('destination'),
Str('mode'),
Str('type'),
additional_attrs=True,
)]),
additional_attrs=True,
),
additional_attrs=True,
)
Expand Down Expand Up @@ -120,7 +125,7 @@ def config(self, app_name):
return get_current_app_config(app_name, app['version'])

@accepts(Str('app_name'), roles=['APPS_WRITE'])
@returns(Ref('app_query'))
@returns(Ref('app_entry'))
@job(lock=lambda args: f'app_start_{args[0]}')
async def convert_to_custom(self, job, app_name):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/apps/rollback.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Config:
),
roles=['APPS_WRITE'],
)
@returns(Ref('app_query'))
@returns(Ref('app_entry'))
@job(lock=lambda args: f'app_rollback_{args[0]}')
def rollback(self, job, app_name, options):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/apps/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Config:
),
roles=['APPS_WRITE'],
)
@returns(Ref('app_query'))
@returns(Ref('app_entry'))
@job(lock=lambda args: f'app_upgrade_{args[0]}')
def upgrade(self, job, app_name, options):
"""
Expand Down

0 comments on commit f9ebf17

Please sign in to comment.