Skip to content

Commit

Permalink
fix: jans-linux-setup code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Apr 26, 2022
1 parent da007f0 commit b01da85
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/jans_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def ami_packaged():
print("Installing Janssen Server...\n\nFor more info see:\n {} \n {}\n".format(paths.LOG_FILE, paths.LOG_ERROR_FILE))
print("Profile : {}".format(Config.profile))
print("Detected OS : {}".format(detected_os))
print("Janssen Version : {}".format(Config.oxVersion))
print("Janssen Version : {}".format(Config.ox_version))
print("Detected init : {}".format(base.os_initdaemon))
print("Detected Apache : {}".format(base.determineApacheVersion()))
print()
Expand Down
4 changes: 3 additions & 1 deletion jans-linux-setup/jans_setup/openbanking/setup_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def init(self, install_dir=INSTALL_DIR):
self.install_dir = install_dir
with open(os.path.join(self.install_dir, 'app_info.json')) as f:
self.app_info = json.load(f)
if not 'SETUP_BRANCH' in self.app_info:
self.app_info['SETUP_BRANCH'] = 'main'

self.oxVersion = self.app_info['JANS_APP_VERSION'] + self.app_info['JANS_BUILD']
self.ox_version = self.app_info['JANS_APP_VERSION'] + self.app_info['JANS_BUILD']

self.thread_queue = None
self.jetty_user = 'jetty'
Expand Down
4 changes: 3 additions & 1 deletion jans-linux-setup/jans_setup/setup_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ def init(self, install_dir=INSTALL_DIR):
self.install_dir = install_dir
with open(os.path.join(self.install_dir, 'app_info.json')) as f:
self.app_info = json.load(f)
if not 'SETUP_BRANCH' in self.app_info:
self.app_info['SETUP_BRANCH'] = 'main'

self.oxVersion = self.app_info['JANS_APP_VERSION'] + self.app_info['JANS_BUILD']
self.ox_version = self.app_info['JANS_APP_VERSION'] + self.app_info['JANS_BUILD']

self.data_dir = os.path.join(self.install_dir, 'setup_app/data')
self.thread_queue = None
Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def check_download_needed(self, src):
if os.path.exists(src):
war_info = get_war_info(src)
if war_info.get('version'):
return LooseVersion(war_info['version']) < LooseVersion(Config.oxVersion)
return LooseVersion(war_info['version']) < LooseVersion(Config.ox_version)

return True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def __init__(self):
self.custom_config_dir = os.path.join(self.jetty_base, self.service_name, 'custom/config')

self.source_files = [
(os.path.join(Config.distJansFolder, 'jans-config-api.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api-server/{0}/jans-config-api-server-{0}.war').format(Config.oxVersion)),
(os.path.join(Config.distJansFolder, 'scim-plugin.jar'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api/plugins/scim-plugin/{0}/scim-plugin-{0}-distribution.jar').format(Config.oxVersion)),
(os.path.join(Config.distJansFolder, 'jans-config-api.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api-server/{0}/jans-config-api-server-{0}.war').format(Config.ox_version)),
(os.path.join(Config.distJansFolder, 'scim-plugin.jar'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api/plugins/scim-plugin/{0}/scim-plugin-{0}-distribution.jar').format(Config.ox_version)),
(os.path.join(Config.distJansFolder, 'facter'), 'https://raw.githubusercontent.com/GluuFederation/gluu-snap/master/facter/facter'),
(os.path.join(Config.install_dir, 'jans_setup/data/jans-config-api-swagger.yaml'), 'https://raw.githubusercontent.com/JanssenProject/jans/main/jans-config-api/docs/jans-config-api-swagger.yaml'),
(os.path.join(Config.distJansFolder, 'user-mgt-plugin.jar'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api/plugins/user-mgt-plugin/{0}/user-mgt-plugin-{0}-distribution.jar').format(Config.oxVersion)),
(os.path.join(Config.distJansFolder, 'user-mgt-plugin.jar'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-config-api/plugins/user-mgt-plugin/{0}/user-mgt-plugin-{0}-distribution.jar').format(Config.ox_version)),
]

def install(self):
Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/eleven.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self):
self.register_progess()

self.source_files = [
(os.path.join(Config.distJansFolder, 'jans-eleven.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-eleven-server/{0}/jans-eleven-server-{0}.war').format(Config.oxVersion))
(os.path.join(Config.distJansFolder, 'jans-eleven.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-eleven-server/{0}/jans-eleven-server-{0}.war').format(Config.ox_version))
]

self.output_folder = os.path.join(Config.outputFolder, 'jans-eleven')
Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self):
self.register_progess()

self.source_files = [
(os.path.join(Config.distJansFolder, 'jans-fido2.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-fido2-server/{0}/jans-fido2-server-{0}.war').format(Config.oxVersion))
(os.path.join(Config.distJansFolder, 'jans-fido2.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-fido2-server/{0}/jans-fido2-server-{0}.war').format(Config.ox_version))
]

self.fido2ConfigFolder = os.path.join(Config.configFolder, 'fido2')
Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/jans.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def initialize(self):

#Download jans-auth-client-jar-with-dependencies
if not os.path.exists(Config.non_setup_properties['oxauth_client_jar_fn']):
oxauth_client_jar_url = os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-auth-client/{0}/jans-auth-client-{0}-jar-with-dependencies.jar').format(Config.oxVersion)
oxauth_client_jar_url = os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-auth-client/{0}/jans-auth-client-{0}-jar-with-dependencies.jar').format(Config.ox_version)
self.logIt("Downloading {}".format(os.path.basename(oxauth_client_jar_url)))
base.download(oxauth_client_jar_url, Config.non_setup_properties['oxauth_client_jar_fn'])

Expand Down
4 changes: 2 additions & 2 deletions jans-linux-setup/jans_setup/setup_app/installers/jans_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def __init__(self):
self.register_progess()

self.source_files = [
(os.path.join(Config.distJansFolder, 'jans-auth.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-auth-server/{}/jans-auth-server-{}.war').format(Config.oxVersion, Config.oxVersion)),
(os.path.join(Config.distJansFolder, 'jans-auth-rp.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-auth-rp/{}/jans-auth-rp-{}.war').format(Config.oxVersion, Config.oxVersion)),
(os.path.join(Config.distJansFolder, 'jans-auth.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-auth-server/{0}/jans-auth-server-{0}.war').format(Config.ox_version)),
(os.path.join(Config.distJansFolder, 'jans-auth-rp.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-auth-rp/{0}/jans-auth-rp-{0}.war').format(Config.ox_version)),
]

self.templates_folder = os.path.join(Config.templateFolder, self.service_name)
Expand Down
4 changes: 2 additions & 2 deletions jans-linux-setup/jans_setup/setup_app/installers/jre.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def install(self):

self.fix_java_security()

def download_files(self, force=False):
def download_files(self, force=False, downloads=[]):
jre_arch_list = glob.glob(os.path.join(Config.distAppFolder, 'amazon-corretto-*.tar.gz'))

if not jre_arch_list:
Expand All @@ -74,7 +74,7 @@ def download_files(self, force=False):
jdk_fn = os.path.basename(self.open_jdk_archive_link)

self.jreArchive = os.path.join(Config.distAppFolder, jdk_fn)
if not os.path.exists(self.jreArchive) or force:
if not os.path.exists(self.jreArchive) or force and not (downloads and not src_name in downloads):
self.logIt("Downloading " + jdk_fn, pbar=self.service_name)
base.download(self.open_jdk_archive_link, self.jreArchive)
else:
Expand Down
4 changes: 2 additions & 2 deletions jans-linux-setup/jans_setup/setup_app/installers/oxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def installed(self):
return os.path.exists(self.oxd_server_yml_fn)

def download_files(self, force=False):
oxd_url = os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/oxd-server/{0}/oxd-server-{0}-distribution.zip').format(Config.oxVersion)
oxd_url = os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/oxd-server/{0}/oxd-server-{0}-distribution.zip').format(Config.ox_version)

self.logIt("Downloading {} and preparing package".format(os.path.basename(oxd_url)))

Expand All @@ -160,7 +160,7 @@ def download_files(self, force=False):

if not base.snap:
service_file = 'oxd-server.init.d' if base.deb_sysd_clone else 'oxd-server.service'
service_url = 'https://raw.githubusercontent.com/GluuFederation/community-edition-package/master/package/systemd/oxd-server.service'.format(Config.oxVersion, service_file)
service_url = 'https://raw.githubusercontent.com/GluuFederation/community-edition-package/master/package/systemd/oxd-server.service'.format(Config.ox_version, service_file)
self.download_file(service_url, os.path.join(oxd_tmp_dir, service_file))

oxd_server_sh_url = 'https://raw.githubusercontent.com/GluuFederation/oxd/master/debian/oxd-server'
Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/scim.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self):
self.register_progess()

self.source_files = [
(os.path.join(Config.distJansFolder, 'jans-scim.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-scim-server/{0}/jans-scim-server-{0}.war').format(Config.oxVersion)),
(os.path.join(Config.distJansFolder, 'jans-scim.war'), os.path.join(Config.app_info['JANS_MAVEN'], 'maven/io/jans/jans-scim-server/{0}/jans-scim-server-{0}.war').format(Config.ox_version)),
(os.path.join(Config.install_dir, 'jans_setup/data/jans-scim-openapi.yaml'), 'https://raw.githubusercontent.com/JanssenProject/jans/main/jans-scim/server/src/main/resources/jans-scim-openapi.yaml'),
]

Expand Down

0 comments on commit b01da85

Please sign in to comment.