diff --git a/cmd/vclusterctl/cmd/platform/reset.go b/cmd/vclusterctl/cmd/platform/reset.go index a2ac77172..e1d1d8268 100644 --- a/cmd/vclusterctl/cmd/platform/reset.go +++ b/cmd/vclusterctl/cmd/platform/reset.go @@ -97,6 +97,22 @@ func (cmd *PasswordCmd) Run() error { return err } + // check if cluster has platform installed + apiResourceList, err := managementClient.Discovery().ServerResourcesForGroupVersion(storagev1.GroupVersion.String()) + if err != nil { + return fmt.Errorf("looks like the api group storage.loft.sh couldn't be found (%w). Please make sure you select the kube context the platform was installed in for this command to work", err) + } + found := false + for _, apiResource := range apiResourceList.APIResources { + if apiResource.Kind == "User" { + found = true + break + } + } + if !found { + return fmt.Errorf("resource User in api group storage.loft.sh couldn't be found. Please make sure you select the kube context the platform was installed in for this command to work") + } + // get user cmd.Log.Infof("Resetting password of user %s", cmd.User) user, err := managementClient.Loft().StorageV1().Users().Get(context.Background(), cmd.User, metav1.GetOptions{}) @@ -111,7 +127,7 @@ func (cmd *PasswordCmd) Run() error { if cmd.Namespace == "" { namespace, err := clihelper.VClusterPlatformInstallationNamespace(context.Background()) if err != nil { - return fmt.Errorf("failed to find platform namespace") + return fmt.Errorf("failed to find platform namespace: %w", err) } cmd.Namespace = namespace