Skip to content

Commit cf2148e

Browse files
committed
Fix some tests that were failing
1 parent 27b8053 commit cf2148e

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

pkg/bundle/dereference.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ type DereferenceOptions struct {
6161

6262
// relativeFilePathPattern only accepts relative file path prefixes "./" and "../"
6363
var relativeFilePathPattern = regexp.MustCompile(`^(\.\/|\.\.\/)`)
64-
var massdriverDefinitionPattern = regexp.MustCompile(`^[a-zA-Z0-9]`)
64+
var massdriverDefinitionPattern = regexp.MustCompile(`^[a-zA-Z0-9-]+\/[a-zA-Z0-9-]+$`)
6565
var httpPattern = regexp.MustCompile(`^(http|https)://`)
66+
var fragmentPattern = regexp.MustCompile(`^#`)
6667

6768
func DereferenceSchema(anyVal any, opts DereferenceOptions) (any, error) {
6869
val := getValue(anyVal)
@@ -89,7 +90,7 @@ func DereferenceSchema(anyVal any, opts DereferenceOptions) (any, error) {
8990

9091
var err error
9192
if relativeFilePathPattern.MatchString(schemaRefValue) { //nolint:gocritic
92-
// this is a local file ref
93+
// this is a relative file ref
9394
// build up the path from where the dir current schema was read
9495
hydratedSchema, err = dereferenceFilePathRef(hydratedSchema, schema, schemaRefValue, opts)
9596
} else if httpPattern.MatchString(schemaRefValue) {
@@ -98,6 +99,9 @@ func DereferenceSchema(anyVal any, opts DereferenceOptions) (any, error) {
9899
} else if massdriverDefinitionPattern.MatchString(schemaRefValue) {
99100
// this must be a published schema, so fetch from massdriver
100101
hydratedSchema, err = dereferenceMassdriverRef(hydratedSchema, schema, schemaRefValue, opts)
102+
} else if fragmentPattern.MatchString(schemaRefValue) {
103+
// this is a fragment, so we do nothing and leave the schema as is
104+
// since fragments are not dereferenced in the same way as full schemas
101105
} else {
102106
return nil, fmt.Errorf("unable to resolve ref: %s", schemaRefValue)
103107
}

pkg/bundle/testdata/lint/module/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ variable "bar" {
77
}
88

99
variable "md_metadata" {
10-
type = any
10+
type = object({})
1111
}

0 commit comments

Comments
 (0)