mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-26 21:33:02 +00:00
Add sinceSeconds parameter to k8s_logs (#142)
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Mike Graves <mgraves@redhat.com>
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- k8s_log - Add since-seconds parameter to the k8s_log module (https://github.com/ansible-collections/kubernetes.core/pull/142).
|
||||
@@ -54,6 +54,12 @@ options:
|
||||
- If there is more than one container, this option is required.
|
||||
required: no
|
||||
type: str
|
||||
since_seconds:
|
||||
description:
|
||||
- A relative time in seconds before the current time from which to show logs.
|
||||
required: no
|
||||
type: str
|
||||
version_added: '2.2.0'
|
||||
|
||||
requirements:
|
||||
- "python >= 3.6"
|
||||
@@ -83,6 +89,7 @@ EXAMPLES = r'''
|
||||
kind: Deployment
|
||||
namespace: testing
|
||||
name: example
|
||||
since_seconds: "4000"
|
||||
register: log
|
||||
|
||||
# This will get the log from a single Pod managed by this DeploymentConfig
|
||||
@@ -124,6 +131,7 @@ def argspec():
|
||||
dict(
|
||||
kind=dict(type='str', default='Pod'),
|
||||
container=dict(),
|
||||
since_seconds=dict(),
|
||||
label_selectors=dict(type='list', elements='str', default=[]),
|
||||
)
|
||||
)
|
||||
@@ -159,6 +167,9 @@ def execute_module(module, k8s_ansible_mixin):
|
||||
if module.params.get('container'):
|
||||
kwargs['query_params'] = dict(container=module.params['container'])
|
||||
|
||||
if module.params.get('since_seconds'):
|
||||
kwargs.setdefault('query_params', {}).update({'sinceSeconds': module.params['since_seconds']})
|
||||
|
||||
log = serialize_log(resource.log.get(
|
||||
name=name,
|
||||
namespace=namespace,
|
||||
|
||||
Reference in New Issue
Block a user