Giter Site home page Giter Site logo

Comments (3)

jnovack avatar jnovack commented on June 12, 2024

I came here searching for this feature as well. Unfortunately, the magic 8-ball says "Outlook not so good". This project has a small number of PRs in the queue and no updates in quite a number of years. :(

from flag.

jnovack avatar jnovack commented on June 12, 2024

Ruminating on this issue, this is definitely something that breaks current implementations.

Docker Secrets standards use _FILE appended to the name of the variable to indicate the variable (as you explained above), but there's nothing stopping me from having an actual PASSWORD_FILE variable, that really points to a file, that's not a docker secret.

In that case, I don't want to read a docker secret PASSWORD, I want the variable PASSWORD_FILE. So that means using secrets will have to be a build-time decision.

Perhaps setting flag.Secrets = true could trigger the alternate usage. At that point, I'm hesitant to put it upstream. It really is coding for a specific environment, that's not a majority, which I do not believe belongs in this package.

Believe me, I want it automagically too, that's why I came here. However, it might just be simpler to use github.com/ijustfool/docker-secrets and code for whichever variables you want to use _FILE for.

It's ugly, but functional.

package main

import (
	"fmt"

	secrets "github.com/ijustfool/docker-secrets"
	"github.com/namsral/flag"
)

var word = flag.String("word", "bird", "string")
var wordFile = flag.String("word_file", "", "string")

func main() {
	flag.Parse()

	if *wordFile != "" {
		dockerSecrets, _ := secrets.NewDockerSecrets(".")
		secret, _ := dockerSecrets.Get("word")
		*word = secret
	}
	fmt.Printf("word: %s\n", *word)
}
❯ cat food
pizza
❯ go run main.go -word banana
word: banana
❯ go run main.go -word_file food
word: pizza

from flag.

jgimenez avatar jgimenez commented on June 12, 2024

Probably this is less important now because k8s can pass secrets as both environment variables or files.

from flag.

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.