Skip to content

Commit

Permalink
remove resolve_relative parse
Browse files Browse the repository at this point in the history
  • Loading branch information
kla committed Oct 21, 2024
1 parent cd47922 commit fe3d7bc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
7 changes: 0 additions & 7 deletions src/yamler/yamler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default class YamlER {
this.content = this.readFile(this.filePath)
this.parseImports()
this.parseExtends()
this.parseResolveRelative()
this.attributes = yaml.load(this.content)
this.attributes = deepRemoveKeys(this.attributes, [ new RegExp(`^${anchorNamePrefix}`) ])

Expand Down Expand Up @@ -144,10 +143,4 @@ export default class YamlER {
const imp = this.imports[importName] || exit(1, { message: `${icons.error} Couldn't find import for '${importName}' referenced in '${this.filePath}'` })
return dig(imp.yaml.attributes, name.split('.')[1]) ? imp : null
}

// Need to handle resolve_relative here rather than in Expressions because we know
// the actual paths here when importing
private parseResolveRelative() {
this.content = this.content.replace(/\$\{\{ resolve_relative (.+?) \}\}/g, (_match, p1) => resolve(this.baseDir, p1))
}
}
8 changes: 1 addition & 7 deletions tests/unit/yamler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe('YamlER', () => {
beforeEach(() => yaml = loadFile(composeYaml, expressionCallback))

it('loads and processes a YAML file with imports', () => {
console.log(dump(yaml))
expect(yaml.stax.app).toBe('some_service')
expect(Object.keys(yaml)).toEqual(['stax', 'volumes', 'services'])
})
Expand All @@ -31,12 +30,7 @@ describe('YamlER', () => {
})

it('handles nested imports', () => {
expect(yaml.services.web.build.context).toBe(resolve(fixturesDir, 'build'))
})

it('parses resolve_relative', () => {
expect(yaml.services.web.build.context).toBe(resolve(fixturesDir, 'build'))
expect(yaml.services.web.build.dockerfile).toBe(resolve(fixturesDir, 'build/Dockerfile'))
expect(yaml.services.web.build.context).toBe('<resolve_relative ../build>')
})

it('strips _stax_import_ anchors', () => {
Expand Down

0 comments on commit fe3d7bc

Please sign in to comment.