Skip to content

Commit

Permalink
Remove Jira
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanvogel committed Feb 11, 2025
1 parent 4c2330b commit e46dd3f
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 561 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pyProfileMgr is a Python module containing the Profile Manager component.

It also provides CLI access for reading, writing, listing and updating profiles.
A profile can store Jira, Polarion and Superset server, credentials and certificate data.
A profile contains server URL, type, credentials (token or username/password) and certificate data.

[![License](https://img.shields.io/badge/license-bsd-3.svg)](https://choosealicense.com/licenses/bsd-3-clause/) [![Repo Status](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip) [![CI](https://github.com/NewTec-GmbH/pyProfileMgr/actions/workflows/test.yml/badge.svg)](https://github.com/NewTec-GmbH/pyProfileMgr/actions/workflows/test.yml)

Expand Down Expand Up @@ -43,7 +43,6 @@ Used 3rd party libraries which are not part of the standard Python package:
| Library | Description | License |
| ------- | ----------- | ------- |
| [colorama](https://github.com/tartley/colorama) | ANSI color support | BSD-3 License |
| [jira](https://pypi.org/project/jira/) | Python library for interacting with JIRA via REST APIs | BSD License (BSD-2-Clause) |
| [toml](https://github.com/uiri/toml) | Parsing [TOML](https://en.wikipedia.org/wiki/TOML) | MIT |

Sections below, for Github only
Expand Down
10 changes: 0 additions & 10 deletions doc/uml/architecture.puml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,17 @@

package "pyProfileMgr" {
component "Main entry point" as main
component "Jira server" as jira_server
component "Profile command" <<command>> as cmd_profile
component "Profile manager" as profile_mgr
}

package "Python Jira" {
component "jira.client.JIRA" as jira
}

package "Python" as python {
component "Argparse" as argparse
component "Requests" as requests
}

main o--> cmd_profile
cmd_profile o--> jira_server
cmd_profile o--> profile_mgr
jira_server o--> profile_mgr
main *--> argparse

jira_server *--> jira
jira *--> requests

@enduml
20 changes: 2 additions & 18 deletions doc/uml/deployment.puml
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
@startuml DeploymentDiagram

node "Jira" <<virtual-machine>> as jira_vm {
node "Jira server" as jira_server {
database "Jira database" as jira_db
}

interface "Jira REST API" as jira_rest_api
jira_server -- jira_rest_api
}

node "Continuous integration server" <<virtual-machine>> {
package "Scripts" {
component "pyJiraCli" as jira_cli #White
component "pyMetricCli" as metric_cli #White
component "pyProfileMgr" as profile_mgr
ProfileMgr - [profile_mgr]
}

folder Filesystem {
file "Profile data" as profile_data_files
}

ProfileMgr - [profile_mgr]
jira_cli -> ProfileMgr
jira_cli --> ProfileMgr
metric_cli --> ProfileMgr
profile_mgr -- profile_data_files
}

jira_rest_api )-- profile_mgr

' Notes
note top of jira_server
Issue tracking system
end note

@enduml
7 changes: 1 addition & 6 deletions doc/uml/overview.puml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@startuml pyJiraCli_components
@startuml pyProfileMgr_components

top to bottom direction
skinparam Linetype ortho
Expand All @@ -14,10 +14,6 @@ package "pyProfileMgr" {

profile_data .down...> cmd_profile : <<flow>>

database "Jira server" as jira_server {
file "Jira issue" as jira_issue
}

folder Filesystem {
file "Profile data" as profile_data_files
}
Expand All @@ -26,7 +22,6 @@ main .down.> cmd_profile : <<flow>>

cmd_profile ...down.> profile_mgr : <<flow>>\n<<store/delete/update/list>>
profile_mgr ...down.> profile_data_files : <<flow>>\n<<store/delete/update/list>>
profile_mgr .down...> jira_server : <<authenticate>>

'Notes
note top of profile_data
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ classifiers = [

dependencies = [
"colorama>=0.4.6",
"jira>=3.8.0",
"toml>=0.10.2"
]

Expand Down
3 changes: 1 addition & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
colorama==0.4.6
jira==3.8.0
m2r>=0.3.1
myst-parser>=4.0.0
pyinstaller>=6.11.1
Expand All @@ -11,4 +10,4 @@ sphinx-rtd-theme>=3.0.1
Sphinx>=8.1.3
sphinxcontrib-plantuml>=0.30
toml>=0.10.2
tomlkit>=0.13.2
tomlkit>=0.13.2
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
colorama==0.4.6
jira==3.8.0
toml==0.10.2
toml==0.10.2
85 changes: 23 additions & 62 deletions src/pyProfileMgr/cmd_profile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Command for the profile function.
This module can add, remove or configure server profiles.
This module can add, remove, modify and list server profiles.
The profiles contain server url, login data, the server certificate
and configuration data for a specific jira server instance.
and configuration data for a specific server instance.
"""
# BSD 3-Clause License
#
Expand Down Expand Up @@ -38,9 +38,7 @@
import argparse

from pyProfileMgr.profile_mgr import ProfileMgr
from pyProfileMgr.profile_mgr import ProfileType

from pyProfileMgr.jira_server import Server
from pyProfileMgr.printer import Printer, PrintType
from pyProfileMgr.ret import Ret

Expand Down Expand Up @@ -102,7 +100,7 @@ def register(subparser) -> argparse.ArgumentParser:
type=str,
metavar='<server URL>',
required=True,
help="The Jira server URL to connect to."
help="The server URL to connect to."
)

sub_parser_add.add_argument(
Expand All @@ -111,7 +109,7 @@ def register(subparser) -> argparse.ArgumentParser:
type=str,
metavar='<token>',
required=False,
help="The token to authenticate at the Jira server."
help="The token to authenticate at the server."
)

sub_parser_add.add_argument(
Expand All @@ -120,7 +118,7 @@ def register(subparser) -> argparse.ArgumentParser:
type=str,
metavar='<user>',
required=False,
help="The user to authenticate at the Jira server."
help="The user to authenticate at the server."
)

sub_parser_add.add_argument(
Expand All @@ -129,7 +127,7 @@ def register(subparser) -> argparse.ArgumentParser:
type=str,
metavar='<password>',
required=False,
help="The password to authenticate at the Jira server."
help="The password to authenticate at the server."
)

sub_parser_add.add_argument(
Expand Down Expand Up @@ -182,7 +180,7 @@ def register(subparser) -> argparse.ArgumentParser:
type=str,
required=False,
metavar='<server URL>',
help="The Jira server URL to connect to."
help="The server URL to connect to."
)

sub_parser_update.add_argument(
Expand All @@ -191,7 +189,7 @@ def register(subparser) -> argparse.ArgumentParser:
type=str,
required=False,
metavar='<token>',
help="The token to authenticate with the Jira server."
help="The token to authenticate with the server."
)

sub_parser_update.add_argument(
Expand All @@ -200,7 +198,7 @@ def register(subparser) -> argparse.ArgumentParser:
type=str,
required=False,
metavar='<user>',
help="The user to authenticate at the Jira server."
help="The user to authenticate at the server."
)

sub_parser_update.add_argument(
Expand All @@ -209,7 +207,7 @@ def register(subparser) -> argparse.ArgumentParser:
type=str,
required=False,
metavar='<password>',
help="The password to authenticate at the Jira server."
help="The password to authenticate at the server."
)

sub_parser_update.add_argument(
Expand Down Expand Up @@ -253,20 +251,12 @@ def _profile_add(args) -> Ret.CODE:
ret_status = Ret.CODE.RET_OK

# Do not overwrite existing profiles.
profile_handler = ProfileMgr()
profile_list = profile_handler.get_profiles()
profile_mgr = ProfileMgr()
profile_list = profile_mgr.get_profiles()
if args.profile_name in profile_list:
ret_status = Ret.CODE.RET_ERROR_PROFILE_ALREADY_EXISTS
return Ret.CODE.RET_ERROR_PROFILE_ALREADY_EXISTS

# Buffer profile name so the check can be run without it.
if ret_status is Ret.CODE.RET_OK:
temp_profile_name = args.profile_name
args.profile_name = None
ret_status = _check_jira_profile(args)
args.profile_name = temp_profile_name

if ret_status is Ret.CODE.RET_OK:
ret_status = _add_profile(args)
ret_status = _add_profile(args)

return ret_status

Expand Down Expand Up @@ -307,36 +297,7 @@ def _profile_update(args) -> Ret.CODE:
Returns:
Ret.CODE: The return status of the module.
"""
ret_status = _check_jira_profile(args)

if ret_status is Ret.CODE.RET_OK:
ret_status = _update_profile(args)

return ret_status


def _check_jira_profile(args) -> Ret.CODE:
""" Checks whether the profile information is valid by login to Jira.
Returns:
Ret.CODE: If successful it will return Ret.CODE.RET_OK otherwise a error.
"""

# Check if the profile type is 'jira' if given (note that not all
# commands require a profile type, so it is not mandatory).
if (args.profile_type is not None) and (args.profile_type != ProfileType.JIRA):
return Ret.CODE.RET_ERROR_INVALID_PROFILE_TYPE

server = Server()
# Login to the server (prefer token over user/password).
if args.token is not None:
ret_status = server.login(
args.profile_name, args.server, args.token, None, None)
else:
ret_status = server.login(
args.profile_name, args.server, None, args.user, args.password)

return ret_status
return _update_profile(args)


def _add_profile(args) -> Ret.CODE:
Expand All @@ -349,7 +310,7 @@ def _add_profile(args) -> Ret.CODE:
Ret.CODE: Status code indicating the success or failure of the profile addition.
"""
ret_status = Ret.CODE.RET_OK
_profile = ProfileMgr()
profile_mgr = ProfileMgr()

if args.server is None:
ret_status = Ret.CODE.RET_ERROR_NO_SERVER_URL
Expand All @@ -367,7 +328,7 @@ def _add_profile(args) -> Ret.CODE:
user = args.user
password = args.password
certificate = args.cert
ret_status = _profile.add(
ret_status = profile_mgr.add(
profile_name, profile_type, server, token, user, password, certificate)

return ret_status
Expand All @@ -380,11 +341,10 @@ def _list_profiles() -> Ret.CODE:
Ret.CODE: Status code indicating the success or failure of the command.
"""
ret_status = Ret.CODE.RET_OK
profile_handler = ProfileMgr()
profile_list = profile_handler.get_profiles()

print("Profiles:")
profile_list = ProfileMgr().get_profiles()

print("Profiles:")
for profile_name in profile_list:
print(f"\t{profile_name}")

Expand Down Expand Up @@ -418,11 +378,12 @@ def _update_profile(args) -> Ret.CODE:
"""
# Update cert
if args.cert is not None:
_profile = ProfileMgr()
ret_status = _profile.load(args.profile_name)
profile_mgr = ProfileMgr()
ret_status = profile_mgr.load(args.profile_name)

if ret_status == Ret.CODE.RET_OK:
# profile exists
ret_status = _profile.add_certificate(args.profile_name, args.cert)
ret_status = profile_mgr.add_certificate(
args.profile_name, args.cert)

return ret_status
Loading

0 comments on commit e46dd3f

Please sign in to comment.