From ee0dc8209867ca344a70003924bfb6be12fd29ce Mon Sep 17 00:00:00 2001 From: Haytham AbuelFutuh Date: Wed, 18 Dec 2019 13:43:32 -0800 Subject: [PATCH] Add revision key to exported log fields (#52) --- contextutils/context.go | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/contextutils/context.go b/contextutils/context.go index fd0b5fa..af6e2e0 100644 --- a/contextutils/context.go +++ b/contextutils/context.go @@ -10,19 +10,20 @@ import ( type Key string const ( - AppNameKey Key = "app_name" - NamespaceKey Key = "ns" - TaskTypeKey Key = "tasktype" - ProjectKey Key = "project" - DomainKey Key = "domain" - WorkflowIDKey Key = "wf" - NodeIDKey Key = "node" - TaskIDKey Key = "task" - ExecIDKey Key = "exec_id" - JobIDKey Key = "job_id" - PhaseKey Key = "phase" - RoutineLabelKey Key = "routine" - LaunchPlanIDKey Key = "lp" + AppNameKey Key = "app_name" + NamespaceKey Key = "ns" + TaskTypeKey Key = "tasktype" + ProjectKey Key = "project" + DomainKey Key = "domain" + WorkflowIDKey Key = "wf" + NodeIDKey Key = "node" + TaskIDKey Key = "task" + ExecIDKey Key = "exec_id" + JobIDKey Key = "job_id" + PhaseKey Key = "phase" + RoutineLabelKey Key = "routine" + LaunchPlanIDKey Key = "lp" + ResourceVersionKey Key = "res_ver" ) func (k Key) String() string { @@ -40,6 +41,12 @@ var logKeys = []Key{ PhaseKey, RoutineLabelKey, LaunchPlanIDKey, + ResourceVersionKey, +} + +// Gets a new context with the resource version set. +func WithResourceVersion(ctx context.Context, resourceVersion string) context.Context { + return context.WithValue(ctx, ResourceVersionKey, resourceVersion) } // Gets a new context with namespace set.