Skip to content

Commit 2961d80

Browse files
authored
Merge pull request #783 from sophotechlabs/fix/helm-type-assertions
mcp: Use safe type assertions for Helm history entries
2 parents d1f5881 + 4ebc043 commit 2961d80

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

cmd/mcp/k8s/helm.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,15 @@ func (k *Client) GetHelmInventory(ctx context.Context, apiVersion string, object
7676
}
7777

7878
// get the latest release from the history
79+
entry, ok := history[0].(map[string]any)
80+
if !ok {
81+
return nil, nil
82+
}
7983
latest := &HelmHistory{}
80-
latest.Name = history[0].(map[string]any)["name"].(string)
81-
latest.ChartName = history[0].(map[string]any)["chartName"].(string)
82-
latest.Version = history[0].(map[string]any)["version"].(int64)
83-
latest.Namespace = history[0].(map[string]any)["namespace"].(string)
84+
latest.Name, _ = entry["name"].(string)
85+
latest.ChartName, _ = entry["chartName"].(string)
86+
latest.Version, _ = entry["version"].(int64)
87+
latest.Namespace, _ = entry["namespace"].(string)
8488

8589
storageKey := ctrlclient.ObjectKey{
8690
Namespace: storageNamespace,

0 commit comments

Comments
 (0)