diff --git a/pkg/lint/rules/values_test.go b/pkg/lint/rules/values_test.go index faa29d48a..67c25fde6 100644 --- a/pkg/lint/rules/values_test.go +++ b/pkg/lint/rules/values_test.go @@ -46,11 +46,24 @@ const testSchema = ` "password": { "description": "Your password", "type": "string" + }, + "extraData": { + "$ref": "http://example.com/helm/definitions/extraData" } } } ` +const extraSchema = ` +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "helm values extra data schema", + "$id": "http://example.com/helm/definitions/extraData", + + "type": "string" +} +` + func TestValidateValuesYamlNotDirectory(t *testing.T) { _ = os.Mkdir(nonExistingValuesFilePath, os.ModePerm) defer os.Remove(nonExistingValuesFilePath) @@ -136,6 +149,17 @@ func TestValidateValuesFile(t *testing.T) { yaml: "username: admin\npassword:", overrides: map[string]interface{}{"username": "anotherUser", "password": "swordfish"}, }, + { + name: "include extra data", + yaml: "username: admin\npassword: swordfish\nextraData: extra", + overrides: map[string]interface{}{}, + }, + { + name: "extra data invalid", + yaml: "username: admin\npassword: swordfish\nextraData: 1234", + overrides: map[string]interface{}{}, + errorMessage: "Expected: string, given: integer", + }, } for _, tt := range tests { @@ -165,5 +189,13 @@ func createTestingSchema(t *testing.T, dir string) string { if err := os.WriteFile(schemafile, []byte(testSchema), 0700); err != nil { t.Fatalf("Failed to write schema to tmpdir: %s", err) } + extraSchemaDir := filepath.Join(dir, "schemas") + if err := os.MkdirAll(extraSchemaDir, 0700); err != nil { + t.Fatalf("Failed to create extra schema dir: %s", err) + } + extraSchemaFile := filepath.Join(extraSchemaDir, "extraData.schema.json") + if err := os.WriteFile(extraSchemaFile, []byte(extraSchema), 0700); err != nil { + t.Fatalf("Failed to write extra schema to tmpdir: %s", err) + } return schemafile }