Giter VIP home page Giter VIP logo

Comments (11)

johnstcn avatar johnstcn commented on August 11, 2024 2

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.

matifali avatar matifali commented on August 11, 2024 1

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?

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.

mafredri avatar mafredri commented on August 11, 2024 1

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.

bpmct avatar bpmct commented on August 11, 2024

Totally makes sense. If we were to support #127, how do you imagine that would work? ENVBUILDER_KANIKO_*?

from envbuilder.

johnstcn avatar johnstcn commented on August 11, 2024

Envbuilder currently imports kaniko as a library, so I don't believe this would impact how kaniko reads its environment variables.

from envbuilder.

bpmct avatar bpmct commented on August 11, 2024

So if we wanted to support all (or most) kaniko options, we would rewrite instead of passing through?

from envbuilder.

BrunoQuaresma avatar BrunoQuaresma commented on August 11, 2024

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.

matifali avatar matifali commented on August 11, 2024

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.

BrunoQuaresma avatar BrunoQuaresma commented on August 11, 2024

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.

BrunoQuaresma avatar BrunoQuaresma commented on August 11, 2024

@matifali I think this can be interesting. Let's see what other folks think about cc.: @mafredri @mtojek

from envbuilder.

ammario avatar ammario commented on August 11, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.