knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/test/environment/config.go (about) 1 /* 2 Copyright 2020 The Knative 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 // This file contains logic to encapsulate flags which are needed to specify 18 // what cluster, etc. to use for e2e tests. 19 20 package environment 21 22 import ( 23 "flag" 24 "os" 25 "time" 26 ) 27 28 // TestClientConfig defines propertis about the test environment 29 type TestClientConfig struct { 30 Namespace string // K8s namespace (blank by default, to be overwritten by test suite) 31 IngressEndpoint string // Host to use for ingress endpoint 32 ImageTemplate string // Template to build the image reference (defaults to {{.Repository}}/{{.Name}}:{{.Tag}}) 33 DockerRepo string // Docker repo (defaults to $KO_DOCKER_REPO) 34 Tag string // Tag for test images 35 SpoofRequestInterval time.Duration // SpoofRequestInterval is the interval between requests in SpoofingClient 36 SpoofRequestTimeout time.Duration // SpoofRequestTimeout is the timeout for polling requests in SpoofingClient 37 } 38 39 // InitFlags is for explicitly initializing the flags. 40 func (c *TestClientConfig) InitFlags(fs *flag.FlagSet) { 41 fs.StringVar(&c.Namespace, "namespace", "", 42 "Provide the namespace you would like to use for these tests.") 43 44 fs.StringVar(&c.IngressEndpoint, "ingressendpoint", "", "Provide a static endpoint url to the ingress server used during tests.") 45 46 fs.StringVar(&c.ImageTemplate, "imagetemplate", "{{.Repository}}/{{.Name}}:{{.Tag}}", 47 "Provide a template to generate the reference to an image from the test. Defaults to `{{.Repository}}/{{.Name}}:{{.Tag}}`.") 48 49 fs.DurationVar(&c.SpoofRequestInterval, "spoofinterval", 1*time.Second, 50 "Provide an interval between requests for the SpoofingClient") 51 52 fs.DurationVar(&c.SpoofRequestTimeout, "spooftimeout", 5*time.Minute, 53 "Provide a request timeout for the SpoofingClient") 54 55 defaultRepo := os.Getenv("KO_DOCKER_REPO") 56 fs.StringVar(&c.DockerRepo, "dockerrepo", defaultRepo, 57 "Provide the uri of the docker repo you have uploaded the test image to using `uploadtestimage.sh`. Defaults to $KO_DOCKER_REPO") 58 59 fs.StringVar(&c.Tag, "tag", "latest", "Provide the version tag for the test images.") 60 }