-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modifying vault utils, separating the client + introducing cli and co…
…nfig for server
- Loading branch information
Showing
5 changed files
with
61 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import argparse | ||
|
||
# Parse arguments from the cli | ||
def parse_arguments(): | ||
"""Parse arguments from cli | ||
Returns: | ||
ArgumentParser: the ArgumentParser produced | ||
""" | ||
parser = argparse.ArgumentParser(description="CLI Optinons") | ||
|
||
parser.add_argument( | ||
"--config", | ||
"-c", | ||
type=str, | ||
default="/tmp/hpcs-server.conf", | ||
help="Configuration file (INI Format) (default: /tmp/hpcs-server.conf)", | ||
) | ||
|
||
return parser.parse_args() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from configparser import ConfigParser, NoSectionError, NoOptionError | ||
|
||
def parse_configuration(path : str): | ||
config = ConfigParser() | ||
config.read(path) | ||
|
||
if not 'spire-server' in config: | ||
raise NoSectionError("spire-server section missing, aborting") | ||
|
||
if not 'vault' in config: | ||
raise NoSectionError("vault section missing, aborting") | ||
|
||
if not 'address' in config['spire-server'] or not 'port' in config['spire-server'] or not 'trust-domain' in config['spire-server']: | ||
raise NoOptionError("'spire-server' section is incomplete, aborting") | ||
|
||
if not 'url' in config['vault'] or not 'server-role' in config['vault']: | ||
raise NoOptionError("'vault' section is incomplete, aborting") | ||
|
||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters