Commit Graph

40 Commits

Author SHA1 Message Date
Erik Johnson
3ab332ad0e
Update tests to reflect bugfix 2018-05-02 15:21:39 -05:00
rallytime
3416e398c6
Update old utils paths references to use new paths 2018-04-17 11:02:38 -04:00
rallytime
94c2a12be6
Merge branch '2017.7' into '2018.3'
Conflicts:
  - tests/integration/modules/test_state.py
  - tests/unit/templates/test_jinja.py
  - tests/unit/test_minion.py
2018-04-17 10:54:42 -04:00
Daniel A. Wozniak
25fd7c0694
fix py3 wart, encode os.linesep 2018-04-13 12:33:23 -07:00
Daniel A Wozniak
d79f1a1961
Fix fileserver roots tests 2018-04-13 10:15:13 -07:00
Erik Johnson
a0586748b6
Remove unused imports 2018-02-07 14:44:15 -06:00
Erik Johnson
fb05654b71
Add unit tests for new Oxygen gitfs features
Also expand unit tests to test both GitPython and pygit2
2018-02-07 12:00:44 -06:00
Erik Johnson
b5ef58c2aa
Fix salt.utils.path.os_walk for certain Python 2 versions
This helper was designed to ensure that the paths returned were all
unicode types, but on a couple platforms having the path be a unicode
type causes a traceback deep in the stdlib within posixpath.

To work around this, this commit makes the helper a generator that
simply decodes each tuple returned from os.walk as we iterate.
2018-01-23 23:03:17 -06:00
Erik Johnson
c27bb7c116
[PY3] Update fileserver for Unicode/PY3 compatibility
This adds a unicode_literals import to the fileserver code, and also ensures
that we return unicode paths from the serialized file/env list caches
(which when deserialized are still encoded str types on PY2).

It also adds a test and modifies a few other existing tests to confirm
that unicode paths/envs are returned *as unicode* in the return data.
2018-01-20 22:25:23 -06:00
Erik Johnson
2d6760ee40
Add update_interval to gitfs, "fs" to several virtual names
This also adds "fs" to all of the fileserver virtualnames which did not
already have them. This both A) normalizes the usage of the non-roots
backends, and B) makes it easier for the FileserverUpdate process to get
the default update interval for each backend from the opts.
2018-01-09 19:11:17 -06:00
Erik Johnson
002aa88a97
Replace yaml usage with a helper to ensure unicode is handled properly
Without allow_unicode=True, unicode characters are processed through the
str representer and on Python 2 are dumped as a Unicode code point (i.e.
a literal \u0414). This commit makes allow_unicode=True the default in
our salt.utils.yamlloader.safe_dump() helper. It also adds a new
salt.utils.yamlloader.dump() helper which wraps yaml.dump() and also
makes allow_unicode=True the default.

To make importing and using our custom yaml loader/dumper easier, a
convenience module called salt.utils.yaml has been added, which does a
wildcard import from both salt.utils.yamldumper and
salt.utils.yamlloader.

Refs to yaml.load/dump and yaml.safe_load/safe_dump have been updated to
salt.utils.yaml, to ensure that unicode is handled properly.
2018-01-03 14:14:21 -06:00
Erik Johnson
3e96225210
Use one salt.utils.gitfs.GitFS instance per thread
This reduces some of the overhead caused by many concurrent fileclient
requests from minions.

Additionally, initializing remotes has been folded into the GitBase
class' dunder init. Instantiating an instance and initializing its
remotes were initially split so that an object could simply be created
with the master opts so that the configuration was loaded and nothing
else, allowing for certain cases (like clearing the cache files) where
we didn't need to actually initialize the remotes. But this both A)
presents a problem when the instance being used is a singleton, as you
don't want to be re-initializing the remotes all the time, and B)
suppressing initialization can be (and is now being) done via a new
argument to the dunder init.
2017-10-16 15:25:29 -05:00
rallytime
9afc84091d Update which and is_windows calls to use new paths 2017-09-15 17:27:02 -04:00
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