Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: have data.list("/") read from root of library #661

Merged
merged 4 commits into from
May 3, 2022

Conversation

gcheadle-vmware
Copy link
Contributor

No description provided.

@gcheadle-vmware gcheadle-vmware changed the title Bug fix: have data.list("/") read from the root of library Bug fix: have data.list("/") read from root of library May 2, 2022
Copy link
Contributor

@pivotaljohn pivotaljohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for the thorough approach, here.

Comments are just for your consideration.

If/When you're happy, good to merge.

@@ -210,6 +210,94 @@ data: #@ data.read("/funcs/data")`)
assert.Equal(t, expectedYAMLTplData, string(file.Bytes()))
}

func TestDataListRelativeToRootInDataValuesAndSchema(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests give me a lot of confidence that our "absolute path" loading works in both schema and data values -flavored templates. 👍🏻 Thank you for investing in this.

As I look around at the test files in pkg/cmd/template ... their ranks are growing. cmd_test.go is almost a KLOC.

If you haven't already thought about this, I'm wondering if these tests would be more "at home" in one of these test files:

  • cmd_root_library_test.go
  • cmd_data_values_test.go

@@ -97,7 +98,7 @@ func (pp DataValuesSchemaPreProcessing) collectSchemaDocs(schemaFiles []*FileInL
}

func (pp DataValuesSchemaPreProcessing) extractSchemaDocs(schemaFile *FileInLibrary) ([]*yamlmeta.Document, error) {
libraryCtx := LibraryExecutionContext{Current: schemaFile.Library, Root: NewRootLibrary(nil)}
libraryCtx := LibraryExecutionContext{Current: schemaFile.Library, Root: pp.rootLibrary}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about how minimizing the differences between Data Values and Data Values Schema processing makes this sweetly obvious that making the exact same change in both flows is the right move? ⭐

@gcheadle-vmware gcheadle-vmware merged commit e251559 into develop May 3, 2022
@gcheadle-vmware gcheadle-vmware deleted the data-list-root branch May 3, 2022 23:21
@pivotaljohn pivotaljohn linked an issue May 11, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Values file data.list("/") should read from root library
4 participants