Give user the option to disable SSL/TLS for the source and destination individually
This commit is contained in:
@@ -21,7 +21,13 @@ class API:
|
|||||||
|
|
||||||
return base
|
return base
|
||||||
|
|
||||||
def get(self, hostname, port, token) -> gitea.Gitea:
|
def get(
|
||||||
|
self,
|
||||||
|
hostname: str,
|
||||||
|
port: int,
|
||||||
|
token: str,
|
||||||
|
verify_ssl: bool = None
|
||||||
|
) -> gitea.Gitea:
|
||||||
|
|
||||||
url = API._make_api_base_url(
|
url = API._make_api_base_url(
|
||||||
hostname=hostname,
|
hostname=hostname,
|
||||||
@@ -29,8 +35,15 @@ class API:
|
|||||||
)
|
)
|
||||||
|
|
||||||
ssl_verify_arg = True
|
ssl_verify_arg = True
|
||||||
if self.__verify_ssl is not None:
|
if verify_ssl is not None:
|
||||||
|
ssl_verify_arg = verify_ssl
|
||||||
|
else:
|
||||||
ssl_verify_arg = self.__verify_ssl
|
ssl_verify_arg = self.__verify_ssl
|
||||||
|
|
||||||
|
print(f"API::get -> hostname {hostname}")
|
||||||
|
print(f"API::get -> verify_ssl was {verify_ssl}")
|
||||||
|
print(f"API::get -> ssl_verify_arg became {ssl_verify_arg}")
|
||||||
|
|
||||||
if self.__ca_bundle is not None:
|
if self.__ca_bundle is not None:
|
||||||
ssl_verify_arg = self.__ca_bundle
|
ssl_verify_arg = self.__ca_bundle
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ class Migrator:
|
|||||||
self,
|
self,
|
||||||
source_host, source_port, source_token,
|
source_host, source_port, source_token,
|
||||||
destination_host, destination_port, destination_token,
|
destination_host, destination_port, destination_token,
|
||||||
verify_ssl: bool = True, ca_bundle: str = None
|
verify_ssl: bool = True, verify_source_ssl: bool = True, verify_destination_ssl: bool = True,
|
||||||
|
ca_bundle: str = None
|
||||||
):
|
):
|
||||||
|
|
||||||
# noinspection PyTypeChecker
|
# noinspection PyTypeChecker
|
||||||
@@ -34,6 +35,9 @@ class Migrator:
|
|||||||
self.__destination_token = destination_token
|
self.__destination_token = destination_token
|
||||||
|
|
||||||
self.__verify_ssl = verify_ssl
|
self.__verify_ssl = verify_ssl
|
||||||
|
self.__verify_source_ssl = verify_source_ssl
|
||||||
|
self.__verify_destination_ssl = verify_destination_ssl
|
||||||
|
|
||||||
self.__ca_bundle = ca_bundle
|
self.__ca_bundle = ca_bundle
|
||||||
|
|
||||||
api = API(
|
api = API(
|
||||||
@@ -45,12 +49,14 @@ class Migrator:
|
|||||||
hostname=self.__source_host,
|
hostname=self.__source_host,
|
||||||
port=self.__source_port,
|
port=self.__source_port,
|
||||||
token=self.__source_token,
|
token=self.__source_token,
|
||||||
|
verify_ssl=self.__verify_source_ssl,
|
||||||
|
|
||||||
)
|
)
|
||||||
self.__destination_api = api.get(
|
self.__destination_api = api.get(
|
||||||
hostname=self.__destination_host,
|
hostname=self.__destination_host,
|
||||||
port=self.__destination_port,
|
port=self.__destination_port,
|
||||||
token=self.__destination_token,
|
token=self.__destination_token,
|
||||||
|
verify_ssl=self.__verify_destination_ssl,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _init_logger(self):
|
def _init_logger(self):
|
||||||
|
|||||||
25
main.py
25
main.py
@@ -21,6 +21,8 @@ def main():
|
|||||||
help="Specify the working directory"
|
help="Specify the working directory"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
######################
|
||||||
|
##### Source Arguments
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--source-hostname", "--source-host",
|
"--source-hostname", "--source-host",
|
||||||
dest="source_hostname",
|
dest="source_hostname",
|
||||||
@@ -55,6 +57,8 @@ def main():
|
|||||||
" Any repository that doesn't have all required topics will be skipped"
|
" Any repository that doesn't have all required topics will be skipped"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
###########################
|
||||||
|
##### Destination Arguments
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--destination-hostname", "--dest-hostname", "--destination-host", "--dest-host",
|
"--destination-hostname", "--dest-hostname", "--destination-host", "--dest-host",
|
||||||
dest="destination_hostname",
|
dest="destination_hostname",
|
||||||
@@ -125,14 +129,31 @@ def main():
|
|||||||
help="Do not ask to confirm each migration; Migrate all repos quickly.",
|
help="Do not ask to confirm each migration; Migrate all repos quickly.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
###################
|
||||||
|
##### SSL/TLS Stuff
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--no-verify-ssl",
|
"--no-verify-ssl",
|
||||||
dest="verify_ssl",
|
dest="verify_ssl",
|
||||||
default=True,
|
default=True,
|
||||||
action="store_false",
|
action="store_false",
|
||||||
help="Don't verify SSL certificates",
|
help="Don't verify SSL/TLS certificates",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--no-verify-source-ssl",
|
||||||
|
dest="verify_source_ssl",
|
||||||
|
default=None,
|
||||||
|
action="store_false",
|
||||||
|
help="Don't verify the SSL/TLS certificate for the source host",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--no-verify-destination-ssl",
|
||||||
|
dest="verify_destination_ssl",
|
||||||
|
default=None,
|
||||||
|
action="store_false",
|
||||||
|
help="Don't verify the SSL/TLS certificate for the destination host",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Doesn't seem to be helpful?
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--ca-bundle",
|
"--ca-bundle",
|
||||||
dest="ca_bundle",
|
dest="ca_bundle",
|
||||||
@@ -153,6 +174,8 @@ def main():
|
|||||||
destination_port=args.destination_port,
|
destination_port=args.destination_port,
|
||||||
destination_token=args.destination_token,
|
destination_token=args.destination_token,
|
||||||
verify_ssl=args.verify_ssl,
|
verify_ssl=args.verify_ssl,
|
||||||
|
verify_source_ssl=args.verify_source_ssl,
|
||||||
|
verify_destination_ssl=args.verify_destination_ssl,
|
||||||
ca_bundle=args.ca_bundle
|
ca_bundle=args.ca_bundle
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user