Skip to content

Commit

Permalink
log an error and exit if agentless mode is set but there's no API key
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyredondo committed Jun 13, 2024
1 parent 6d19e62 commit 5862d18
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ddtrace/tracer/civisibility_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"gopkg.in/DataDog/dd-trace-go.v1/internal"
"gopkg.in/DataDog/dd-trace-go.v1/internal/civisibility/constants"
"gopkg.in/DataDog/dd-trace-go.v1/internal/log"
"gopkg.in/DataDog/dd-trace-go.v1/internal/version"
)

Expand Down Expand Up @@ -73,7 +74,13 @@ func newCiVisibilityTransport(config *config) *civisibilityTransport {
testCycleURL := ""
if agentlessEnabled {
// Agentless mode is enabled.
defaultHeaders["dd-api-key"] = os.Getenv(constants.APIKeyEnvironmentVariable)
APIKeyValue := os.Getenv(constants.APIKeyEnvironmentVariable)
if APIKeyValue == "" {
log.Error("An API key is required for agentless mode. Use the DD_API_KEY env variable to set it")
os.Exit(1)
}

defaultHeaders["dd-api-key"] = APIKeyValue

// Check for a custom agentless URL.
agentlessURL := ""
Expand Down

0 comments on commit 5862d18

Please sign in to comment.