From c8f860a6735cae0b17d9ff8c94369c6c57cbcd3e Mon Sep 17 00:00:00 2001 From: Jacek Wysocki Date: Tue, 5 Sep 2023 13:06:56 +0200 Subject: [PATCH] feat: add orgid and env to agent context (#4320) --- pkg/agent/agent.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/agent/agent.go b/pkg/agent/agent.go index 0255d1f1621..049315f9b69 100644 --- a/pkg/agent/agent.go +++ b/pkg/agent/agent.go @@ -28,8 +28,14 @@ import ( const ( apiKeyMeta = "api-key" clusterIDMeta = "cluster-id" - cloudMigrate = "migrate" + cloudMigrateMeta = "migrate" + orgIdMeta = "environment-id" + envIdMeta = "organization-id" healthcheckCommand = "healthcheck" + + cloudMigrateEnvName = "TESTKUBE_CLOUD_MIGRATE" + cloudEnvIdEnvName = "TESTKUBE_CLOUD_ENV_ID" + cloudOrgIdEnvName = "TESTKUBE_CLOUD_ORG_ID" ) // buffer up to five messages per worker @@ -208,7 +214,9 @@ func (ag *Agent) runCommandLoop(ctx context.Context) error { ctx = AddAPIKeyMeta(ctx, ag.apiKey) ctx = metadata.AppendToOutgoingContext(ctx, clusterIDMeta, ag.clusterID) - ctx = metadata.AppendToOutgoingContext(ctx, cloudMigrate, os.Getenv("TESTKUBE_CLOUD_MIGRATE")) + ctx = metadata.AppendToOutgoingContext(ctx, cloudMigrateMeta, os.Getenv(cloudMigrateEnvName)) + ctx = metadata.AppendToOutgoingContext(ctx, envIdMeta, os.Getenv(cloudEnvIdEnvName)) + ctx = metadata.AppendToOutgoingContext(ctx, orgIdMeta, os.Getenv(cloudOrgIdEnvName)) ag.logger.Infow("initiating streaming connection with Cloud API") // creates a new Stream from the client side. ctx is used for the lifetime of the stream.