Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Flank version info to requests #2073

Merged
merged 7 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion test_runner/src/main/kotlin/ftl/client/google/GcTesting.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import ftl.config.FtlConstants
import ftl.config.FtlConstants.JSON_FACTORY
import ftl.config.FtlConstants.applicationName
import ftl.config.FtlConstants.httpTransport
import ftl.util.readRevision
import ftl.util.readVersion

object GcTesting {
val get: Testing by lazy {
val builder = Testing.Builder(httpTransport, JSON_FACTORY, httpCredential)
.setApplicationName(applicationName)
.setApplicationName("$applicationName, version: ${readVersion()}, revision: ${readRevision()}")

if (FtlConstants.useMock) builder.rootUrl = FtlConstants.localhost

Expand Down
21 changes: 17 additions & 4 deletions test_runner/src/main/kotlin/ftl/client/google/GcToolResults.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import ftl.run.exception.FailureToken
import ftl.run.exception.FlankGeneralError
import ftl.run.exception.PermissionDenied
import ftl.run.exception.ProjectNotFound
import ftl.util.readRevision
import ftl.util.readVersion

object GcToolResults {

Expand All @@ -33,7 +35,7 @@ object GcToolResults {

if (FtlConstants.useMock) builder.rootUrl = FtlConstants.localhost

builder.setApplicationName(applicationName)
builder.setApplicationName("$applicationName, version: ${readVersion()}, revision: ${readRevision()}")
.build()
}

Expand Down Expand Up @@ -159,8 +161,19 @@ object GcToolResults {
} catch (ftlProjectError: FTLProjectError) {
// flank needs to rewrap the exception with additional info about project
when (ftlProjectError) {
is PermissionDenied -> throw FlankGeneralError(permissionDeniedErrorMessage(projectId, source, ftlProjectError.message))
is ProjectNotFound -> throw FlankGeneralError(projectNotFoundErrorMessage(projectId, ftlProjectError.message))
is PermissionDenied -> throw FlankGeneralError(
permissionDeniedErrorMessage(
projectId,
source,
ftlProjectError.message
)
)
is ProjectNotFound -> throw FlankGeneralError(
projectNotFoundErrorMessage(
projectId,
ftlProjectError.message
)
)
is FailureToken -> UserAuth.throwAuthenticationError()
}
}
Expand Down Expand Up @@ -221,7 +234,7 @@ object GcToolResults {
}

private val permissionDeniedErrorMessage = { projectId: String, projectIdSource: String?, message: String? ->
"""Flank encountered a 403 error when running on project $projectId${projectIdSource?.let {" (from $it)"} ?: ""}. Please verify this credential is authorized for the project and has the required permissions.
"""Flank encountered a 403 error when running on project $projectId${projectIdSource?.let { " (from $it)" } ?: ""}. Please verify this credential is authorized for the project and has the required permissions.
Consider authentication with a Service Account https://github.com/Flank/flank#authenticate-with-a-service-account
or with a Google account https://github.com/Flank/flank#authenticate-with-a-google-account

Expand Down