Skip to content

Commit

Permalink
fix: jans cli build issues (update doc and fix requirements) (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Mar 2, 2022
1 parent f7327e9 commit 18d1507
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 35 deletions.
56 changes: 28 additions & 28 deletions jans-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,46 @@ wget https://github.com/JanssenProject/jans-cli/releases/latest/download/jans-cl
If you would like to build `jans-cli` manually, you can go through the following steps noted here:

## Prerequisites
1. git
1. wget
1. unzip
1. Python 3.6+.
1. Python `pip3` package.

### Downloading `jans-cli` files
### Building

1. Clone the repository:
1. Install dependencies

```sh
apt install -y wget unzip python3-pip python3-dev
pip3 install shiv
```
git clone https://github.com/JanssenProject/jans-cli/

2. Download the repository:

```sh
wget https://github.com/JanssenProject/jans/archive/refs/heads/main.zip
```

2. open directory
3. Unzip package, and change to directory

```sh
unzip main.zip
cd jans-main/jans-cli
```
cd jans-cli

4. Build

```sh
make zipapp
```

You can verify with the following command line if everything is done successfully.

```
python3 jans-cli.pyz -h
```


### Standard Python package

1. Create virtual environment and activate:
Expand All @@ -64,28 +86,6 @@ If you would like to build `jans-cli` manually, you can go through the following

This command will install executable called `jans-cli` available in virtual environment `PATH`.

### Python zipapp

1. Install [shiv](https://shiv.readthedocs.io/) using `pip3`:

```sh
pip3 install shiv
```

1. Install the package:

```sh
make zipapp
```

This command will generate executable called `jans-cli.pyz` under the same directory.


You can verify with the following command line if everything is done successfully.

```
python3 jans-cli.pyz -h
```

![](docs/img/build-jans-cli-pyz-manually.png)

Expand Down
15 changes: 8 additions & 7 deletions jans-cli/cli/config_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ def join(self):

################## end of arguments #################


def write_config():
with open(config_ini_fn, 'w') as w:
config.write(w)

if not (host and client_id and client_secret):
host = args.host
client_id = args.client_id
Expand All @@ -152,7 +157,7 @@ def join(self):
'scim_client_id': 'your jans scim client id',
'scim_client_secret': 'client secret for your jans scim client'}

self.write_config()
write_config()

print(
"Pelase fill {} or set environmental variables jans_host, jans_client_id ,and jans_client_secret and re-run".format(config_ini_fn)
Expand Down Expand Up @@ -289,10 +294,6 @@ def get_yaml(self):
json.dump(self.cfg_yml, w, indent=2)
return self.cfg_yml

def write_config(self):
with open(config_ini_fn, 'w') as w:
config.write(w)

def get_rest_client(self):
rest = swagger_client.rest.RESTClientObject(self.swagger_configuration)
if args.key_password:
Expand Down Expand Up @@ -490,7 +491,7 @@ def get_jwt_access_token(self):
self.access_token = result['access_token']
access_token_enc = encode_decode(self.access_token)
config['DEFAULT']['access_token_enc'] = access_token_enc
self.write_config()
write_config()


def get_access_token(self, scope):
Expand Down Expand Up @@ -637,7 +638,7 @@ def get_input(self, values=[], text='Selection', default=None, itype=None,
print("Logging out...")
if 'access_token_enc' in config['DEFAULT']:
config['DEFAULT'].pop('access_token_enc')
self.write_config()
write_config()
print("Quiting...")
sys.exit()
break
Expand Down
2 changes: 2 additions & 0 deletions jans-cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def find_version(*file_paths):
install_requires=[
"ruamel.yaml>=0.16.5",
"PyJWT==2.3.0",
"certifi",
"six",
"jca-swagger-client @ https://ox.gluu.org/icrby8xcvbcv/cli-swagger/jca_swagger_client.zip",
"scim_swagger_client @ https://ox.gluu.org/icrby8xcvbcv/cli-swagger/scim_swagger_client.zip",

Expand Down

0 comments on commit 18d1507

Please sign in to comment.