Skip to content
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

Add template provider #8504

Closed
wants to merge 1 commit into from

Conversation

djaglowski
Copy link
Member

@djaglowski djaglowski commented Sep 22, 2023

Resolves #8372

This PR defines a new template provider. It acts very similarly to the file provider but expects a "template" file as defined in #8372. It is not yet useful without an associated converter which will be needed to expand the template.

Subset of #8344

@codecov
Copy link

codecov bot commented Sep 22, 2023

Codecov Report

Patch coverage is 100.00% of modified lines.

Files Changed Coverage
confmap/provider/templateprovider/provider.go 100.00%

📢 Thoughts on this report? Let us know!.

@djaglowski djaglowski marked this pull request as ready for review September 22, 2023 13:45
@djaglowski djaglowski requested a review from a team as a code owner September 22, 2023 13:45

// New returns a new confmap.Provider that reads the template from a file.
//
// This Provider supports "file" scheme, and can be called with a "uri" that follows:
Copy link
Contributor

@evan-bradley evan-bradley Sep 22, 2023

Choose a reason for hiding this comment

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

Is there any way to take advantage of the other providers to handle obtaining the templates? Since templates feel more like another type of config than a config "source" (file, http, s3, etc.), it would be unfortunate if templates could either only be obtained from select sources or that getting them from additional sources would require updates to the provider.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for taking a look at this @evan-bradley. I worked out an implementation based only on a converter. (See #8507)

I actually like this a lot better.

  • It has the advantage you mentioned, of allowing any provider to provide templates.
  • It removes the awkward coupling between a provider and converter.
  • It allows templates to appear directly in a config file (though I think typically they would not be used this way.) Still, it is nice to be able to reason about them in a more natural way.

@djaglowski
Copy link
Member Author

Closing in favor of #8507

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.

Template provider
2 participants