This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from cloudfoundry-incubator/165900520-multinam…
…espace Add testing helper to create labeled namespaces
- Loading branch information
Showing
6 changed files
with
69 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cmd | ||
|
||
import ( | ||
flag "github.com/spf13/pflag" | ||
"github.com/spf13/viper" | ||
|
||
"code.cloudfoundry.org/quarks-utils/pkg/config" | ||
) | ||
|
||
// MonitoredID sets the moitored id from viper | ||
func MonitoredID(cfg *config.Config) { | ||
id := viper.GetString("monitored-id") | ||
if id == "" { | ||
id = "default" | ||
} | ||
cfg.MonitoredID = id | ||
} | ||
|
||
// MonitoredIDFlags adds to viper flags | ||
func MonitoredIDFlags(pf *flag.FlagSet, argToEnv map[string]string) { | ||
pf.String("monitored-id", "default", "only monitor namespaces with this id in their namespace label") | ||
viper.BindPFlag("monitored-id", pf.Lookup("monitored-id")) | ||
argToEnv["monitored-id"] = "MONITORED_ID" | ||
} |
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,19 @@ | ||
package testhelper | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/spf13/afero" | ||
|
||
"code.cloudfoundry.org/quarks-utils/pkg/config" | ||
) | ||
|
||
// NewConfigWithTimeout returns a default config, with a context timeout | ||
func NewConfigWithTimeout(timeout time.Duration) *config.Config { | ||
return &config.Config{ | ||
Fs: afero.NewMemMapFs(), | ||
CtxTimeOut: timeout, | ||
MeltdownDuration: config.MeltdownDuration, | ||
MeltdownRequeueAfter: config.MeltdownRequeueAfter, | ||
} | ||
} |