fix(delivery): accept root@% credential for CloudDM registration

PR #128 looks up the root credential with account_host = 'localhost',
which never matches under the single root@% account model. Widen the
lookup to account_host IN ('%', 'localhost'), consistent with the
compatibility strategy in deploymentCredentialVars.
This commit is contained in:
Hungerdream
2026-07-29 18:40:23 +08:00
parent b3eb10a81d
commit 07a661f7d1
+1 -1
View File
@@ -2046,7 +2046,7 @@ func (s *DeliveryService) RegisterCloudDM(ctx context.Context, taskID string) er
}
var credential model.DeploymentCredential
if err := s.db.WithContext(ctx).
Where("task_id = ? AND username = ? AND account_host = ? AND status IN ?", taskID, "root", "localhost", []string{"pending", "available"}).
Where("task_id = ? AND username = ? AND account_host IN ? AND status IN ?", taskID, "root", []string{"%", "localhost"}, []string{"pending", "available"}).
First(&credential).Error; err != nil {
return fmt.Errorf("CloudDM registration requires the MySQL root credential: %w", err)
}