Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ repos:
)$

- repo: https://github.com/s0undt3ch/python-tools-scripts
rev: "0.12.0"
rev: "0.18.1"
hooks:
- id: tools
alias: check-changelog-entries
Expand Down Expand Up @@ -1037,7 +1037,7 @@ repos:

# ----- Code Formatting ------------------------------------------------------------------------------------------->
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.2
rev: v3.13.0
hooks:
- id: pyupgrade
name: Drop six usage and Py2 support
Expand All @@ -1058,7 +1058,7 @@ repos:

- repo: https://github.com/s0undt3ch/salt-rewrite
# Automatically rewrite code with known rules
rev: 2.4.4
rev: 2.5.2
hooks:
- id: salt-rewrite
alias: rewrite-docstrings
Expand Down Expand Up @@ -1091,7 +1091,7 @@ repos:
)$

- repo: https://github.com/psf/black
rev: 22.6.0
rev: 23.9.1
hooks:
- id: black
# This tells pre-commit not to pass files to black.
Expand All @@ -1104,7 +1104,7 @@ repos:
)$

- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
rev: 1.16.0
hooks:
- id: blacken-docs
args: [--skip-errors]
Expand All @@ -1116,7 +1116,7 @@ repos:

# ----- Security -------------------------------------------------------------------------------------------------->
- repo: https://github.com/PyCQA/bandit
rev: "1.7.4"
rev: "1.7.5"
hooks:
- id: bandit
alias: bandit-salt
Expand All @@ -1130,7 +1130,7 @@ repos:
)$
additional_dependencies: ['importlib_metadata<5']
- repo: https://github.com/PyCQA/bandit
rev: "1.7.4"
rev: "1.7.5"
hooks:
- id: bandit
alias: bandit-tests
Expand Down Expand Up @@ -1251,7 +1251,7 @@ repos:
- looseversion

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.0
rev: v1.5.1
hooks:
- id: mypy
alias: mypy-tools
Expand All @@ -1266,7 +1266,7 @@ repos:
- types-requests

- repo: https://github.com/saltstack/mirrors-nox
rev: v2021.6.12
rev: v2022.11.21
hooks:
- id: nox
alias: lint-salt
Expand All @@ -1286,7 +1286,7 @@ repos:
- pip>=20.2.4,<21.2

- repo: https://github.com/saltstack/mirrors-nox
rev: v2021.6.12
rev: v2022.11.21
hooks:
- id: nox
alias: lint-tests
Expand Down
13 changes: 3 additions & 10 deletions salt/daemons/masterapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import salt.utils.verify
import salt.wheel
from salt.defaults import DEFAULT_TARGET_DELIM
from salt.pillar import git_pillar

try:
import pwd
Expand All @@ -65,13 +64,7 @@ def init_git_pillar(opts):
for opts_dict in [x for x in opts.get("ext_pillar", [])]:
if "git" in opts_dict:
try:
pillar = salt.utils.gitfs.GitPillar(
opts,
opts_dict["git"],
per_remote_overrides=git_pillar.PER_REMOTE_OVERRIDES,
per_remote_only=git_pillar.PER_REMOTE_ONLY,
global_only=git_pillar.GLOBAL_ONLY,
)
pillar = salt.utils.gitfs.GitPillar(opts, opts_dict["git"])
ret.append(pillar)
except salt.exceptions.FileserverConfigError:
if opts.get("git_pillar_verify_config", True):
Expand Down Expand Up @@ -132,7 +125,7 @@ def clean_pub_auth(opts):
if not os.path.exists(auth_cache):
return
else:
for (dirpath, dirnames, filenames) in salt.utils.path.os_walk(auth_cache):
for dirpath, dirnames, filenames in salt.utils.path.os_walk(auth_cache):
for auth_file in filenames:
auth_file_path = os.path.join(dirpath, auth_file)
if not os.path.isfile(auth_file_path):
Expand Down Expand Up @@ -724,7 +717,7 @@ def _file_recv(self, load):
if not os.path.isdir(cdir):
try:
os.makedirs(cdir)
except os.error:
except OSError:
pass
if os.path.isfile(cpath) and load["loc"] != 0:
mode = "ab"
Expand Down
22 changes: 0 additions & 22 deletions salt/fileserver/gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,6 @@
import salt.utils.gitfs
from salt.exceptions import FileserverConfigError

PER_REMOTE_OVERRIDES = (
"base",
"fallback",
"mountpoint",
"root",
"ssl_verify",
"saltenv_whitelist",
"saltenv_blacklist",
"refspecs",
"disable_saltenv_mapping",
"ref_types",
"update_interval",
)
PER_REMOTE_ONLY = ("all_saltenvs", "name", "saltenv")

# Auth support (auth params can be global or per-remote, too)
AUTH_PROVIDERS = ("pygit2",)
AUTH_PARAMS = ("user", "password", "pubkey", "privkey", "passphrase", "insecure_auth")


log = logging.getLogger(__name__)

# Define the module's virtual name
Expand All @@ -84,8 +64,6 @@ def _gitfs(init_remotes=True):
return salt.utils.gitfs.GitFS(
__opts__,
__opts__["gitfs_remotes"],
per_remote_overrides=PER_REMOTE_OVERRIDES,
per_remote_only=PER_REMOTE_ONLY,
init_remotes=init_remotes,
)

Expand Down
10 changes: 3 additions & 7 deletions salt/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def handle_key_rotate(self, now):
else:
log.error("Found dropfile with incorrect permissions, ignoring...")
os.remove(dfn)
except os.error:
except OSError:
pass

if self.opts.get("publish_session"):
Expand Down Expand Up @@ -665,9 +665,6 @@ def _pre_flight(self):
git_pillar = salt.utils.gitfs.GitPillar(
new_opts,
repo["git"],
per_remote_overrides=salt.pillar.git_pillar.PER_REMOTE_OVERRIDES,
per_remote_only=salt.pillar.git_pillar.PER_REMOTE_ONLY,
global_only=salt.pillar.git_pillar.GLOBAL_ONLY,
)
except salt.exceptions.FileserverConfigError as exc:
critical_errors.append(exc.strerror)
Expand Down Expand Up @@ -698,7 +695,6 @@ def start(self):
# manager. We don't want the processes being started to inherit those
# signal handlers
with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM):

# Setup the secrets here because the PubServerChannel may need
# them as well.
SMaster.secrets["aes"] = {
Expand Down Expand Up @@ -884,7 +880,7 @@ def __bind(self):
# Cannot delete read-only files on Windows.
os.chmod(dfn, stat.S_IRUSR | stat.S_IWUSR)
os.remove(dfn)
except os.error:
except OSError:
pass

# Wait for kill should be less then parent's ProcessManager.
Expand Down Expand Up @@ -1572,7 +1568,7 @@ def _file_recv(self, load):
if not os.path.isdir(cdir):
try:
os.makedirs(cdir)
except os.error:
except OSError:
pass
if os.path.isfile(cpath) and load["loc"] != 0:
mode = "ab"
Expand Down
9 changes: 1 addition & 8 deletions salt/pillar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,16 +1161,9 @@ def ext_pillar(self, pillar, errors=None):
# the git ext_pillar() func is run, but only for masterless.
if self.ext and "git" in self.ext and self.opts.get("__role") != "minion":
# Avoid circular import
import salt.pillar.git_pillar
import salt.utils.gitfs

git_pillar = salt.utils.gitfs.GitPillar(
self.opts,
self.ext["git"],
per_remote_overrides=salt.pillar.git_pillar.PER_REMOTE_OVERRIDES,
per_remote_only=salt.pillar.git_pillar.PER_REMOTE_ONLY,
global_only=salt.pillar.git_pillar.GLOBAL_ONLY,
)
git_pillar = salt.utils.gitfs.GitPillar(self.opts, self.ext["git"])
git_pillar.fetch_remotes()
except TypeError:
# Handle malformed ext_pillar
Expand Down
7 changes: 0 additions & 7 deletions salt/pillar/git_pillar.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,6 @@
from salt.exceptions import FileserverConfigError
from salt.pillar import Pillar

PER_REMOTE_OVERRIDES = ("base", "env", "root", "ssl_verify", "refspecs", "fallback")
PER_REMOTE_ONLY = ("name", "mountpoint", "all_saltenvs")
GLOBAL_ONLY = ("branch",)

# Set up logging
log = logging.getLogger(__name__)

Expand Down Expand Up @@ -438,9 +434,6 @@ def ext_pillar(minion_id, pillar, *repos): # pylint: disable=unused-argument
git_pillar = salt.utils.gitfs.GitPillar(
opts,
repos,
per_remote_overrides=PER_REMOTE_OVERRIDES,
per_remote_only=PER_REMOTE_ONLY,
global_only=GLOBAL_ONLY,
)
if __opts__.get("__role") == "minion":
# If masterless, fetch the remotes. We'll need to remove this once
Expand Down
10 changes: 0 additions & 10 deletions salt/runners/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import salt.config
import salt.fileserver.gitfs
import salt.payload
import salt.pillar.git_pillar
import salt.runners.winrepo
import salt.utils.args
import salt.utils.gitfs
import salt.utils.master
Expand Down Expand Up @@ -289,8 +287,6 @@ def clear_git_lock(role, remote=None, **kwargs):
salt.utils.gitfs.GitFS(
__opts__,
__opts__["gitfs_remotes"],
per_remote_overrides=salt.fileserver.gitfs.PER_REMOTE_OVERRIDES,
per_remote_only=salt.fileserver.gitfs.PER_REMOTE_ONLY,
)
]
elif role == "git_pillar":
Expand All @@ -303,9 +299,6 @@ def clear_git_lock(role, remote=None, **kwargs):
obj = salt.utils.gitfs.GitPillar(
__opts__,
ext_pillar["git"],
per_remote_overrides=salt.pillar.git_pillar.PER_REMOTE_OVERRIDES,
per_remote_only=salt.pillar.git_pillar.PER_REMOTE_ONLY,
global_only=salt.pillar.git_pillar.GLOBAL_ONLY,
)
git_objects.append(obj)
elif role == "winrepo":
Expand All @@ -320,9 +313,6 @@ def clear_git_lock(role, remote=None, **kwargs):
obj = salt.utils.gitfs.WinRepo(
__opts__,
remotes,
per_remote_overrides=salt.runners.winrepo.PER_REMOTE_OVERRIDES,
per_remote_only=salt.runners.winrepo.PER_REMOTE_ONLY,
global_only=salt.runners.winrepo.GLOBAL_ONLY,
cache_root=base_dir,
)
git_objects.append(obj)
Expand Down
9 changes: 1 addition & 8 deletions salt/runners/git_pillar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import logging

import salt.pillar.git_pillar
import salt.utils.gitfs
from salt.exceptions import SaltRunnerError

Expand Down Expand Up @@ -67,13 +66,7 @@ def update(branch=None, repo=None):
if pillar_type != "git":
continue
pillar_conf = ext_pillar[pillar_type]
pillar = salt.utils.gitfs.GitPillar(
__opts__,
pillar_conf,
per_remote_overrides=salt.pillar.git_pillar.PER_REMOTE_OVERRIDES,
per_remote_only=salt.pillar.git_pillar.PER_REMOTE_ONLY,
global_only=salt.pillar.git_pillar.GLOBAL_ONLY,
)
pillar = salt.utils.gitfs.GitPillar(__opts__, pillar_conf)
for remote in pillar.remotes:
# Skip this remote if it doesn't match the search criteria
if branch is not None:
Expand Down
13 changes: 0 additions & 13 deletions salt/runners/winrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@

log = logging.getLogger(__name__)

# Global parameters which can be overridden on a per-remote basis
PER_REMOTE_OVERRIDES = ("ssl_verify", "refspecs", "fallback")

# Fall back to default per-remote-only. This isn't technically needed since
# salt.utils.gitfs.GitBase.__init__ will default to
# salt.utils.gitfs.PER_REMOTE_ONLY for this value, so this is mainly for
# runners and other modules that import salt.runners.winrepo.
PER_REMOTE_ONLY = salt.utils.gitfs.PER_REMOTE_ONLY
GLOBAL_ONLY = ("branch",)


def _legacy_git():
return not any(
Expand Down Expand Up @@ -228,9 +218,6 @@ def update_git_repos(opts=None, clean=False, masterless=False):
winrepo = salt.utils.gitfs.WinRepo(
opts,
remotes,
per_remote_overrides=PER_REMOTE_OVERRIDES,
per_remote_only=PER_REMOTE_ONLY,
global_only=GLOBAL_ONLY,
cache_root=base_dir,
)
winrepo.fetch_remotes()
Expand Down
Loading