Commit eae26c95 authored by Andy Cobaugh's avatar Andy Cobaugh

wait: make url template configurable via flag

parent 796d41e1
......@@ -53,7 +53,7 @@ var ciWaitCmd = &cobra.Command{
var ciWaitCommitFields = []string{"scm-commit-id", "Commit", "commit"}
var ciWaitVersionFields = []string{"Version", "version", "commit"}
var ciWaitURLs = []string{
var ciWaitURLsDefault = []string{
"https://{{.Env}}-{{.Project}}.qa.k8s.psu.edu/{{.Project}}-web/resources/version",
"https://{{.Env}}-{{.Project}}.qa.k8s.psu.edu/{{.Project}}/resources/version",
"https://{{.Env}}-{{.Project}}.qa.k8s.psu.edu/resources/version",
......@@ -66,6 +66,7 @@ type ciWaitBaseURLData struct {
}
func init() {
ciWaitCmd.PersistentFlags().StringArrayP("urls", "u", ciWaitURLsDefault, "List of URL templates to check in order to find version endpoint")
ciWaitCmd.PersistentFlags().Int("url-max-tries", 10, "Max tries to locate the version endpoint")
ciWaitCmd.PersistentFlags().Duration("url-delay", 10*time.Second, "Time to wait between attempts to locate version endpoint")
ciWaitCmd.PersistentFlags().Int("update-max-tries", 30, "Max tries to check version endpoint for the update")
......@@ -102,7 +103,7 @@ func runCiWaitCmd(cmd *cobra.Command, args []string) error {
// loop over possible urls
cli.Default.Padding = 2 * InitialPadding
for i := 1; i <= viper.GetInt("url-max-tries"); i++ {
for _, u := range ciWaitURLs {
for _, u := range viper.GetStringSlice("urls") {
tmpl, err := template.New("URL").Parse(u)
if err != nil {
log.Fatalf("Could not parse URL template '%s': %s", u, err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment