Initialize remotes
(
self,
remotes,
per_remote_overrides=(),
per_remote_only=PER_REMOTE_ONLY,
global_only=GLOBAL_ONLY,
)
| 3188 | return False |
| 3189 | |
| 3190 | def init_remotes( |
| 3191 | self, |
| 3192 | remotes, |
| 3193 | per_remote_overrides=(), |
| 3194 | per_remote_only=PER_REMOTE_ONLY, |
| 3195 | global_only=GLOBAL_ONLY, |
| 3196 | ): |
| 3197 | """ |
| 3198 | Initialize remotes |
| 3199 | """ |
| 3200 | # The global versions of the auth params (gitfs_user, |
| 3201 | # gitfs_password, etc.) default to empty strings. If any of them |
| 3202 | # are defined and the provider is not one that supports auth, then |
| 3203 | # error out and do not proceed. |
| 3204 | override_params = copy.deepcopy(per_remote_overrides) |
| 3205 | global_auth_params = [ |
| 3206 | f"{self.role}_{x}" for x in AUTH_PARAMS if self.opts.get(f"{self.role}_{x}") |
| 3207 | ] |
| 3208 | if self.provider in AUTH_PROVIDERS: |
| 3209 | override_params += AUTH_PARAMS |
| 3210 | elif global_auth_params: |
| 3211 | # If the provider is one we don't know about (like a mocked provider in tests) |
| 3212 | # and it's NOT in our core AUTH_PROVIDERS, we only fail if auth is actually configured. |
| 3213 | # If the provider is in self.git_providers but not in AUTH_PROVIDERS, |
| 3214 | # we'll allow it if no global auth is set. |
| 3215 | if self.provider not in self.git_providers: |
| 3216 | msg_auth_providers = "{}".format(", ".join(AUTH_PROVIDERS)) |
| 3217 | msg = ( |
| 3218 | f"{self.role} authentication was configured, but the '{self.provider}' " |
| 3219 | f"{self.role}_provider does not support authentication. The " |
| 3220 | f"providers for which authentication is supported in {self.role} " |
| 3221 | f"are: {msg_auth_providers}." |
| 3222 | ) |
| 3223 | if self.role == "gitfs": |
| 3224 | msg += ( |
| 3225 | " See the GitFS Walkthrough in the Salt documentation " |
| 3226 | "for further information." |
| 3227 | ) |
| 3228 | log.critical(msg) |
| 3229 | failhard(self.role) |
| 3230 | |
| 3231 | per_remote_defaults = {} |
| 3232 | global_values = set(override_params) |
| 3233 | global_values.update(set(global_only)) |
| 3234 | for param in global_values: |
| 3235 | key = f"{self.role}_{param}" |
| 3236 | if key not in self.opts: |
| 3237 | # Provide defaults for newly added parameters if they are missing |
| 3238 | # from global opts (e.g. in older configs or some tests) |
| 3239 | if param == "depth": |
| 3240 | val = 1 |
| 3241 | elif param == "ref_types": |
| 3242 | val = ["branch", "tag", "sha"] |
| 3243 | elif param == "disable_saltenv_mapping": |
| 3244 | val = False |
| 3245 | elif param == "fallback": |
| 3246 | val = "" |
| 3247 | else: |
no test coverage detected