mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #35285 from xbglowx/develop
Fixes #30577 - Add log_config option
This commit is contained in:
commit
08095474b2
@ -546,6 +546,14 @@ VALID_CREATE_OPTS = {
|
||||
'min_docker': (1, 5, 0),
|
||||
'default': '',
|
||||
},
|
||||
'log_config': {
|
||||
'path': 'HostConfig:LogConfig',
|
||||
'min_docker': (1, 4, 0),
|
||||
'default': {
|
||||
'Type': None,
|
||||
'Config': {},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -1811,6 +1819,31 @@ def _validate_input(kwargs,
|
||||
'pid_mode can only be \'host\', if set'
|
||||
)
|
||||
|
||||
def _valid_log_config(): # pylint: disable=unused-variable
|
||||
'''
|
||||
Needs to be a dictionary that might contain keys Type and Config
|
||||
'''
|
||||
try:
|
||||
_valid_dict('log_config')
|
||||
except SaltInvocationError:
|
||||
raise SaltInvocationError(
|
||||
'log_config must be of type \'dict\', if set'
|
||||
)
|
||||
|
||||
log_config = kwargs.get('log_config')
|
||||
log_config_type = log_config.get('Type', None)
|
||||
if log_config_type and not isinstance(log_config_type,
|
||||
six.string_types):
|
||||
raise SaltInvocationError(
|
||||
'log_config[\'type\'] must be of type \'str\''
|
||||
)
|
||||
|
||||
log_config_config = log_config.get('Config', {})
|
||||
if log_config_config and not isinstance(log_config_config, dict):
|
||||
raise SaltInvocationError(
|
||||
'log_config[\'config\'] must be of type \'dict\''
|
||||
)
|
||||
|
||||
def _valid_labels(): # pylint: disable=unused-variable
|
||||
'''
|
||||
Must be a dict or a list of strings
|
||||
@ -3016,6 +3049,14 @@ def create(image,
|
||||
|
||||
Example: ``pid_mode=host``
|
||||
|
||||
log_config
|
||||
Set container's log driver and options
|
||||
|
||||
Example: ``log_conf:
|
||||
Type: json-file
|
||||
Config:
|
||||
max-file: '10'``
|
||||
|
||||
**RETURN DATA**
|
||||
|
||||
A dictionary containing the following keys:
|
||||
|
@ -422,6 +422,17 @@ def _compare(actual, create_kwargs, defaults_from_image):
|
||||
if actual_data != data:
|
||||
ret.update({item: {'old': actual_data, 'new': data}})
|
||||
continue
|
||||
elif item == 'log_config':
|
||||
# https://github.com/saltstack/salt/issues/30577#issuecomment-238322721
|
||||
if not data.get('Config', None) and actual_data.get('Config', None):
|
||||
data['Config'] = {}
|
||||
actual_data['Config'] = {}
|
||||
if not data.get('Type', None) and actual_data.get('Type', None):
|
||||
data['Type'] = None
|
||||
actual_data['Type'] = None
|
||||
if data != actual_data:
|
||||
ret.update({item: {'old': actual_data, 'new': data}})
|
||||
continue
|
||||
elif item in ('cmd', 'command', 'entrypoint'):
|
||||
if (actual_data is None and item not in create_kwargs and
|
||||
_image_get(config['image_path'])):
|
||||
|
Loading…
Reference in New Issue
Block a user