From 69a8927a004858dd6d39e4383330f10207fc8115 Mon Sep 17 00:00:00 2001 From: ShocOne <62835948+ShocOne@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:45:27 +0100 Subject: [PATCH] Refactor helpers package for improved code organization and readability file that has been mvoed to heleprs package --- jamf/jamfprointegration/helpers.go | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 jamf/jamfprointegration/helpers.go diff --git a/jamf/jamfprointegration/helpers.go b/jamf/jamfprointegration/helpers.go deleted file mode 100644 index d86fbe2..0000000 --- a/jamf/jamfprointegration/helpers.go +++ /dev/null @@ -1,27 +0,0 @@ -package helpers - -import ( - "fmt" - "os" - "path/filepath" - "time" -) - -// TODO this duplicated across both integrations. Improve it another time. - -// ParseISO8601Date attempts to parse a string date in ISO 8601 format. -func ParseISO8601_Date(dateStr string) (time.Time, error) { - return time.Parse(time.RFC3339, dateStr) -} - -// SafeOpenFile opens a file safely after validating and resolving its path. -func SafeOpenFile(filePath string) (*os.File, error) { - cleanPath := filepath.Clean(filePath) - - absPath, err := filepath.EvalSymlinks(cleanPath) - if err != nil { - return nil, fmt.Errorf("unable to resolve the absolute path: %s, error: %w", filePath, err) - } - - return os.Open(absPath) -}