Skip to content

feat: Support ${file:./path} expansion in spec#418

Merged
kodiakhq[bot] merged 5 commits intomainfrom
feat/support_file_variable
Nov 21, 2022
Merged

feat: Support ${file:./path} expansion in spec#418
kodiakhq[bot] merged 5 commits intomainfrom
feat/support_file_variable

Conversation

@yevgenypats
Copy link
Copy Markdown
Contributor

@yevgenypats yevgenypats commented Nov 20, 2022

Per user request. we had a similar version of that in v0 but now it is generic and available to all specs and not only to a specific destination.

@github-actions github-actions bot added the feat label Nov 20, 2022
@github-actions github-actions bot added feat and removed feat labels Nov 20, 2022
otherstuff: 2
`)
_, err = expandFileConfig(badCfg)
expectedErr := `open ./testdata/creds2.txt: no such file or directory`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not use errors.Is and ErrNotExist etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah that would be better. I basically copy pasted from other tests :)

Destinations map[string]*Destination
}

var fileRegex = regexp.MustCompile(`\$\{file:(.+)\}`)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
var fileRegex = regexp.MustCompile(`\$\{file:(.+)\}`)
var fileRegex = regexp.MustCompile(`\$\{file:([^}]+)\}`)

I think this regex should also handle the case where multiple variable replacements occur in the same line.

E.g. before:

${file:abc}-${file:def}

would greedily match abc}-${file:def as the filename, instead of two separate matches abc and def. (Assuming this is a valid)

We may want to add a test case where two variable replacements happen as well (maybe one file replacement and one normal replacement)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Member

@disq disq Nov 21, 2022

Choose a reason for hiding this comment

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

Why not do

var fileRegex = regexp.MustCompile(`\$\{file:(.+?)\}`)

for an ungreedy match?

@kodiakhq kodiakhq bot merged commit 58d7c44 into main Nov 21, 2022
@kodiakhq kodiakhq bot deleted the feat/support_file_variable branch November 21, 2022 14:18
kodiakhq bot pushed a commit that referenced this pull request Nov 21, 2022
🤖 I have created a release *beep* *boop*
---


## [1.6.0](v1.5.3...v1.6.0) (2022-11-21)


### Features

* Add option to plugin doc command to output tables as JSON ([#347](#347)) ([c1b4240](c1b4240))
* Support ${file:./path} expansion in spec ([#418](#418)) ([58d7c44](58d7c44))


### Bug Fixes

* Fix Destination testing suite ([#417](#417)) ([4771efa](4771efa))
* Increase GRPC message size limit to 50MiB ([#419](#419)) ([a54c6ea](a54c6ea))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
kodiakhq bot pushed a commit to cloudquery/cloudquery that referenced this pull request Nov 21, 2022
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.

3 participants