Skip to content

Commit b60b552

Browse files
committed
add version information
Signed-off-by: Chris Snow <[email protected]>
1 parent 518a921 commit b60b552

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

bin/cli.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -812,13 +812,10 @@ def dashboard_token(
812812

813813
@intercept_exception
814814
def k8smanifest(self):
815-
"""Retrieve the k8smanifest.
816-
"""
815+
"""Retrieve the k8smanifest."""
817816
response = get_client().k8s_cluster.k8smanifest()
818817
print(
819-
yaml.dump(
820-
yaml.load(json.dumps(response), Loader=yaml.FullLoader,)
821-
)
818+
yaml.dump(yaml.load(json.dumps(response), Loader=yaml.FullLoader,))
822819
)
823820

824821
def get_installed_addons(self, id):
@@ -1524,7 +1521,7 @@ def _get_metadata(self):
15241521
for module_name in self.cli.__dict__.keys():
15251522

15261523
# we manually define autocomplete for these methods
1527-
if module_name in ["autocomplete", "configure_cli"]:
1524+
if module_name in ["autocomplete", "configure_cli", "version"]:
15281525
continue
15291526

15301527
module = getattr(self.cli, module_name)
@@ -1666,7 +1663,7 @@ def bash(self,):
16661663
COMPREPLY=( $(compgen -W "bash" -- $cur) )
16671664
;;
16681665
*"hpecp"*)
1669-
COMPREPLY=( $(compgen -W "autocomplete configure-cli {{module_names}}" -- $cur) )
1666+
COMPREPLY=( $(compgen -W "autocomplete configure-cli version {{module_names}}" -- $cur) )
16701667
;;
16711668
esac
16721669
return 0
@@ -1685,6 +1682,11 @@ def bash(self,):
16851682
)
16861683

16871684

1685+
def version():
1686+
"""Display version information."""
1687+
print(ContainerPlatformClient.version())
1688+
1689+
16881690
class CLI(object):
16891691
"""Command Line Interface for the HPE Container Platform."""
16901692

@@ -1706,6 +1708,7 @@ def __init__(self,):
17061708
self.httpclient = HttpClientProxy()
17071709
self.user = UserProxy()
17081710
self.role = RoleProxy()
1711+
self.version = version
17091712

17101713

17111714
if __name__ == "__main__":

hpecp/client.py

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
from requests.structures import CaseInsensitiveDict
5353
from hpecp.exceptions import APIForbiddenException
5454
import re
55+
import pkg_resources
5556

5657
try:
5758
basestring
@@ -103,6 +104,11 @@ class ContainerPlatformClient(object):
103104
ContainerPlatformClient instance
104105
"""
105106

107+
@classmethod
108+
def version(cls):
109+
"""Retrieve the hpecp version information."""
110+
return pkg_resources.require("hpecp")[0].version
111+
106112
@classmethod
107113
def create_from_config_file(
108114
cls, config_file="~/.hpecp.conf", profile=None

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
packages=["hpecp"],
4747
scripts=["bin/hpecp"],
4848
keywords="",
49+
version_format='{tag}.dev{commitcount}+{gitsha}',
50+
setup_requires=['setuptools-git-version'],
4951
install_requires=requirements,
5052
test_suite="nose.collector",
5153
tests_require=["coverage", "mock", "nose", "requests"],

0 commit comments

Comments
 (0)