Skip to content

Commit

Permalink
experimentalflags: improve doc strings and module docs
Browse files Browse the repository at this point in the history
This commit improves the docs strings and module documentation
for the `experimentalflags` package.

Thanks to Achilleas.

This is a followup for
#1248 (review)
where excellent points are raised.

Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
  • Loading branch information
2 people authored and bcl committed Feb 25, 2025
1 parent 083ab3f commit 9d95516
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion pkg/experimentalflags/experimental.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Package experimentalflags provides functionality for reading
// options defined in an environment variable named
// IMAGE_BUILDER_EXPERIMENTAL.
//
// These functions should be used to determine, in a common way, if
// experimental features should be enabled when using the libarary.
package experimentalflags

import (
Expand Down Expand Up @@ -30,7 +36,13 @@ func experimentalOptions() map[string]string {
}

// Bool returns true if there is a boolean option with the given
// option name
// option name.
//
// Example usage by the user:
//
// IMAGE_BUILDER_EXPERIMENTAL=skip-foo,skip-bar=1,skip-baz=true
//
// would result in experimetnalflags.Bool("skip-foo") -> true
func Bool(option string) bool {
expMap := experimentalOptions()
b, err := strconv.ParseBool(expMap[option])
Expand All @@ -41,6 +53,16 @@ func Bool(option string) bool {
return b
}

// String returns the user set string for the given experimental feature.
//
// Note that currently no quoting or escaping is supported, so a string
// can (currently) not contain a "," or a "=".
//
// Example usage by the user:
//
// IMAGE_BUILDER_EXPERIMENTAL=key=value
//
// would result in experimetnalflags.String("key") -> "value"
func String(option string) string {
expMap := experimentalOptions()
return expMap[option]
Expand Down

0 comments on commit 9d95516

Please sign in to comment.