Comments (11)
KANIKO_DIR
is just looked up on-demand at present so we do not need to do anything for that env.
Other kaniko options are checked in its root command (for example, KANIKO_REGISTRY_MIRROR
, KANIKO_REGISTRY_MAP
and KANIKO_NO_PUSH
). We currently have to check for the presence of this environment variable and pass it in as required.
I don't think we would want to prefix these with ENVBUILDER_
in either case.
from envbuilder.
Thinking more about how we want to make it, I wonder if we could make
coder/serpent
to acceptEnv
as an[]string
instead. IMO, it makes the code more clear and direct about the usage. Another option would be toEnv
asany
and acceptstring
orstring[]
.const prefix = "CODER_" return serpent.OptionSet{ { Flag: "setup-script", Env: []string{"SETUP_SCRIPT", prefix + "SETUP_SCRIPT"}, Value: serpent.StringOf(&o.SetupScript), Description: "...", }, }Wdyt?
What if we add new fields for deprecated environment DeprecatedEnv
and DeprecationMessage
? And allow coder/serpent
to still accept them but show a deprecation message.
It can make it easier to remove the deprecated values later.
from envbuilder.
I think you both are on to something, but I'd like to know what @ammario thinks about introducing breaking changes to the API.
Another way to achieve this could be by introducing aliases, perhaps something like this:
type OptionAlias struct {
Flag string `json:"flag,omitempty"`
FlagShorthand string `json:"flag_shorthand,omitempty"`
Env string `json:"env,omitempty"`
Deprecated string `json:"deprecated,omitempty"`
}
// Option is a configuration option for a CLI application.
type Option struct {
Aliases []OptionAlias `json:"aliases,omitempty"`
// ...
}
// Usage:
{
// ...
Env: "CODER_FOOBAR",
Alias: []serpent.OptionAlias{
{Env: "FOOBAR", Deprecated: "Use CODER_FOOBAR instead."},
},
},
We could then create a convenience function in envbuilder that adds the deprecated alias to an option.
There already exists UseInstead
that can serve a similar purpose, but I feel that solves the issue in reverse.
Ultimately, I love the idea of being able to define multiple envs for a flag. We have such use-cases in coder/coder
too, for instance.
from envbuilder.
Totally makes sense. If we were to support #127, how do you imagine that would work? ENVBUILDER_KANIKO_*
?
from envbuilder.
Envbuilder currently imports kaniko as a library, so I don't believe this would impact how kaniko reads its environment variables.
from envbuilder.
So if we wanted to support all (or most) kaniko options, we would rewrite instead of passing through?
from envbuilder.
After discussing this on Coconut standup we want to:
- Add env variables prefix option to the coder/serpent and after support this on the envbuilder
- The "prefix env variable" should still support the env variables without the prefix so it does not break old consumers
from envbuilder.
The "prefix env variable" should still support the env variables without the prefix so it does not break old consumers
We should only support old format until we do 1.0 that too with a deprecation message that it is going to be removed in release 1.0.
from envbuilder.
Thinking more about how we want to make it, I wonder if we could make coder/serpent
to accept Env
as an []string
instead. IMO, it makes the code more clear and direct about the usage. Another option would be to Env
as any
and accept string
or string[]
.
const prefix = "CODER_"
return serpent.OptionSet{
{
Flag: "setup-script",
Env: []string{"SETUP_SCRIPT", prefix + "SETUP_SCRIPT"},
Value: serpent.StringOf(&o.SetupScript),
Description: "...",
},
}
Wdyt?
from envbuilder.
@matifali I think this can be interesting. Let's see what other folks think about cc.: @mafredri @mtojek
from envbuilder.
Re prefixing all environment variables, there is ParseEnviron for this very reason.
In the meantime if envbuilder needs to support multiple environment variables, we can use UseInstead or even manipulate the Invocation.Environ before its ran.
We should take any conversation about changing the serpent API to that repo to keep this tracker clean. I created an issue here for aliases.
from envbuilder.
Related Issues (20)
- Dev Containers: Support volume mounts of devcontainer spec HOT 2
- Dev Containers: Script init and Entrypoint
- Error running devcontainer with container registry kubernetes secret volume mounted HOT 2
- Add support for feature order definition in devcontainer definitions
- usability: fix ownership of Docker volume mounts to /home HOT 1
- coder/kaniko: support multi-stage builds with DoCacheProbe HOT 1
- devcontainer: support multi-stage build with dangling build stage
- devcontainer: support docker-compose
- Implement devcontainer-lock.json
- Envbuilder create git repo folder with a trailing `.git`
- bug: lifecycle script `OnCreateCommand` is not executed.
- coder/kaniko: support caching ENV and ARG directives HOT 1
- Stop using deprecated codersdk.LogsSender function
- 401 error for requests to coder.example.com after "Update" option following template change HOT 3
- question: Ability to add features and/or modify feature parameters HOT 3
- feat: Add a way to select a specific branch before building the devcontainer HOT 2
- kubernetes: build with an initContainer or a Job HOT 2
- envbuilder - pass ssh key HOT 1
- envbuilder: fetch upstream changes from repo if local copy is not dirty HOT 5
- Add support for starting envbuilder from a built image
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from envbuilder.