Skip to content

Commit

Permalink
Remove shebang + main function from dynamic client (#252)
Browse files Browse the repository at this point in the history
* Remove shebang + main function from dynamic client

* remove unused imports
  • Loading branch information
fabianvf committed Jan 3, 2019
1 parent 2bfc077 commit d59353f
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions openshift/dynamic/client.py 100755 → 100644
@@ -1,7 +1,4 @@
#!/usr/bin/env python

import os
import sys
import copy
import json
import base64
Expand All @@ -13,8 +10,7 @@
import yaml
from pprint import pformat

from kubernetes import config, watch
from kubernetes.client.api_client import ApiClient
from kubernetes import watch
from kubernetes.client.rest import ApiException

from openshift.dynamic.exceptions import ResourceNotFoundError, ResourceNotUniqueError, api_exception, KubernetesValidateMissing
Expand Down Expand Up @@ -976,28 +972,3 @@ def __getitem__(self, name):

def __dir__(self):
return dir(type(self)) + list(self.attributes.__dict__.keys())


def main():
config.load_kube_config()
client = DynamicClient(ApiClient())
ret = []
for resource in client.resources:
key = '{}.{}'.format(resource.group_version, resource.kind)
item = {}
item[key] = {k: v for k, v in resource.__dict__.items() if k not in ('client', 'subresources', 'resource')}
if isinstance(resource, ResourceList):
item[key]["resource"] = '{}.{}'.format(resource.group_version, resource.kind)
else:
item[key]['subresources'] = {}
for name, value in resource.subresources.items():
item[key]['subresources'][name] = {k: v for k, v in value.__dict__.items() if k != 'parent'}
item[key]['urls'] = resource.urls
ret.append(item)

print(yaml.safe_dump(sorted(ret, key=lambda x: x.keys()[0].replace('List', '1')), default_flow_style=False))
return 0


if __name__ == '__main__':
sys.exit(main())

0 comments on commit d59353f

Please sign in to comment.