Skip to content

Commit 7ea37a7

Browse files
committed
Use sync root path in metadata computation
1 parent 7a6a7eb commit 7ea37a7

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

bundle/deploy/metadata/compute.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ func (m *compute) Apply(_ context.Context, b *bundle.Bundle) diag.Diagnostics {
3737
// Set job config paths in metadata
3838
jobsMetadata := make(map[string]*metadata.Job)
3939
for name, job := range b.Config.Resources.Jobs {
40-
// Compute config file path the job is defined in, relative to the bundle
41-
// root
40+
// Compute config file path the job is defined in, relative to the sync root.
41+
// You can join the file path (below) with this relative path to find the
42+
// workspace path containing the YAML file that defines the job.
4243
l := b.Config.GetLocation("resources.jobs." + name)
43-
relativePath, err := filepath.Rel(b.RootPath, l.File)
44+
relativePath, err := filepath.Rel(b.SyncRootPath, l.File)
4445
if err != nil {
4546
return diag.Errorf("failed to compute relative path for job %s: %v", name, err)
4647
}

bundle/deploy/metadata/compute_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616

1717
func TestComputeMetadataMutator(t *testing.T) {
1818
b := &bundle.Bundle{
19+
RootPath: "parent/my_bundle",
20+
SyncRootPath: "parent",
1921
Config: config.Root{
2022
Workspace: config.Workspace{
2123
RootPath: "/Users/[email protected]",
@@ -55,9 +57,9 @@ func TestComputeMetadataMutator(t *testing.T) {
5557
},
5658
}
5759

58-
bundletest.SetLocation(b, "resources.jobs.my-job-1", "a/b/c")
59-
bundletest.SetLocation(b, "resources.jobs.my-job-2", "d/e/f")
60-
bundletest.SetLocation(b, "resources.pipelines.my-pipeline", "abc")
60+
bundletest.SetLocation(b, "resources.jobs.my-job-1", "parent/my_bundle/a/b/c")
61+
bundletest.SetLocation(b, "resources.jobs.my-job-2", "parent/my_bundle/d/e/f")
62+
bundletest.SetLocation(b, "resources.pipelines.my-pipeline", "parent/my_bundle/abc")
6163

6264
expectedMetadata := metadata.Metadata{
6365
Version: metadata.Version,
@@ -79,11 +81,11 @@ func TestComputeMetadataMutator(t *testing.T) {
7981
Resources: metadata.Resources{
8082
Jobs: map[string]*metadata.Job{
8183
"my-job-1": {
82-
RelativePath: "a/b/c",
84+
RelativePath: "my_bundle/a/b/c",
8385
ID: "1111",
8486
},
8587
"my-job-2": {
86-
RelativePath: "d/e/f",
88+
RelativePath: "my_bundle/d/e/f",
8789
ID: "2222",
8890
},
8991
},

0 commit comments

Comments
 (0)