Skip to content

Commit

Permalink
Rename "context" to "service_context"
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoyt committed Jul 11, 2023
1 parent c38729e commit 273330e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions ops/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2366,7 +2366,7 @@ def exec( # noqa
self,
command: List[str],
*,
context: Optional[str] = None,
service_context: Optional[str] = None,
environment: Optional[Dict[str, str]] = None,
working_dir: Optional[str] = None,
timeout: Optional[float] = None,
Expand All @@ -2388,7 +2388,7 @@ def exec( # noqa
self,
command: List[str],
*,
context: Optional[str] = None,
service_context: Optional[str] = None,
environment: Optional[Dict[str, str]] = None,
working_dir: Optional[str] = None,
timeout: Optional[float] = None,
Expand All @@ -2408,7 +2408,7 @@ def exec(
self,
command: List[str],
*,
context: Optional[str] = None,
service_context: Optional[str] = None,
environment: Optional[Dict[str, str]] = None,
working_dir: Optional[str] = None,
timeout: Optional[float] = None,
Expand All @@ -2429,7 +2429,7 @@ def exec(
"""
return self._pebble.exec(
command,
context=context,
service_context=service_context,
environment=environment,
working_dir=working_dir,
timeout=timeout,
Expand Down
14 changes: 7 additions & 7 deletions ops/pebble.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
total=False)
ExecDict = typing.TypedDict('ExecDict',
{'command': str,
'context': str,
'service-context': str,
'environment': Dict[str, str],
'user-id': Optional[int],
'user': str,
Expand Down Expand Up @@ -2154,7 +2154,7 @@ def exec( # noqa
self,
command: List[str],
*,
context: Optional[str] = None,
service_context: Optional[str] = None,
environment: Optional[Dict[str, str]] = None,
working_dir: Optional[str] = None,
timeout: Optional[float] = None,
Expand All @@ -2176,7 +2176,7 @@ def exec( # noqa
self,
command: List[str],
*,
context: Optional[str] = None,
service_context: Optional[str] = None,
environment: Optional[Dict[str, str]] = None,
working_dir: Optional[str] = None,
timeout: Optional[float] = None,
Expand All @@ -2196,7 +2196,7 @@ def exec(
self,
command: List[str],
*,
context: Optional[str] = None,
service_context: Optional[str] = None,
environment: Optional[Dict[str, str]] = None,
working_dir: Optional[str] = None,
timeout: Optional[float] = None,
Expand Down Expand Up @@ -2281,8 +2281,8 @@ def exec(
Args:
command: Command to execute: the first item is the name (or path)
of the executable, the rest of the items are the arguments.
context: If specified, run the command in the context of this
service. Specifically, inherit its environment variables,
service_context: If specified, run the command in the context of
this service. Specifically, inherit its environment variables,
user/group settings, and working directory. The other exec
options will override the service context; ``environment``
will be merged on top of the service's.
Expand Down Expand Up @@ -2351,7 +2351,7 @@ def exec(

body = {
'command': command,
'context': context,
'service-context': service_context,
'environment': environment or {},
'working-dir': working_dir,
'timeout': _format_timeout(timeout) if timeout is not None else None,
Expand Down
2 changes: 1 addition & 1 deletion test/pebble_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def main():

process = client.exec(
args.exec_command,
context=args.context,
service_context=args.context,
environment=environment,
working_dir=args.working_dir,
timeout=args.timeout,
Expand Down
4 changes: 2 additions & 2 deletions test/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ def test_exec(self):
self.pebble.responses.append('fake_exec_process')
p = self.container.exec(
['echo', 'foo'],
context='srv1',
service_context='srv1',
environment={'K1': 'V1', 'K2': 'V2'},
working_dir='WD',
timeout=10.5,
Expand All @@ -1797,7 +1797,7 @@ def test_exec(self):
)
self.assertEqual(self.pebble.requests, [
('exec', ['echo', 'foo'], dict(
context='srv1',
service_context='srv1',
environment={'K1': 'V1', 'K2': 'V2'},
working_dir='WD',
timeout=10.5,
Expand Down
4 changes: 2 additions & 2 deletions test/test_pebble.py
Original file line number Diff line number Diff line change
Expand Up @@ -2642,11 +2642,11 @@ def add_responses(self, change_id, exit_code, change_err=None):
return (stdio, stderr, control)

def build_exec_data(
self, command, context=None, environment=None, working_dir=None, timeout=None,
self, command, service_context=None, environment=None, working_dir=None, timeout=None,
user_id=None, user=None, group_id=None, group=None, combine_stderr=False):
return {
'command': command,
'context': context,
'service-context': service_context,
'environment': environment or {},
'working-dir': working_dir,
'timeout': f'{timeout:.3f}s' if timeout is not None else None,
Expand Down

0 comments on commit 273330e

Please sign in to comment.