Skip to content

Commit 0f2f9e9

Browse files
committed
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 <github@gone.nl>
1 parent 6e1ff0b commit 0f2f9e9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

cli/command/image/build/context.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func GetContextFromGitURL(gitURL, dockerfileName string) (string, string, error)
234234
return "", "", fmt.Errorf("unable to 'git clone' to temporary context directory: %w", err)
235235
}
236236

237-
absContextDir, err = ResolveAndValidateContextPath(absContextDir)
237+
absContextDir, err = resolveAndValidateContextPath(absContextDir)
238238
if err != nil {
239239
return "", "", err
240240
}
@@ -287,7 +287,7 @@ func getWithStatusError(url string) (resp *http.Response, err error) {
287287
// the relative path of the dockerfile in that context directory, and a non-nil
288288
// error on success.
289289
func GetContextFromLocalDir(localDir, dockerfileName string) (string, string, error) {
290-
localDir, err := ResolveAndValidateContextPath(localDir)
290+
localDir, err := resolveAndValidateContextPath(localDir)
291291
if err != nil {
292292
return "", "", err
293293
}
@@ -307,7 +307,18 @@ func GetContextFromLocalDir(localDir, dockerfileName string) (string, string, er
307307

308308
// ResolveAndValidateContextPath uses the given context directory for a `docker build`
309309
// and returns the absolute path to the context directory.
310+
//
311+
// Deprecated: this utility was used internally and will be removed in the next
312+
// release. Use [DetectContextType] to detect the context-type, and use
313+
// [GetContextFromLocalDir], [GetContextFromLocalDir], [GetContextFromGitURL],
314+
// or [GetContextFromURL] instead.
310315
func ResolveAndValidateContextPath(givenContextDir string) (string, error) {
316+
return resolveAndValidateContextPath(givenContextDir)
317+
}
318+
319+
// resolveAndValidateContextPath uses the given context directory for a `docker build`
320+
// and returns the absolute path to the context directory.
321+
func resolveAndValidateContextPath(givenContextDir string) (string, error) {
311322
absContextDir, err := filepath.Abs(givenContextDir)
312323
if err != nil {
313324
return "", fmt.Errorf("unable to get absolute context directory of given context directory %q: %w", givenContextDir, err)

0 commit comments

Comments
 (0)