-
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.
- Loading branch information
1 parent
67756d8
commit 72dcdaf
Showing
7 changed files
with
5,384 additions
and
7 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,11 @@ | ||
rm -rf src | ||
rm -rf swagger-codegen | ||
git clone https://github.com/swagger-api/swagger-codegen | ||
cp swagger/public.swagger.json swagger-codegen | ||
cd swagger-codegen | ||
./run-in-docker.sh mvn package | ||
./run-in-docker.sh generate -i public.swagger.json \ | ||
-l python -o /gen/out -DpackageName=src.cudo_compute | ||
cd .. | ||
cp -r swagger-codegen/out/* . | ||
|
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,59 @@ | ||
import yaml | ||
import os | ||
|
||
home = os.path.expanduser("~") | ||
|
||
|
||
def load_config(path, context_name): | ||
key_config = None | ||
context_config = None | ||
error = None | ||
|
||
with open(path, 'r') as file: | ||
config_data = yaml.safe_load(file) | ||
|
||
if config_data['configVersion'] != "v0": | ||
error = Exception("Only config version v0 is supported") | ||
return key_config, context_config, error | ||
|
||
if not context_name: | ||
if 'current-context' in config_data: | ||
context_name = config_data['current-context'] | ||
else: | ||
return key_config, context_config, Exception("No current context selected") | ||
|
||
if 'contexts' in config_data: | ||
for context_data in config_data['contexts']: | ||
if context_data['name'] == context_name: | ||
context_config = context_data | ||
break | ||
|
||
if not context_config: | ||
error = Exception("Context not found") | ||
return key_config, context_config, error | ||
|
||
if 'keys' in config_data: | ||
for key_data in config_data['keys']: | ||
if key_data['name'] == context_config['key']: | ||
key_config = key_data | ||
|
||
if not key_config: | ||
error = Exception("Key not found") | ||
|
||
return key_config, context_config, error | ||
|
||
|
||
def get_api_key(): | ||
key_config, context_config, error = load_config(home + '/.config/cudo/cudo.yml', "") | ||
if not error: | ||
return key_config['key'], None | ||
else: | ||
return None, error | ||
|
||
|
||
def get_project(): | ||
key_config, context_config, error = load_config(home + '/.config/cudo/cudo.yml', "") | ||
if not error: | ||
return context_config['project'], None | ||
else: | ||
return None, error |
Empty file.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.