Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bake: allow overriding no-cache and pull per target via --set
Signed-off-by: Tibor Vass <tibor@docker.com>
- Loading branch information
Tibor Vass
committed
Apr 23, 2020
1 parent
70209e1
commit 6e74b0d
Showing
5 changed files
with
89 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package flagutil | ||
|
||
import "strconv" | ||
|
||
type tristate struct { | ||
opt *bool | ||
} | ||
|
||
// Tristate is a tri-state boolean flag type. | ||
// It can be set, but not unset. | ||
func Tristate(opt *bool) tristate { | ||
return tristate{opt} | ||
} | ||
|
||
func (t tristate) Type() string { | ||
return "tristate" | ||
} | ||
|
||
func (t tristate) String() string { | ||
if t.opt == nil { | ||
return "(unset)" | ||
} | ||
if *t.opt { | ||
return "true" | ||
} | ||
return "false" | ||
} | ||
|
||
func (t tristate) Set(s string) error { | ||
b, err := strconv.ParseBool(s) | ||
if err != nil { | ||
return err | ||
} | ||
t.opt = &b | ||
return nil | ||
} |