From 0f2f9e9c41f10997aad8c370fe1193d7a744a3ac Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 13 Oct 2025 15:28:12 +0200 Subject: [PATCH] cli/command/image/build: deprecate ResolveAndValidateContextPath util This utility was used internally and will be removed in the next release. Use `DetectContextType` to detect the context-type, and use `GetContextFromLocalDir`, `GetContextFromLocalDir`, `GetContextFromGitURL`, or `GetContextFromURL` instead. Signed-off-by: Sebastiaan van Stijn --- cli/command/image/build/context.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cli/command/image/build/context.go b/cli/command/image/build/context.go index 85502fad29..04c35dc1d9 100644 --- a/cli/command/image/build/context.go +++ b/cli/command/image/build/context.go @@ -234,7 +234,7 @@ func GetContextFromGitURL(gitURL, dockerfileName string) (string, string, error) return "", "", fmt.Errorf("unable to 'git clone' to temporary context directory: %w", err) } - absContextDir, err = ResolveAndValidateContextPath(absContextDir) + absContextDir, err = resolveAndValidateContextPath(absContextDir) if err != nil { return "", "", err } @@ -287,7 +287,7 @@ func getWithStatusError(url string) (resp *http.Response, err error) { // the relative path of the dockerfile in that context directory, and a non-nil // error on success. func GetContextFromLocalDir(localDir, dockerfileName string) (string, string, error) { - localDir, err := ResolveAndValidateContextPath(localDir) + localDir, err := resolveAndValidateContextPath(localDir) if err != nil { return "", "", err } @@ -307,7 +307,18 @@ func GetContextFromLocalDir(localDir, dockerfileName string) (string, string, er // ResolveAndValidateContextPath uses the given context directory for a `docker build` // and returns the absolute path to the context directory. +// +// Deprecated: this utility was used internally and will be removed in the next +// release. Use [DetectContextType] to detect the context-type, and use +// [GetContextFromLocalDir], [GetContextFromLocalDir], [GetContextFromGitURL], +// or [GetContextFromURL] instead. func ResolveAndValidateContextPath(givenContextDir string) (string, error) { + return resolveAndValidateContextPath(givenContextDir) +} + +// resolveAndValidateContextPath uses the given context directory for a `docker build` +// and returns the absolute path to the context directory. +func resolveAndValidateContextPath(givenContextDir string) (string, error) { absContextDir, err := filepath.Abs(givenContextDir) if err != nil { return "", fmt.Errorf("unable to get absolute context directory of given context directory %q: %w", givenContextDir, err)