Add support for building from a subdirectory#245
Add support for building from a subdirectory#245google-prow-robot merged 4 commits intoknative:masterfrom
Conversation
| for i, step := range append(setupContainers, build.Spec.Steps...) { | ||
| step.Env = append(implicitEnvVars, step.Env...) | ||
| // TODO(mattmoor): Check that volumeMounts match volumes. | ||
| step.VolumeMounts = append(step.VolumeMounts, mounts...) |
There was a problem hiding this comment.
I moved these so that the Name and WorkingDir changes happen after the copies.
| IdentityFile %s/.ssh/id_foo | ||
| `, os.Getenv("HOME")) | ||
| IdentityFile %s | ||
| `, filepath.Join(os.Getenv("HOME"), ".ssh", "id_foo")) |
There was a problem hiding this comment.
I can pull creds_test.go and ssh.go into a separate PR if you want. They were small, so I added them for now.
|
/test pull-knative-build-go-coverage |
3 similar comments
|
/test pull-knative-build-go-coverage |
|
/test pull-knative-build-go-coverage |
|
/test pull-knative-build-go-coverage |
| Custom *corev1.Container `json:"custom,omitempty"` | ||
|
|
||
| // SubDir specifies a subdirectory of the fetched source which should be | ||
| // built. |
There was a problem hiding this comment.
Mention here that this makes parent directories inaccessible.
There was a problem hiding this comment.
Done. I also mentioned the possible optimization that files outside the subPath may not be fetched.
|
|
||
| // SubDir specifies a subdirectory of the fetched source which should be | ||
| // built. | ||
| SubDir string `json:"subDir,omitempty"` |
There was a problem hiding this comment.
:bikeshed: WDYT about Dir or SubPath?
There was a problem hiding this comment.
Chose SubPath for consistency with k8s volumeMount.
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| apiVersion: build.knative.dev/v1alpha1 | ||
| kind: BuildTemplate |
There was a problem hiding this comment.
You don't really need a template to demonstrate the capability, I'd just specify a build with source.subDir directly.
This would also let each test be explicit about what they're doing:
subdir-exists.yamlspecifies a subdir that exists, and its steps runcat <some file that's only in that subdir>subdir-notexists.yamlspecifies a subdir that doesn't exist and expects failuresubdir-nofile.yamlspecifies a subdir that exists but a file that doesn't exist in that subdir, and so expects failure.
Also fixes test credential handling on Windows.
|
The following is the coverage report on pkg/.
|
|
/retest |
|
Needs /approve and /lgtm still. 😄 |
| GCS *GCSSourceSpec `json:"gcs,omitempty"` | ||
| Custom *corev1.Container `json:"custom,omitempty"` | ||
|
|
||
| // SubPath specifies a pathd within the fetched source which should be |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: evankanderson, ImJasonH The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* Add support for building from a subdirectory Also fixes test credential handling on Windows. * Add e2e test for subdir option * Rename `subDir` to `subPath`, address other @imjasonh feedback * Rename test files to `subpath`
* Add support for building from a subdirectory Also fixes test credential handling on Windows. * Add e2e test for subdir option * Rename `subDir` to `subPath`, address other @imjasonh feedback * Rename test files to `subpath`
The major change is to have all stages after the "source fetch" possibly pivot into a subdir of the
workspacevolume via thesubPathoption to VolumeMount. Tested by hand, but will add an e2e test.Also fixes test credential handling on Windows.
Fixes #91
Proposed Changes
subDiroption to any source type specifying that only a subdirectory of the source should be built.Release Note