Fix UpdateOrCreateToken get secrets err handling optimization

Signed-off-by: lonelyCZ <chengzhe@zju.edu.cn>
This commit is contained in:
lonelyCZ 2023-02-15 21:26:38 +08:00
parent a9089325dc
commit 8b67d22786
1 changed files with 1 additions and 1 deletions

View File

@ -322,7 +322,7 @@ func UpdateOrCreateToken(client kubeclient.Interface, failIfExists bool, token *
if err != nil && !apierrors.IsNotFound(err) {
return err
}
if secret != nil && failIfExists {
if secret != nil && err == nil && failIfExists {
return fmt.Errorf("a token with id %q already exists", token.Token.ID)
}