From 9e3f3c663017c2a7108d11fb09bc9ae5aa7d86f8 Mon Sep 17 00:00:00 2001 From: Sam Plant Date: Fri, 29 Nov 2024 12:31:49 +0000 Subject: [PATCH] fix: Added function docs Signed-off-by: Sam Plant --- pkg/tfc_trigger/project_config.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/tfc_trigger/project_config.go b/pkg/tfc_trigger/project_config.go index 4827d41..b26f5bf 100644 --- a/pkg/tfc_trigger/project_config.go +++ b/pkg/tfc_trigger/project_config.go @@ -24,6 +24,12 @@ type ProjectConfig struct { Workspaces []*TFCWorkspace `yaml:"workspaces"` } +// Finds the workspace with the deepest matching directory suffix. +// For example, given workspaces with config "terraform/dev/" and a dir of "dev/", +// and a filepath directory of "filesystem/terraform/dev/" - "dev" and "terraform/dev/" are both a suffix +// we would return the ws for "terraform/dev/"as it is the deepest match. +// Special case: if a workspace has config "/" and the input dir is ".", that workspace is returned. +// If no workspace matches, returns nil. func (cfg *ProjectConfig) workspaceForDir(dir string) *TFCWorkspace { var longestMatch *TFCWorkspace var longestMatchDepth int