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

Supporting Docker Secrets #202

Closed
amir20 opened this issue Oct 28, 2022 · 1 comment
Closed

Supporting Docker Secrets #202

amir20 opened this issue Oct 28, 2022 · 1 comment
Labels
v2-ideas Possible inclusion in V2

Comments

@amir20
Copy link

amir20 commented Oct 28, 2022

Hello again,

Would you be open to supporting #{parameter_name}_FILE for also reading configurations from a file? I ask because Docker Secrets writes configurations to a file.

Someone asked on Dozzle if I support this amir20/dozzle#1927

I could support it but maybe this library should also support it. So the logic would be

  1. Try the parameter from cli and look for --parameter-name
  2. Then try for PARAMETER_NAME in ENV
  3. Last if if PARAMETER_NAME_FILE is set, read that file.

What do you think?

@alexflint
Copy link
Owner

Yes it's worth considering for this library but just as an interim solution you might do something like this:

type DockerSecret struct {
  Value string
}

func (s *DockerSecret) UnmarshalText(b []byte) error {
  v, err := os.ReadFile(string(b))
  s.Value = string(v)
  return err
}

func main() {
  var args struct {
    Parameter *string `arg:"env:PARAMETER_NAME"`
    ParameterAlt *DockerSecret `arg:"env:PARAMETER_NAME_FILE"`
  }
  arg.MustParse(&args)
  if args.Parameter == nil && args.ParameterAlt != nil {
    args.Parameter = &args.parameterAlt.Value
  }
}

Closing for now but I'll tag this as a v2 feature for possible inclusion in #197.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2-ideas Possible inclusion in V2
Projects
None yet
Development

No branches or pull requests

2 participants