@@ -35,6 +35,7 @@ const (
35
35
36
36
type gitAuthError string
37
37
type gitNotFoundError string
38
+ type contextDirNotFoundError string
38
39
39
40
func (e gitAuthError ) Error () string {
40
41
return fmt .Sprintf ("failed to fetch requested repository %q with provided credentials" , string (e ))
@@ -44,6 +45,10 @@ func (e gitNotFoundError) Error() string {
44
45
return fmt .Sprintf ("requested repository %q not found" , string (e ))
45
46
}
46
47
48
+ func (e contextDirNotFoundError ) Error () string {
49
+ return fmt .Sprintf ("provided context directory does not exist: %s" , string (e ))
50
+ }
51
+
47
52
// fetchSource retrieves the inputs defined by the build source into the
48
53
// provided directory, or returns an error if retrieval is not possible.
49
54
func fetchSource (dockerClient DockerClient , dir string , build * api.Build , urlTimeout time.Duration , in io.Reader , gitClient GitClient ) (* git.SourceInfo , error ) {
@@ -92,6 +97,12 @@ func fetchSource(dockerClient DockerClient, dir string, build *api.Build, urlTim
92
97
}
93
98
}
94
99
100
+ if len (build .Spec .Source .ContextDir ) > 0 {
101
+ if _ , err := os .Stat (filepath .Join (dir , build .Spec .Source .ContextDir )); os .IsNotExist (err ) {
102
+ return sourceInfo , contextDirNotFoundError (build .Spec .Source .ContextDir )
103
+ }
104
+ }
105
+
95
106
// a Dockerfile has been specified, create or overwrite into the destination
96
107
if dockerfileSource := build .Spec .Source .Dockerfile ; dockerfileSource != nil {
97
108
baseDir := dir
0 commit comments