Integrate version hardcoding into CLI
The get_distribution load was very heavy, so follow the other parts and just hardcode the version in. Also update bump-version to work with this and with the new pyproject.toml configuration, and add a custom user-agent to the API requests leveraging this version.
This commit is contained in:
		@@ -22,7 +22,8 @@ sed -i "s,version = \"${current_version}\",version = \"${new_version}\"," node-d
 | 
			
		||||
sed -i "s,version = \"${current_version}\",version = \"${new_version}\"," health-daemon/pvchealthd/Daemon.py
 | 
			
		||||
sed -i "s,version = \"${current_version}\",version = \"${new_version}\"," worker-daemon/pvcworkerd/Daemon.py
 | 
			
		||||
sed -i "s,version = \"${current_version}\",version = \"${new_version}\"," api-daemon/pvcapid/Daemon.py
 | 
			
		||||
sed -i "s,version=\"${current_version}\",version=\"${new_version}\"," client-cli/setup.py
 | 
			
		||||
sed -i "s,version = \"${current_version}\",version = \"${new_version}\"," client-cli/pyproject.toml
 | 
			
		||||
sed -i "s,VERSION = \"${current_version}\",VERSION = \"${new_version}\"," client-cli/pvc/cli/cli.py
 | 
			
		||||
echo ${new_version} > .version
 | 
			
		||||
 | 
			
		||||
changelog_tmpdir=$( mktemp -d )
 | 
			
		||||
 
 | 
			
		||||
@@ -51,6 +51,8 @@ import click
 | 
			
		||||
###############################################################################
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
VERSION = "0.9.107"
 | 
			
		||||
 | 
			
		||||
CONTEXT_SETTINGS = dict(
 | 
			
		||||
    help_option_names=["-h", "--help"], max_content_width=MAX_CONTENT_WIDTH
 | 
			
		||||
)
 | 
			
		||||
@@ -97,10 +99,7 @@ def version(ctx, param, value):
 | 
			
		||||
    if not value or ctx.resilient_parsing:
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    from pkg_resources import get_distribution
 | 
			
		||||
 | 
			
		||||
    version = get_distribution("pvc").version
 | 
			
		||||
    echo(CLI_CONFIG, f"Parallel Virtual Cluster CLI client version {version}")
 | 
			
		||||
    echo(CLI_CONFIG, f"Parallel Virtual Cluster CLI client version {VERSION}")
 | 
			
		||||
    ctx.exit()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ from requests import get, post, put, patch, delete, Response
 | 
			
		||||
from requests.exceptions import ConnectionError
 | 
			
		||||
from time import time
 | 
			
		||||
from urllib3 import disable_warnings
 | 
			
		||||
from pvc.cli.cli import VERSION
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def format_bytes(size_bytes):
 | 
			
		||||
@@ -166,6 +167,9 @@ def call_api(
 | 
			
		||||
        config["api_scheme"], config["api_host"], config["api_prefix"], request_uri
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # Add custom User-Agent header
 | 
			
		||||
    headers["User-Agent"] = f"pvc-client-cli/{VERSION}"
 | 
			
		||||
 | 
			
		||||
    # Craft the authentication header if required
 | 
			
		||||
    if config["api_key"]:
 | 
			
		||||
        headers["X-Api-Key"] = config["api_key"]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user