def files(self, key: str, content: Union[str, Dict[str, Any]] = None, source: str = None, local_file_path: str = None, encoding: str = None, group: str = None, owner: str = None, mode: str = None, authentication: str = None, context: str = None, local_file_params: str = None) -> 'CfnInitMetadata.Config': if local_file_params is None: local_file_params = {} m = OrderedDict() if content is not None: m['content'] = content if source is not None: m['source'] = source if local_file_path is not None: with open(local_file_path) as fh: c = fh.read() init_file_content = utils.inject_params(c, local_file_params) m['content'] = Intrinsics.join('', init_file_content) if encoding is not None: m['encoding'] = encoding if group is not None: m['group'] = group if owner is not None: m['owner'] = owner if mode is not None: m['mode'] = mode if authentication is not None: m['authentication'] = authentication if context is not None: m['context'] = context v = self._create_and_get_map(['files']) v[key] = m return self
def files(self, key: str, content: Union[str, Dict[str, Any]] = None, source: str = None, local_file_path: str = None, encoding: str = None, group: str = None, owner: str = None, mode: str = None, authentication: str = None, context: str = None, local_file_params: str = None) -> 'CfnInitMetadata.Config': if local_file_params is None: local_file_params = {} m = OrderedDict() if content is not None: m['content'] = content if source is not None: m['source'] = source if local_file_path is not None: with open(local_file_path) as fh: c = fh.read() init_file_content = utils.inject_params(c, local_file_params) m['content'] = Intrinsics.join('', init_file_content) if encoding is not None: m['encoding'] = encoding if group is not None: m['group'] = group if owner is not None: m['owner'] = owner if mode is not None: m['mode'] = mode if authentication is not None: m['authentication'] = authentication if context is not None: m['context'] = context v = self._create_and_get_map(['files']) v[key] = m return self
def test_inject_params__multi_placeholders_in_one_line(): assert_equal( inject_params('abcde__{{ fghij }}__{{ klmno }}__pqrst', {'fghij': '__fghij__', 'klmno': '__klmno__'}), ['abcde__', '__fghij__', '__', '__klmno__', '__pqrst\n'] )
def test_inject_params__illegal_placeholder__space_between_right_parns(): assert_equal( inject_params('abcde\n__{{ fghij } }__\nklmno\n', {'fghij': '__fghij__'}), ['abcde\n', '__{{ fghij } }__\n', 'klmno\n', '\n'] )
def test_inject_params__illegal_placeholder__no_spaces_on_the_both_sides(): assert_equal( inject_params('abcde\n__{{fghij}}__\nklmno\n', {'fghij': '__fghij__'}), ['abcde\n', '__{{fghij}}__\n', 'klmno\n', '\n'] )
def test_inject_params__no_parameters_passed(): assert_equal( inject_params('abcde\n__{{ fghij }}__\nklmno\n', {}), ['abcde\n', '__{{ fghij }}__\n', 'klmno\n', '\n'] )
def test_inject_params__all_placeholders_replaced(): assert_equal( inject_params('abcde\n__{{ fghij }}__\nklmno\n', {'fghij': '__fghij__'}), ['abcde\n', '__', '__fghij__', '__\n', 'klmno\n', '\n'] )
def from_files(cls, files: List[Tuple[str, str]], params: Dict[str, Any]) -> Dict[str, Any]: user_data = utils.inject_params(utils.combine_user_data(files), params) return {'UserData': Intrinsics.base64(Intrinsics.join('', user_data))}
def test_inject_params__multi_placeholders_in_one_line(): assert_equal( inject_params('abcde__{{ fghij }}__{{ klmno }}__pqrst', { 'fghij': '__fghij__', 'klmno': '__klmno__' }), ['abcde__', '__fghij__', '__', '__klmno__', '__pqrst\n'])
def test_inject_params__illegal_placeholder__space_between_right_parns(): assert_equal( inject_params('abcde\n__{{ fghij } }__\nklmno\n', {'fghij': '__fghij__'}), ['abcde\n', '__{{ fghij } }__\n', 'klmno\n', '\n'])
def test_inject_params__illegal_placeholder__no_spaces_on_the_both_sides(): assert_equal( inject_params('abcde\n__{{fghij}}__\nklmno\n', {'fghij': '__fghij__'}), ['abcde\n', '__{{fghij}}__\n', 'klmno\n', '\n'])
def test_inject_params__no_parameters_passed(): assert_equal(inject_params('abcde\n__{{ fghij }}__\nklmno\n', {}), ['abcde\n', '__{{ fghij }}__\n', 'klmno\n', '\n'])
def test_inject_params__all_placeholders_replaced(): assert_equal( inject_params('abcde\n__{{ fghij }}__\nklmno\n', {'fghij': '__fghij__'}), ['abcde\n', '__', '__fghij__', '__\n', 'klmno\n', '\n'])
def from_files(cls, files: List[Tuple[str, str]], params: Dict[str, Any]) -> Dict[str, Any]: user_data = utils.inject_params(utils.combine_user_data(files), params) return {'UserData': Intrinsics.base64(Intrinsics.join('', user_data))}