Comments (3)
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.
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.
Probably this is less important now because k8s can pass secrets as both environment variables or files.
from flag.
Related Issues (20)
- not a drop-in replacement HOT 12
- `go test -v` stops working HOT 4
- using config file by default HOT 6
- Execution with -h should just print the usage instruction and exit HOT 2
- print error from config file parsing by default HOT 1
- Parse behaviour is wrong when flag contains "-" HOT 1
- lowercase environment variables HOT 1
- prefix for environment variables HOT 6
- Add camel case flag name example to readme
- type alias for Value, Getter etc.
- Is there a way to disable the ConfigFlagname of a FlagSet?
- Release new version
- Odd interaction with other libraries using flag behind the scenes HOT 3
- Support for fixed-size integer types
- Support for required flag and Default should be optional
- Out of Sync with latest go version - Newer fork available jnovack/flag HOT 2
- Config file parse failure "configuration variable provided but not defined" is not visible to application HOT 2
- Required environment variables is a regression HOT 6
- Running go test with any of the standard flags throws an "flag provided but not defined:" error HOT 6
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 flag.