-
Notifications
You must be signed in to change notification settings - Fork 2.7k
DataSource sync from git by ssh does not work #12464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think the best we can do here is add some validation to prevent both using the username field and including the username within the URL, however I don't know if we actually want to do that as that seems like a lot of extra work (we might have to write a separate parser for the URL) for very little gain. The second case should probably be handled better however I feel that this should be more documentation then a bug itself. "You can't use a username in the URL and the username/password backend fields." |
Both bug get trigger regardless if you enter a username and/or password in the backup parameters. @contextmanager
def fetch(self):
local_path = tempfile.TemporaryDirectory()
username = self.params.get('username')
password = self.params.get('password')
branch = self.params.get('branch')
config = StackedConfig.default()
if settings.HTTP_PROXIES and self.url_scheme in ('http', 'https'):
if proxy := settings.HTTP_PROXIES.get(self.url_scheme):
config.set("http", "proxy", proxy)
clone_kwargs = dict(
depth=1,
branch=branch,
username=username,
password=password,
config=config,
quiet=True
)
if self.url_scheme in ('git'):
del clone_kwargs['username']
del clone_kwargs['password']
logger.debug(f"Cloning git repo: {self.url}")
try:
porcelain.clone(
self.url, local_path.name, errstream=porcelain.NoneStream(), **clone_kwargs
)
except BaseException as e:
raise SyncError(f"Fetching remote data failed ({type(e).__name__}): {e}")
yield local_path.name
local_path.cleanup() |
I will create a PR |
NetBox version
v3.5.0
Python version
3.10
Steps to Reproduce
ssh://[email protected]:2222/project/netbox_scripts.git
)netbox/manage.py syncdatasource --all --traceback
Expected Behavior
The Datasource is synced.
Observed Behavior
An exception is raised.
porcelain
parses the username for ssh from the url. This leads to a error asporcelain
tries to call a function while supplying the kwarg username twice.It the username parameter is removed from netbox/core/data_backends.py#L104 it still fails as in ssh mode no password is allowed by
porcelain
.It the password parameter is removed too from netbox/core/data_backends.py#L104 the sync works with git over ssh and ssh key authentication.
The text was updated successfully, but these errors were encountered: