-
Notifications
You must be signed in to change notification settings - Fork 121
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
Add support for exec "service-context" #957
Changes from 10 commits
0294f7d
8f68a98
31926c4
7561a98
c38729e
273330e
e1545ee
15831c2
3432745
d024ce8
001b16a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ | |
'user-id': Optional[int], | ||
'group': str, | ||
'group-id': Optional[int], | ||
'working-dir': str, | ||
'on-success': str, | ||
'on-failure': str, | ||
'on-check-failure': Dict[str, Any], | ||
|
@@ -88,9 +89,25 @@ | |
}, | ||
total=False) | ||
|
||
HttpDict = typing.TypedDict('HttpDict', {'url': str}) | ||
TcpDict = typing.TypedDict('TcpDict', {'port': int}) | ||
ExecDict = typing.TypedDict('ExecDict', {'command': str}) | ||
HttpDict = typing.TypedDict('HttpDict', | ||
{'url': str, | ||
'headers': Dict[str, str]}, | ||
total=False) | ||
TcpDict = typing.TypedDict('TcpDict', | ||
{'port': int, | ||
'host': str}, | ||
total=False) | ||
ExecDict = typing.TypedDict('ExecDict', | ||
{'command': str, | ||
# see JujuVersion.supports_exec_service_context | ||
'service-context': str, | ||
'environment': Dict[str, str], | ||
'user-id': Optional[int], | ||
'user': str, | ||
'group-id': Optional[int], | ||
'group': str, | ||
'working-dir': str}, | ||
total=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How did these get so out of sync with what you can put into them? Presumably because they are just dicts (so you could have always passed additional information there). What if pebble had a "validate these arguments" mode, where it didn't actually run it, but at least validated the content, and then an ops test that if it doesn't see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These types only just became public (in ops 2.4.0), so that's probably the main reason. I wanted them to be public so people could use them to type check their Separately, we're planning to add a |
||
|
||
CheckDict = typing.TypedDict('CheckDict', | ||
{'override': str, | ||
|
@@ -800,6 +817,7 @@ def __init__(self, name: str, raw: Optional['ServiceDict'] = None): | |
self.user_id = dct.get('user-id') | ||
self.group = dct.get('group', '') | ||
self.group_id = dct.get('group-id') | ||
self.working_dir = dct.get('working-dir', '') | ||
self.on_success = dct.get('on-success', '') | ||
self.on_failure = dct.get('on-failure', '') | ||
self.on_check_failure = dict(dct.get('on-check-failure', {})) | ||
|
@@ -823,6 +841,7 @@ def to_dict(self) -> 'ServiceDict': | |
('user-id', self.user_id), | ||
('group', self.group), | ||
('group-id', self.group_id), | ||
('working-dir', self.working_dir), | ||
('on-success', self.on_success), | ||
('on-failure', self.on_failure), | ||
('on-check-failure', self.on_check_failure), | ||
|
@@ -2136,6 +2155,7 @@ def exec( # noqa | |
self, | ||
command: List[str], | ||
*, | ||
service_context: Optional[str] = None, | ||
environment: Optional[Dict[str, str]] = None, | ||
working_dir: Optional[str] = None, | ||
timeout: Optional[float] = None, | ||
|
@@ -2157,6 +2177,7 @@ def exec( # noqa | |
self, | ||
command: List[str], | ||
*, | ||
service_context: Optional[str] = None, | ||
environment: Optional[Dict[str, str]] = None, | ||
working_dir: Optional[str] = None, | ||
timeout: Optional[float] = None, | ||
|
@@ -2176,6 +2197,7 @@ def exec( | |
self, | ||
command: List[str], | ||
*, | ||
service_context: Optional[str] = None, | ||
environment: Optional[Dict[str, str]] = None, | ||
working_dir: Optional[str] = None, | ||
timeout: Optional[float] = None, | ||
|
@@ -2260,6 +2282,11 @@ 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. | ||
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. | ||
environment: Environment variables to pass to the process. | ||
working_dir: Working directory to run the command in. If not set, | ||
Pebble uses the target user's $HOME directory (and if the user | ||
|
@@ -2325,6 +2352,7 @@ def exec( | |
|
||
body = { | ||
'command': command, | ||
'service-context': service_context, | ||
'environment': environment or {}, | ||
'working-dir': working_dir, | ||
'timeout': _format_timeout(timeout) if timeout is not None else None, | ||
|
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.
fwiw, 3.2.1 isn't "out" it just is a burned release number so nobody will ever run it.
Anyway, are we sure that this is a true statement? Have we already landed the pebble changes into the juju branches such that the next releases will have the service context?
Would this read cleaner as: