Skip to content

Commit

Permalink
Merge pull request #112 from duplocloud/better-versions
Browse files Browse the repository at this point in the history
More Component Versions
  • Loading branch information
kferrone authored Oct 28, 2024
2 parents 156373e + e639d46 commit 1643e16
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update Kubeconfig now has a name argument to name the user/context anything you want.
- Update Kubeconfig will always name the server after the Plan. This will share the same server for all tenants in the same plan. Also prevents unnecessary duplicates of the same server.
- Update kubeconfig will update the sections instead of skipping if they already exist. For example you can switch to interactive mode.
- Added more duplo component versions to the version command.

### Fixed

Expand Down
35 changes: 21 additions & 14 deletions src/duplo_resource/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,28 @@ class DuploVersion():
"""
def __init__(self, duplo: DuploClient):
self.duplo = duplo
self.paths = {
"ui": "build-metadata.json",
"frontdoor": "frontdoor/build-metadata.json",
"backend": "v3/version",
"auth": "v3/auth/version",
"katkit": "v3/katkit/version",
"billing": "v3/billing/version",
"security": "v3/security/version"
}

def __call__(self) -> dict:
ui = None
server = None
v = {
"cli": version('duplocloud-client')
v = {}
# first get cli version then server versions
v["cli"] = {
"tag": version('duplocloud-client')
}
try:
ui = self.duplo.get("build-metadata.json")
server = self.duplo.get("v3/version")
except Exception:
pass
finally:
if ui:
v["ui"] = ui.json()
if server:
v["server"] = server.json()
for (name, path) in self.paths.items():
try:
res = self.duplo.get(path).json()
except Exception as e:
self.duplo.logger.error(f"Failed to get version for {path}: {e}")
res = {"error": str(e)}
finally:
v[name] = res
return v

0 comments on commit 1643e16

Please sign in to comment.