Commit Graph

27 Commits

Author SHA1 Message Date
rallytime
14f5e5e023 Merge branch '2017.7' into 'develop'
Conflicts:
  - salt/modules/augeas_cfg.py
  - salt/modules/inspectlib/collector.py
2017-08-30 12:16:28 -04:00
twangboy
c956d24283 Fix is_windows detection when USERNAME missing 2017-08-29 10:16:21 -06:00
twangboy
869e8cc603 Fix unit.fileserver.test_gitfs for Windows
Put `import pwd` in a try/except block
Set `os.environ['USERNAME']` in windows using win_functions
Add error function for `shutil.rmtree`
2017-08-29 10:16:21 -06:00
Erik Johnson
3184168365 Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.

A summary of the changes in this PR is as follows:

* Moves the following functions from `salt.utils` to new locations
  (including a deprecation warning if invoked from `salt.utils`):
  `to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
  `dequote`, `is_hex`, `is_bin_str`, `rand_string`,
  `contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
  `which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
  `is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
  `is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
  `is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
  `salt/utils/__init__.py` for better organization, so we can keep the
  deprecated ones separate from the ones yet to be deprecated as we
  continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
  unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
  import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
  accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
  such that it returns a string matching the passed size. Previously
  this function would get `size` bytes from `os.urandom()`,
  base64-encode it, and return the result, which would in most cases not
  be equal to the passed size.
2017-08-08 13:33:43 -05:00
rallytime
df693423b9 Move salt.utils.rm_rf to salt.utils.files.rm_rf
Also added a deprecation warning to utils/__init__.py and updated
all references to rm_rf in salt codebase.
2017-07-18 10:48:54 -06:00
rallytime
ccf790a83f Update all references for moved functions to use "files" util
- fopen
- flopen
- fpopen
- safe_rm
- is_empty
- is_fcntl_available
2017-07-18 10:31:01 -06:00
rallytime
9227a1263d Merge branch '2017.7' into 'develop'
No conflicts.
2017-06-30 10:00:01 -06:00
twangboy
cdb53c2657 Set file_roots for Windows Temp 2017-06-29 13:01:10 -06:00
Erik Johnson
798567b766 Add new gitfs config options to mocked opts 2017-06-21 12:42:48 -05:00
Erik Johnson
67363f6e32 Update fileserver unit tests
This fixes the tests by adding back gitfs_env_blacklist, and also
converts the config tests to use the new LoaderModuleMixin.
2017-05-08 20:30:46 -05:00
Erik Johnson
59737a34a5 Rename the *_env_blacklist config opts to *_saltenv_blacklist
These were overlooked a while back when we deprecated env in favor of
saltenv.
2017-05-06 23:11:33 -05:00
Pedro Algarvio
75569c8e99
unittest.TestCase does not have a skip() method. It's skipTest. 2017-04-28 13:33:33 +01:00
Pedro Algarvio
8031ac0209
Move mixins to tests.support.mixins.
The adapted config mixin get config methods are not static methods
2017-04-04 17:29:34 +01:00
Pedro Algarvio
d6d3161f80
Use a temporary configuration instead 2017-04-01 19:00:14 +01:00
Pedro Algarvio
ec7182a292
Use a temporary configuration instead 2017-04-01 18:55:48 +01:00
Pedro Algarvio
d05028e88c
These are not integration tests 2017-04-01 14:22:51 +01:00
Pedro Algarvio
b25b26e23d
Cleanup test attributes once finished 2017-03-28 19:00:51 +01:00
Pedro Algarvio
40a64191a1
Absolute imports and A LOT of code cleanup. 2017-03-01 01:33:07 +00:00
Pedro Algarvio
3beb3fb801
Move whatever we need from salttesting to salt.
Let's drop the salttesting dependency cycle.
2017-02-28 22:52:49 +00:00
Pedro Algarvio
f7974b186b
Code cleanup 2017-02-24 00:49:32 +00:00
Pedro Algarvio
15af4c9728
Test filenames conformity. Adjust for pytest. 2017-02-23 23:19:42 +00:00
Erik Johnson
d35c2f810c salt.utils.gitfs: remove dulwich support, make refspecs configurable (#39210)
* Add config params for custom refspecs

* Add exceptions for errors encountered modifying git config

* Make the refspecs a configurable parameter

* Make refspecs a per-remote parameter

* Update master config template to include custom refspecs opts

* Add documentation for new config params

* Update GitFS walkthrough with a section on custom refspecs

* Remove dulwich support from salt.utils.gitfs

Dulwich still lacks important features, including (but not limited to)
the following:

- Lack of the necessary support for checking out a ref needed for
  git_pillar/winrepo support

- No support in its config objects for multivar git config items, making
  it impossible to detect when repos have multiple refspecs set for a
  given git remote

Given this information, and the fact that it trails as a distant third
to Pygit2 and GitPython, Salt will cease to support Dulwich as a git
interface moving forward.

* Excise references to dulwich from documentation

* Add mention of custom refspecs to Nitrogen release notes

* Add gitfs_refspecs to mocked opts in gitfs integration tests

Also remove dulwich from unit tests

* Add information about opts argument not being intended for CLI use
2017-02-09 09:50:45 -07:00
Erik Johnson
3345da0d36 Add tests for gitfs per-saltenv configuration (#29954) 2016-09-03 14:59:04 -05:00
Erik Johnson
c35ed45668 Rename test file so that it runs properly when unit tests are executed 2016-09-03 14:59:04 -05:00
Nicole Thomas
b089db6f21 Fix pylint of develop (#35002) 2016-07-27 15:18:29 -06:00
Mike Place
48aa151fa6 Fixup #33875 2016-07-27 13:17:57 -06:00
Eu
3954529502 Fix naive fileserver map diff algorithm
Naively comparing sorted dict keys does not guarantee that maps are equal. We
must compare mtimes for filenames in case keys are the same to make sure there
isnt a modified file.
2016-06-08 16:36:39 -03:00