-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat(datasource/custom): add toml support #28594
base: main
Are you sure you want to change the base?
Conversation
@@ -316,6 +316,16 @@ export class Http<Opts extends HttpOptions = HttpOptions> { | |||
}); | |||
} | |||
|
|||
async getToml(url: string, options?: Opts): Promise<HttpResponse> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a separate test in lib/util/http/index.spec.ts
It should also parse the toml and support optional schema validation. please do it like the getJson
.
It should be a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, I understand now how the JSON side works. Just to make sure I understand, you want two PRs.
- Implementing
getToml
correctly in lib/util/http/index.spec.ts + tests - lib/modules/datasource/custom/index.spec.ts where we consume
getToml
and also refactor the test suite into smaller ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the split can be done last after this pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some more digging and had some more downtime to look into this.
I may be missing something, but I can't do it precisely like getJson
since the internals of lib.util.http
delegate to got
for parsing the body.
The best I can do is to use a more basic type like text
in the InternalHttpOptions.responseType
, and then once I have something back from await this.request<ResT>(url, opts)
I can parse the TOML and then optionally apply the schema.
Still working on the util.http.index.spec
but it feels like I am finally making progress with my understanding of this area.
It appears some of the other JSON support floating around is for interfacing with other systems / clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, do the parsing in Http class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should split this file because it's becoming too big. Should of cause be done in a separate PR.
Changes
Adds support for custom toml data sources
Context
Closes #25635
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via:
Happy to hook it up to a real repo but I wasn't sure if I should make one or if there's an existing test fixture.
Closes: #25635