-
Notifications
You must be signed in to change notification settings - Fork 46
Public API Separation #476
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // Copyright 2025 Tetrate | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Package api allows Go projects to use func-e as a library, decoupled from how | ||
| // the func-e binary reads environment variables or CLI args. | ||
| package api | ||
|
|
||
| import ( | ||
| "context" | ||
| "io" | ||
|
|
||
| "github.com/tetratelabs/func-e/internal/opts" | ||
| ) | ||
|
|
||
| // HomeDir is an absolute path which most importantly contains "versions" | ||
| // installed from EnvoyVersionsURL. Defaults to "${HOME}/.func-e" | ||
| func HomeDir(homeDir string) RunOption { | ||
| return func(o *opts.RunOpts) { | ||
| o.HomeDir = homeDir | ||
| } | ||
| } | ||
|
|
||
| // EnvoyVersionsURL is the path to the envoy-versions.json. | ||
| // Defaults to "https://archive.tetratelabs.io/envoy/envoy-versions.json" | ||
| func EnvoyVersionsURL(envoyVersionsURL string) RunOption { | ||
| return func(o *opts.RunOpts) { | ||
| o.EnvoyVersionsURL = envoyVersionsURL | ||
| } | ||
| } | ||
|
|
||
| // EnvoyVersion overrides the version of Envoy to run. Defaults to the | ||
| // contents of "$HomeDir/versions/version". | ||
| // | ||
| // When that file is missing, it is generated from ".latestVersion" from the | ||
| // EnvoyVersionsURL. Its value can be in full version major.minor.patch format, | ||
| // e.g. 1.18.1 or without patch component, major.minor, e.g. 1.18. | ||
| func EnvoyVersion(envoyVersion string) RunOption { | ||
| return func(o *opts.RunOpts) { | ||
| o.EnvoyVersion = envoyVersion | ||
| } | ||
| } | ||
|
|
||
| // Out is where status messages are written. Defaults to os.Stdout | ||
| func Out(out io.Writer) RunOption { | ||
| return func(o *opts.RunOpts) { | ||
| o.Out = out | ||
| } | ||
| } | ||
|
|
||
| // EnvoyOut sets the writer for Envoy stdout | ||
| func EnvoyOut(w io.Writer) RunOption { | ||
| return func(o *opts.RunOpts) { | ||
| o.EnvoyOut = w | ||
| } | ||
| } | ||
|
|
||
| // EnvoyErr sets the writer for Envoy stderr | ||
| func EnvoyErr(w io.Writer) RunOption { | ||
| return func(o *opts.RunOpts) { | ||
| o.EnvoyErr = w | ||
| } | ||
| } | ||
|
|
||
| // RunOption is a configuration for RunFunc. | ||
| // | ||
| // Note: None of these default to values read from OS environment variables. | ||
| // If you wish to introduce such behavior, populate them in calling code. | ||
| type RunOption func(*opts.RunOpts) | ||
|
|
||
| // RunFunc downloads Envoy and runs it as a process with the arguments | ||
| // passed to it. Use api.RunOption for configuration options. | ||
| // | ||
| // On success, this blocks and returns nil when either `ctx` is done, or the | ||
| // process exits with status zero. | ||
| // | ||
| // The default implementation of RunFunc is func_e.Run. | ||
| type RunFunc func(ctx context.Context, args []string, options ...RunOption) error | ||
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Copyright func-e contributors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Package opts holds shared configuration types for func-e options. | ||
| // This is internal and not intended for direct use by external packages. | ||
| package opts | ||
|
|
||
| import "io" | ||
|
|
||
| // RunOpts holds the configuration set by RunOptions. | ||
| type RunOpts struct { | ||
| HomeDir string | ||
| EnvoyVersion string | ||
| EnvoyVersionsURL string | ||
| Out io.Writer | ||
| EnvoyOut io.Writer | ||
| EnvoyErr io.Writer | ||
| EnvoyPath string // Internal: path to the Envoy binary (for tests). | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this uses an internal type which is a trick to effectively hide the exported fields