github.com/abayer/test-infra@v0.0.5/mungegithub/mungeopts/mungeopts.go (about) 1 /* 2 Copyright 2017 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package mungeopts 18 19 import ( 20 "time" 21 22 "k8s.io/apimachinery/pkg/util/sets" 23 "k8s.io/test-infra/mungegithub/options" 24 ) 25 26 var ( 27 // GCS holds the values of GCS options. 28 GCS struct { 29 BucketName string 30 LogDir string 31 32 // PullLogDir is the directory of the pr builder jenkins 33 PullLogDir string 34 35 // PullKey is a string to look for in a job name to figure out if it's 36 // a pull (presubmit) job. 37 PullKey string 38 } 39 40 // RequiredContexts holds options that specify which status contexts are required for various 41 // actions. 42 RequiredContexts struct { 43 Merge []string 44 Retest []string 45 } 46 47 // Maximum time to wait for tests in a PR to start or finish. 48 // This should be >2x as long as it normally takes for a PR 49 // to complete, to avoid congestion collapse in the queue. 50 PRMaxWaitTime time.Duration 51 52 // App is the mungegithub app (like 'submit-queue', 'cherrypick', or 'misc-mungers') 53 App string 54 ) 55 56 // RegisterOptions registers options that may be used by any munger, feature, or report. It returns 57 // any options that require a restart when changed. 58 func RegisterOptions(opts *options.Options) sets.String { 59 // GCS options: 60 opts.RegisterString(&GCS.BucketName, "gcs-bucket", "", "Name of GCS bucket.") 61 opts.RegisterString(&GCS.LogDir, "gcs-logs-dir", "", "Directory containing test logs.") 62 opts.RegisterString(&GCS.PullLogDir, "pull-logs-dir", "", "Directory of the PR builder.") 63 opts.RegisterString(&GCS.PullKey, "pull-key", "", "String to look for in job name for it to be a pull (presubmit) job.") 64 65 // Status context options: 66 opts.RegisterStringSlice(&RequiredContexts.Retest, "required-retest-contexts", []string{}, "Comma separate list of statuses which will be retested and which must come back green after the `retest-body` comment is posted to a PR") 67 opts.RegisterStringSlice(&RequiredContexts.Merge, "required-contexts", []string{}, "Comma separate list of status contexts required for a PR to be considered ok to merge") 68 69 opts.RegisterDuration(&PRMaxWaitTime, "pr-max-wait-time", 2*time.Hour, "Maximum time to wait for tests in a PR to start or finish") 70 71 opts.RegisterString(&App, "app", "submit-queue", "The mungegithub app that this instance represents.") 72 73 return sets.NewString("app") 74 }