Open oleiade opened 1 month ago
@oleiade I'm pondering the API for the tweaked token login, modifying what is already there, for backwards-compatibility:
POST k6-cloud-ingest-api /v1/validate-token
Request:
{
"token": str,
"stack-id": str # new
}
Response (always http 200):
{
"token-info": str,
"stack-id": str, # new
"is_valid": bool,
"message": "Token|StackId is valid|invalid" # updated
}
Error response (same as before, only on server errors):
{
"error": str,
"error_code": int
}
This is simple but doesn't contain any programmatic way to determine which of the token/stack-id is invalid and how. Do you want that? I could add something like
{
"token-info": str,
...
"message": str,
"details: {"token-info": str, "stack-id": str} # new
}
@fornfrey This endpoint doesn't start out following the public API spec, and to be backwards-compatible it's hard to remake it. Do you have any recommendations here?
Feature Description
In order to cater to upcoming changes to how we handle the login process in the cloud we would like to introduce a Stack ID option to the
k6 cloud login
command, that would be persisted to the k6 default configuration file.The Stack ID holds the identifier of a Grafana Cloud stack, and will eventually be relied upon by the cloud to determine which default project to use if not explicitly provided by the user. In the future, the stack id will most likely become mandatory whenever interacting with Grafana Cloud k6.
Suggested Solution (optional)
cloud login
command optionIntroduce a stack ID option and persist it after successful login in the k6 default configuration file, in the same fashion as what we do with the token.
The option is set through a command line option:
k6 cloud login token sometokenstring --stack-id 123
, and is persisted in thecollectors.cloud
object of the k6 configuration file.This stack ID will be sent to the backend API when starting a test run.
Error Handling
If neither a stack ID was set in the login process, nor a project ID was defined in the options, an error message will be displayed: “Either re-login with a stack ID, or set a project ID”.
Project ID Precedence:
If both a default project ID and a project ID are defined in the script, the one in the script must take precedence.
Already existing or connected issues / PRs (optional)
No response