GODRIVER-2906 Add container Env to Handshake.#1382
Conversation
API Change ReportNo changes found! |
55670ab to
484a1e6
Compare
| name := getFaasEnvName() | ||
| if name == "" { | ||
| container := getContainerEnvInfo() | ||
| if name == "" && container == nil { |
There was a problem hiding this comment.
This line implies that we wouldn't append the client environment if the name and the container are unavailable. However, both name and container were made optional as part of DRIVERS-2570: https://github.com/mongodb/specifications/pull/1454/files#diff-0ecfac0976ff0bfe5b91b5bd52bc5a79dd1125434505ff22331c7cadf1b2f25eR170
I think we should completely remove this block.
If tests are failing, such as the handshake integration tests, it's because there is an expectation that they should contain a name which is now incorrect.
There was a problem hiding this comment.
I'm afraid it's ambiguous. My understanding is that the entire client.env can be omitted because:
- The spec states the
envis optional. - Logically, we don't have to keep the
envif it has nothing.
However, I will ask for clarification because we don't have a lot of reference implementations now.
Spec says:
If no fields of
client.envwould be populated,client.envMUST be entirely omitted. ref
There was a problem hiding this comment.
Ah okay, so because the other fields in env depend on either name or container, if both are empty then implicitly the other fields will be empty. Could we add a comment to that effect?
| var idx int32 | ||
| idx, dst = bsoncore.AppendDocumentElementStart(dst, "env") | ||
|
|
||
| if name != "" { |
There was a problem hiding this comment.
Instead of nesting these conditions, suggest making them separate blocks for readability:
var idx int32
idx, dst = bsoncore.AppendDocumentElementStart(dst, "env")
if name != "" {
dst = bsoncore.AppendStringElement(dst, "name", name)
}
if !omitNonName {
switch name {
case envNameAWSLambda:
dst = addMem(envVarAWSLambdaFunctionMemorySize)
dst = addRegion(envVarAWSRegion)
case envNameGCPFunc:
dst = addMem(envVarFunctionMemoryMB)
dst = addRegion(envVarFunctionRegion)
dst = addTimeout(envVarFunctionTimeoutSec)
case envNameVercel:
dst = addRegion(envVarVercelRegion)
}
}(cherry picked from commit c3d390f)
GODRIVER-2906
Summary
client.env.namefield to optional.client.env.container.The values for
client.env.containerare sourced from the environment, see here.Background & Motivation
client.env.container.runtimeis untested since it requires "/.dockerenv", which exists in the root directory.