From 9e2c10a099d312a94b233ee91737d04cb27a887d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20Suszy=C5=84ski?= Date: Wed, 28 Oct 2020 17:17:52 +0100 Subject: [PATCH] Embedding configuration structs Conflicts resolved: * test/upgrade/prober/configuration.go --- test/upgrade/prober/configuration.go | 48 ++++++++++++++-------------- test/upgrade/prober/forwarder.go | 10 +++--- test/upgrade/prober/prober_test.go | 4 +-- test/upgrade/prober/receiver.go | 10 +++--- test/upgrade/prober/sender.go | 8 ++--- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/test/upgrade/prober/configuration.go b/test/upgrade/prober/configuration.go index 776d591a27e..29f7e6550a5 100644 --- a/test/upgrade/prober/configuration.go +++ b/test/upgrade/prober/configuration.go @@ -49,7 +49,7 @@ var eventTypes = []string{"step", "finished"} // Config represents a configuration for prober. type Config struct { - Wathola WatholaConfig + Wathola Namespace string Interval time.Duration FinishedSleep time.Duration @@ -57,19 +57,19 @@ type Config struct { FailOnErrors bool } -// WatholaConfig represents options related strictly to wathola testing tool. -type WatholaConfig struct { - Config ConfigMapConfig +// Wathola represents options related strictly to wathola testing tool. +type Wathola struct { + ConfigMap EventsTypePrefix string HealthEndpoint string BrokerName string } -// ConfigMapConfig represents options of wathola config toml file. -type ConfigMapConfig struct { - Name string - MountPoint string - Filename string +// ConfigMap represents options of wathola config toml file. +type ConfigMap struct { + ConfigMapName string + ConfigMountPoint string + ConfigFilename string } // ServingConfig represents a options for serving test component (wathola-forwarder). @@ -91,11 +91,11 @@ func NewConfig(namespace string) *Config { Use: false, ScaleToZero: true, }, - Wathola: WatholaConfig{ - Config: ConfigMapConfig{ - Name: defaultConfigName, - MountPoint: fmt.Sprintf("%s/%s", defaultHomedir, defaultConfigHomedirPath), - Filename: defaultConfigFilename, + Wathola: Wathola{ + ConfigMap: ConfigMap{ + ConfigMapName: defaultConfigName, + ConfigMountPoint: fmt.Sprintf("%s/%s", defaultHomedir, defaultConfigHomedirPath), + ConfigFilename: defaultConfigFilename, }, EventsTypePrefix: defaultWatholaEventsPrefix, HealthEndpoint: defaultHealthEndpoint, @@ -119,53 +119,53 @@ func (p *prober) deployConfiguration() { } func (p *prober) deployBroker() { - p.client.CreateBrokerV1Beta1OrFail(p.config.Wathola.BrokerName) + p.client.CreateBrokerV1Beta1OrFail(p.config.BrokerName) } func (p *prober) fetchBrokerURL() (*apis.URL, error) { namespace := p.config.Namespace p.log.Debugf("Fetching %s broker URL for ns %s", - p.config.Wathola.BrokerName, namespace) + p.config.BrokerName, namespace) meta := resources.NewMetaResource( - p.config.Wathola.BrokerName, p.config.Namespace, testlib.BrokerTypeMeta, + p.config.BrokerName, p.config.Namespace, testlib.BrokerTypeMeta, ) err := duck.WaitForResourceReady(p.client.Dynamic, meta) if err != nil { return nil, err } broker, err := p.client.Eventing.EventingV1beta1().Brokers(namespace).Get( - p.config.Wathola.BrokerName, metav1.GetOptions{}, + p.config.BrokerName, metav1.GetOptions{}, ) if err != nil { return nil, err } url := broker.Status.Address.URL p.log.Debugf("%s broker URL for ns %s is %v", - p.config.Wathola.BrokerName, namespace, url) + p.config.BrokerName, namespace, url) return url, nil } func (p *prober) deployConfigMap() { - name := p.config.Wathola.Config.Name + name := p.config.ConfigMapName p.log.Infof("Deploying config map: \"%s/%s\"", p.config.Namespace, name) brokerURL, err := p.fetchBrokerURL() ensure.NoError(err) - configData := p.compileTemplate(p.config.Wathola.Config.Filename, brokerURL) + configData := p.compileTemplate(p.config.ConfigFilename, brokerURL) p.client.CreateConfigMapOrFail(name, p.config.Namespace, map[string]string{ - p.config.Wathola.Config.Filename: configData, + p.config.ConfigFilename: configData, }) } func (p *prober) deployTriggers() { for _, eventType := range eventTypes { name := fmt.Sprintf("wathola-trigger-%v", eventType) - fullType := fmt.Sprintf("%v.%v", p.config.Wathola.EventsTypePrefix, eventType) + fullType := fmt.Sprintf("%v.%v", p.config.EventsTypePrefix, eventType) subscriberOption := resources.WithSubscriberServiceRefForTriggerV1Beta1(receiverName) if p.config.Serving.Use { subscriberOption = resources.WithSubscriberKServiceRefForTrigger(forwarderName) } p.client.CreateTriggerOrFailV1Beta1(name, - resources.WithBrokerV1Beta1(p.config.Wathola.BrokerName), + resources.WithBrokerV1Beta1(p.config.BrokerName), resources.WithAttributesTriggerFilterV1Beta1( eventingv1beta1.TriggerAnyFilter, fullType, diff --git a/test/upgrade/prober/forwarder.go b/test/upgrade/prober/forwarder.go index 33a0c8432de..a5242b870d8 100644 --- a/test/upgrade/prober/forwarder.go +++ b/test/upgrade/prober/forwarder.go @@ -77,20 +77,20 @@ func (p *prober) forwarderKService(name, namespace string) *unstructured.Unstruc "name": "forwarder", "image": pkgTest.ImagePath(forwarderName), "volumeMounts": []map[string]interface{}{{ - "name": p.config.Wathola.Config.Name, - "mountPath": p.config.Wathola.Config.MountPoint, + "name": p.config.ConfigMapName, + "mountPath": p.config.ConfigMountPoint, "readOnly": true, }}, "readinessProbe": map[string]interface{}{ "httpGet": map[string]interface{}{ - "path": p.config.Wathola.HealthEndpoint, + "path": p.config.HealthEndpoint, }, }, }}, "volumes": []map[string]interface{}{{ - "name": p.config.Wathola.Config.Name, + "name": p.config.ConfigMapName, "configMap": map[string]interface{}{ - "name": p.config.Wathola.Config.Name, + "name": p.config.ConfigMapName, }, }}, }, diff --git a/test/upgrade/prober/prober_test.go b/test/upgrade/prober/prober_test.go index e6eb534282c..40666a72e48 100644 --- a/test/upgrade/prober/prober_test.go +++ b/test/upgrade/prober/prober_test.go @@ -27,7 +27,7 @@ import ( const ( defaultConfigFilename = "config.toml" servingEnvName = "E2E_UPGRADE_TESTS_SERVING_USE" - configFilenameEnvName = "E2E_UPGRADE_TESTS_WATHOLA_CONFIG_FILENAME" + configFilenameEnvName = "E2E_UPGRADE_TESTS_CONFIGFILENAME" ) func TestNewConfig(t *testing.T) { @@ -57,7 +57,7 @@ func TestNewConfig(t *testing.T) { assert.Equal(t, s.servingUse, config.Serving.Use) assert.True(t, config.Serving.ScaleToZero) - assert.Equal(t, s.configFilename, config.Wathola.Config.Filename) + assert.Equal(t, s.configFilename, config.ConfigFilename) }) } } diff --git a/test/upgrade/prober/receiver.go b/test/upgrade/prober/receiver.go index 66aa35c79b3..3878390af91 100644 --- a/test/upgrade/prober/receiver.go +++ b/test/upgrade/prober/receiver.go @@ -50,11 +50,11 @@ func (p *prober) deployReceiverPod() { Spec: corev1.PodSpec{ Volumes: []corev1.Volume{ { - Name: p.config.Wathola.Config.Name, + Name: p.config.ConfigMapName, VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ - Name: p.config.Wathola.Config.Name, + Name: p.config.ConfigMapName, }, }, }, @@ -66,15 +66,15 @@ func (p *prober) deployReceiverPod() { Image: pkgTest.ImagePath(receiverName), VolumeMounts: []corev1.VolumeMount{ { - Name: p.config.Wathola.Config.Name, + Name: p.config.ConfigMapName, ReadOnly: true, - MountPath: p.config.Wathola.Config.MountPoint, + MountPath: p.config.ConfigMountPoint, }, }, ReadinessProbe: &corev1.Probe{ Handler: corev1.Handler{ HTTPGet: &corev1.HTTPGetAction{ - Path: p.config.Wathola.HealthEndpoint, + Path: p.config.HealthEndpoint, Port: intstr.FromInt(watholaconfig.DefaultReceiverPort), }, }, diff --git a/test/upgrade/prober/sender.go b/test/upgrade/prober/sender.go index aa5a91a247d..a689e29461c 100644 --- a/test/upgrade/prober/sender.go +++ b/test/upgrade/prober/sender.go @@ -37,11 +37,11 @@ func (p *prober) deploySender() { Spec: corev1.PodSpec{ Volumes: []corev1.Volume{ { - Name: p.config.Wathola.Config.Name, + Name: p.config.ConfigMapName, VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ - Name: p.config.Wathola.Config.Name, + Name: p.config.ConfigMapName, }, }, }, @@ -53,9 +53,9 @@ func (p *prober) deploySender() { Image: pkgTest.ImagePath(senderName), VolumeMounts: []corev1.VolumeMount{ { - Name: p.config.Wathola.Config.Name, + Name: p.config.ConfigMapName, ReadOnly: true, - MountPath: p.config.Wathola.Config.MountPoint, + MountPath: p.config.ConfigMountPoint, }, }, },