Skip to content

fix(HCL): read file from fs instead of os #135

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

Merged
merged 1 commit into from
Oct 15, 2022
Merged

fix(HCL): read file from fs instead of os #135

merged 1 commit into from
Oct 15, 2022

Conversation

tmzane
Copy link
Contributor

@tmzane tmzane commented Oct 14, 2022

I believe it was a bug because ioutil reads directly from os, not fs.FS

@tmzane
Copy link
Contributor Author

tmzane commented Oct 14, 2022

Btw, love the idea of the main module being dependency-free + optional plugins!

I wonder if you've considered registering file parsers the way the database/sql package does it? Something like this in main.go:

import _ github.com/cristalhq/aconfig/aconfighcl

I get that importing with side effects is a bit awkward, but this way we could minimize the submodules API (no need to export anything). And the Go community is pretty familiar with this method because of the database plugins.

Just thinking out loud 😅

Copy link
Member

@cristaloleg cristaloleg left a comment

Choose a reason for hiding this comment

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

Nice! I'm not a big user of HCL so I'm not shocked that this bug was here.

@cristaloleg cristaloleg merged commit 80e06ca into cristalhq:main Oct 15, 2022
@cristaloleg
Copy link
Member

Regarding sql.Register(...) API it's not explicit, that's was my main (pain) point.

Defining file format per:

	FileDecoders: map[string]aconfig.FileDecoder{
		// from `aconfigyaml` submodule
		// see submodules in repo for more formats
		".yaml": aconfigyaml.New(),
	},

..makes everything easier to understand + gives a free configuration feature to support different file extensions (even somewhat weird like .cfg, .config)

@tmzane tmzane deleted the fix-hcl-read-from-fs branch October 15, 2022 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants