Skip to content

Commit

Permalink
Fix issue with size trend retrieval using empty credentials. (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyKoltsov1997 authored Jun 8, 2023
1 parent fbce91b commit bf6a864
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DockerRegistryAccessor(private val uri: String, credentials: DockerhubCred
// -- parse JSON fields that don't have an assigned serializer into a String, e.g.: Number
isLenient = true
}
this.token = if (credentials != null) this.getPersonalAccessToken(credentials) else ""
this.token = if (credentials != null && credentials.isUsable()) this.getPersonalAccessToken(credentials) else ""
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@ class DockerhubCredentials {
this.username = username?.trim() ?: ""
this.token = token?.trim() ?: ""
}

/**
* @return true if credentials are usable for DockerHub auth (both are non-empty)
*/
fun isUsable(): Boolean {
return !(this.username.isNullOrEmpty() || this.token.isNullOrEmpty())
}
}

0 comments on commit bf6a864

Please sign in to comment.