diff --git a/helpers/utils/configmap_utils.go b/helpers/utils/configmap_utils.go index a109752..4c5e14c 100644 --- a/helpers/utils/configmap_utils.go +++ b/helpers/utils/configmap_utils.go @@ -30,7 +30,7 @@ import ( // Defines a function type. Functions of the updateDataFunc type implements the // logic to update the data of a configmap, defined by the 'data' argument. -type updateDataFunc func(obj client.Object, data map[string]interface{}) error +type updateDataFunc func(obj client.Object, data map[string]any) error // A generic function to update an existing ConfigMap. It takes as arguments: // * The context @@ -106,8 +106,8 @@ func loadFileFromConfigMapData( func LoadYAMLFileFromConfigMapData( configMap corev1.ConfigMap, filename string, -) (map[string]interface{}, error) { - yamlContent := map[string]interface{}{} +) (map[string]any, error) { + yamlContent := map[string]any{} content, err := loadFileFromConfigMapData(configMap, filename) if err != nil { @@ -131,7 +131,7 @@ func writeFileToConfigMapData( func writeYAMLFileToConfigMapData( configMap *corev1.ConfigMap, filename string, - yamlContent map[string]interface{}, + yamlContent map[string]any, ) error { bytesContent, err := yaml.Marshal(yamlContent) if err != nil { diff --git a/helpers/utils/tests_utils.go b/helpers/utils/tests_utils.go index 0090985..1bffbaf 100644 --- a/helpers/utils/tests_utils.go +++ b/helpers/utils/tests_utils.go @@ -19,15 +19,15 @@ func BoolAddr(b bool) *bool { return &boolVar } -func Convert(i interface{}) interface{} { +func Convert(i any) any { switch x := i.(type) { - case map[interface{}]interface{}: - m2 := map[string]interface{}{} + case map[any]any: + m2 := map[string]any{} for k, v := range x { m2[k.(string)] = Convert(v) } return m2 - case []interface{}: + case []any: for i, v := range x { x[i] = Convert(v) } diff --git a/helpers/utils/utils.go b/helpers/utils/utils.go index 0ddba8a..d9a0bad 100644 --- a/helpers/utils/utils.go +++ b/helpers/utils/utils.go @@ -18,9 +18,9 @@ package utils import "gopkg.in/yaml.v3" -func ConvertStructToMap(in interface{}) (map[string]interface{}, error) { +func ConvertStructToMap(in any) (map[string]any, error) { var intermediate []byte - var out map[string]interface{} + var out map[string]any intermediate, err := yaml.Marshal(in) if err != nil { return nil, err diff --git a/internal/controller/synapse/heisenbridge/heisenbridge_configmap.go b/internal/controller/synapse/heisenbridge/heisenbridge_configmap.go index 6f6e2fb..34df1a8 100644 --- a/internal/controller/synapse/heisenbridge/heisenbridge_configmap.go +++ b/internal/controller/synapse/heisenbridge/heisenbridge_configmap.go @@ -132,7 +132,7 @@ func (r *HeisenbridgeReconciler) configureHeisenbridgeConfigMap( // bridge. func (r *HeisenbridgeReconciler) updateHeisenbridgeWithURL( obj client.Object, - heisenbridge map[string]interface{}, + heisenbridge map[string]any, ) error { h := obj.(*synapsev1alpha1.Heisenbridge) diff --git a/internal/controller/synapse/heisenbridge/heisenbridge_controller_test.go b/internal/controller/synapse/heisenbridge/heisenbridge_controller_test.go index 8cd30ce..f8f4170 100644 --- a/internal/controller/synapse/heisenbridge/heisenbridge_controller_test.go +++ b/internal/controller/synapse/heisenbridge/heisenbridge_controller_test.go @@ -142,13 +142,13 @@ var _ = Describe("Integration tests for the Heisenbridge controller", Ordered, L }) Context("Validating Heisenbridge CRD Schema", func() { - var obj map[string]interface{} + var obj map[string]any BeforeEach(func() { - obj = map[string]interface{}{ + obj = map[string]any{ "apiVersion": "synapse.opdev.io/v1alpha1", "kind": "Heisenbridge", - "metadata": map[string]interface{}{ + "metadata": map[string]any{ "name": HeisenbridgeName, "namespace": HeisenbridgeNamespace, }, @@ -156,7 +156,7 @@ var _ = Describe("Integration tests for the Heisenbridge controller", Ordered, L }) DescribeTable("Creating a misconfigured Heisenbridge instance", - func(heisenbridge map[string]interface{}) { + func(heisenbridge map[string]any) { // Augment base heisenbridge obj with additional fields for key, value := range heisenbridge { obj[key] = value @@ -165,38 +165,38 @@ var _ = Describe("Integration tests for the Heisenbridge controller", Ordered, L u := unstructured.Unstructured{Object: obj} Expect(k8sClient.Create(ctx, &u)).ShouldNot(Succeed()) }, - Entry("when Heisenbridge spec is missing", map[string]interface{}{}), - Entry("when Heisenbridge spec is empty", map[string]interface{}{ - "spec": map[string]interface{}{}, + Entry("when Heisenbridge spec is missing", map[string]any{}), + Entry("when Heisenbridge spec is empty", map[string]any{ + "spec": map[string]any{}, }), - Entry("when Heisenbridge spec is missing Synapse reference", map[string]interface{}{ - "spec": map[string]interface{}{ - "configMap": map[string]interface{}{ + Entry("when Heisenbridge spec is missing Synapse reference", map[string]any{ + "spec": map[string]any{ + "configMap": map[string]any{ "name": "dummy", }, }, }), - Entry("when Heisenbridge spec Synapse doesn't has a name", map[string]interface{}{ - "spec": map[string]interface{}{ - "synapse": map[string]interface{}{ + Entry("when Heisenbridge spec Synapse doesn't has a name", map[string]any{ + "spec": map[string]any{ + "synapse": map[string]any{ "namespase": "dummy", }, }, }), - Entry("when Heisenbridge spec ConfigMap doesn't specify a Name", map[string]interface{}{ - "spec": map[string]interface{}{ - "configMap": map[string]interface{}{ + Entry("when Heisenbridge spec ConfigMap doesn't specify a Name", map[string]any{ + "spec": map[string]any{ + "configMap": map[string]any{ "namespace": "dummy", }, - "synapse": map[string]interface{}{ + "synapse": map[string]any{ "name": "dummy", }, }, }), // This should not work but passes - PEntry("when Heisenbridge spec possesses an invalid field", map[string]interface{}{ - "spec": map[string]interface{}{ - "synapse": map[string]interface{}{ + PEntry("when Heisenbridge spec possesses an invalid field", map[string]any{ + "spec": map[string]any{ + "synapse": map[string]any{ "name": "dummy", }, "invalidSpecFiels": "random", @@ -205,7 +205,7 @@ var _ = Describe("Integration tests for the Heisenbridge controller", Ordered, L ) DescribeTable("Creating a correct Heisenbridge instance", - func(heisenbridge map[string]interface{}) { + func(heisenbridge map[string]any) { // Augment base heisenbridge obj with additional fields for key, value := range heisenbridge { obj[key] = value @@ -218,13 +218,13 @@ var _ = Describe("Integration tests for the Heisenbridge controller", Ordered, L }, Entry( "when the Configuration file is provided via a ConfigMap", - map[string]interface{}{ - "spec": map[string]interface{}{ - "configMap": map[string]interface{}{ + map[string]any{ + "spec": map[string]any{ + "configMap": map[string]any{ "name": "dummy", "namespace": "dummy", }, - "synapse": map[string]interface{}{ + "synapse": map[string]any{ "name": "dummy", "namespace": "dummy", }, @@ -233,12 +233,12 @@ var _ = Describe("Integration tests for the Heisenbridge controller", Ordered, L ), Entry( "when optional Synapse Namespace and ConfigMap Namespace are missing", - map[string]interface{}{ - "spec": map[string]interface{}{ - "configMap": map[string]interface{}{ + map[string]any{ + "spec": map[string]any{ + "configMap": map[string]any{ "name": "dummy", }, - "synapse": map[string]interface{}{ + "synapse": map[string]any{ "name": "dummy", }, }, @@ -492,7 +492,7 @@ var _ = Describe("Integration tests for the Heisenbridge controller", Ordered, L configMapdata, ok := createdConfigMap.Data["heisenbridge.yaml"] g.Expect(ok).Should(BeTrue()) - heisenbridge := make(map[string]interface{}) + heisenbridge := make(map[string]any) g.Expect(yaml.Unmarshal([]byte(configMapdata), heisenbridge)).Should(Succeed()) _, ok = heisenbridge["url"] diff --git a/internal/controller/synapse/mautrixsignal/mautrixsignal_configmap.go b/internal/controller/synapse/mautrixsignal/mautrixsignal_configmap.go index 1820bd7..e062a32 100644 --- a/internal/controller/synapse/mautrixsignal/mautrixsignal_configmap.go +++ b/internal/controller/synapse/mautrixsignal/mautrixsignal_configmap.go @@ -141,7 +141,7 @@ func (r *MautrixSignalReconciler) configureMautrixSignalConfigMap( // and knows the correct path to the signald socket. func (r *MautrixSignalReconciler) updateMautrixSignalData( obj client.Object, - config map[string]interface{}, + config map[string]any, ) error { ms := obj.(*synapsev1alpha1.MautrixSignal) @@ -150,7 +150,7 @@ func (r *MautrixSignalReconciler) updateMautrixSignalData( synapseServerName := ms.Status.Synapse.ServerName // Update the homeserver section so that the bridge can reach Synapse - configHomeserver, ok := config["homeserver"].(map[string]interface{}) + configHomeserver, ok := config["homeserver"].(map[string]any) if !ok { err := errors.New("cannot parse mautrix-signal config.yaml: error parsing 'homeserver' section") return err @@ -160,7 +160,7 @@ func (r *MautrixSignalReconciler) updateMautrixSignalData( config["homeserver"] = configHomeserver // Update the appservice section so that Synapse can reach the bridge - configAppservice, ok := config["appservice"].(map[string]interface{}) + configAppservice, ok := config["appservice"].(map[string]any) if !ok { err := errors.New("cannot parse mautrix-signal config.yaml: error parsing 'appservice' section") return err @@ -169,7 +169,7 @@ func (r *MautrixSignalReconciler) updateMautrixSignalData( config["appservice"] = configAppservice // Update the path to the signal socket path - configSignal, ok := config["signal"].(map[string]interface{}) + configSignal, ok := config["signal"].(map[string]any) if !ok { err := errors.New("cannot parse mautrix-signal config.yaml: error parsing 'signal' section") return err @@ -178,7 +178,7 @@ func (r *MautrixSignalReconciler) updateMautrixSignalData( config["signal"] = configSignal // Update persmissions to use the correct domain name - configBridge, ok := config["bridge"].(map[string]interface{}) + configBridge, ok := config["bridge"].(map[string]any) if !ok { err := errors.New("cannot parse mautrix-signal config.yaml: error parsing 'bridge' section") return err @@ -191,17 +191,17 @@ func (r *MautrixSignalReconciler) updateMautrixSignalData( config["bridge"] = configBridge // Update the path to the log file - configLogging, ok := config["logging"].(map[string]interface{}) + configLogging, ok := config["logging"].(map[string]any) if !ok { err := errors.New("cannot parse mautrix-signal config.yaml: error parsing 'logging' section") return err } - configLoggingHandlers, ok := configLogging["handlers"].(map[string]interface{}) + configLoggingHandlers, ok := configLogging["handlers"].(map[string]any) if !ok { err := errors.New("cannot parse mautrix-signal config.yaml: error parsing 'logging/handlers' section") return err } - configLoggingHandlersFile, ok := configLoggingHandlers["file"].(map[string]interface{}) + configLoggingHandlersFile, ok := configLoggingHandlers["file"].(map[string]any) if !ok { err := errors.New("cannot parse mautrix-signal config.yaml: error parsing 'logging/handlers/file' section") return err diff --git a/internal/controller/synapse/mautrixsignal/mautrixsignal_controller_test.go b/internal/controller/synapse/mautrixsignal/mautrixsignal_controller_test.go index 612eaf6..085a5ac 100644 --- a/internal/controller/synapse/mautrixsignal/mautrixsignal_controller_test.go +++ b/internal/controller/synapse/mautrixsignal/mautrixsignal_controller_test.go @@ -143,13 +143,13 @@ var _ = Describe("Integration tests for the MautrixSignal controller", Ordered, }) Context("Validating MautrixSignal CRD Schema", func() { - var obj map[string]interface{} + var obj map[string]any BeforeEach(func() { - obj = map[string]interface{}{ + obj = map[string]any{ "apiVersion": "synapse.opdev.io/v1alpha1", "kind": "MautrixSignal", - "metadata": map[string]interface{}{ + "metadata": map[string]any{ "name": MautrixSignalName, "namespace": MautrixSignalNamespace, }, @@ -157,7 +157,7 @@ var _ = Describe("Integration tests for the MautrixSignal controller", Ordered, }) DescribeTable("Creating a misconfigured MautrixSignal instance", - func(mautrixsignal map[string]interface{}) { + func(mautrixsignal map[string]any) { // Augment base mautrixsignal obj with additional fields for key, value := range mautrixsignal { obj[key] = value @@ -166,38 +166,38 @@ var _ = Describe("Integration tests for the MautrixSignal controller", Ordered, u := unstructured.Unstructured{Object: obj} Expect(k8sClient.Create(ctx, &u)).ShouldNot(Succeed()) }, - Entry("when MautrixSignal spec is missing", map[string]interface{}{}), - Entry("when MautrixSignal spec is empty", map[string]interface{}{ - "spec": map[string]interface{}{}, + Entry("when MautrixSignal spec is missing", map[string]any{}), + Entry("when MautrixSignal spec is empty", map[string]any{ + "spec": map[string]any{}, }), - Entry("when MautrixSignal spec is missing Synapse reference", map[string]interface{}{ - "spec": map[string]interface{}{ - "configMap": map[string]interface{}{ + Entry("when MautrixSignal spec is missing Synapse reference", map[string]any{ + "spec": map[string]any{ + "configMap": map[string]any{ "name": "dummy", }, }, }), - Entry("when MautrixSignal spec Synapse doesn't has a name", map[string]interface{}{ - "spec": map[string]interface{}{ - "synapse": map[string]interface{}{ + Entry("when MautrixSignal spec Synapse doesn't has a name", map[string]any{ + "spec": map[string]any{ + "synapse": map[string]any{ "namespase": "dummy", }, }, }), - Entry("when MautrixSignal spec ConfigMap doesn't specify a Name", map[string]interface{}{ - "spec": map[string]interface{}{ - "configMap": map[string]interface{}{ + Entry("when MautrixSignal spec ConfigMap doesn't specify a Name", map[string]any{ + "spec": map[string]any{ + "configMap": map[string]any{ "namespace": "dummy", }, - "synapse": map[string]interface{}{ + "synapse": map[string]any{ "name": "dummy", }, }, }), // This should not work but passes - PEntry("when MautrixSignal spec possesses an invalid field", map[string]interface{}{ - "spec": map[string]interface{}{ - "synapse": map[string]interface{}{ + PEntry("when MautrixSignal spec possesses an invalid field", map[string]any{ + "spec": map[string]any{ + "synapse": map[string]any{ "name": "dummy", }, "invalidSpecFiels": "random", @@ -206,7 +206,7 @@ var _ = Describe("Integration tests for the MautrixSignal controller", Ordered, ) DescribeTable("Creating a correct MautrixSignal instance", - func(mautrixsignal map[string]interface{}) { + func(mautrixsignal map[string]any) { // Augment base mautrixsignal obj with additional fields for key, value := range mautrixsignal { obj[key] = value @@ -219,13 +219,13 @@ var _ = Describe("Integration tests for the MautrixSignal controller", Ordered, }, Entry( "when the Configuration file is provided via a ConfigMap", - map[string]interface{}{ - "spec": map[string]interface{}{ - "configMap": map[string]interface{}{ + map[string]any{ + "spec": map[string]any{ + "configMap": map[string]any{ "name": "dummy", "namespace": "dummy", }, - "synapse": map[string]interface{}{ + "synapse": map[string]any{ "name": "dummy", "namespace": "dummy", }, @@ -234,12 +234,12 @@ var _ = Describe("Integration tests for the MautrixSignal controller", Ordered, ), Entry( "when optional Synapse Namespace and ConfigMap Namespace are missing", - map[string]interface{}{ - "spec": map[string]interface{}{ - "configMap": map[string]interface{}{ + map[string]any{ + "spec": map[string]any{ + "configMap": map[string]any{ "name": "dummy", }, - "synapse": map[string]interface{}{ + "synapse": map[string]any{ "name": "dummy", }, }, @@ -567,41 +567,41 @@ logging: ConfigMapdata, ok := createdConfigMap.Data["config.yaml"] g.Expect(ok).Should(BeTrue()) - config := make(map[string]interface{}) + config := make(map[string]any) g.Expect(yaml.Unmarshal([]byte(ConfigMapdata), config)).Should(Succeed()) By("Verifying that the homeserver configuration has been updated") - configHomeserver, ok := config["homeserver"].(map[string]interface{}) + configHomeserver, ok := config["homeserver"].(map[string]any) g.Expect(ok).Should(BeTrue()) g.Expect(configHomeserver["address"]).To(Equal("http://" + synapseFQDN + ":8008")) g.Expect(configHomeserver["domain"]).To(Equal(SynapseServerName)) By("Verifying that the appservice configuration has been updated") expectedConfigAppServiceAddress := "http://" + mautrixsignalFQDN + ":" + strconv.Itoa(mautrixsignalPort) - configAppservice, ok := config["appservice"].(map[string]interface{}) + configAppservice, ok := config["appservice"].(map[string]any) g.Expect(ok).Should(BeTrue()) g.Expect(configAppservice["address"]).To(Equal(expectedConfigAppServiceAddress)) By("Verifying that the signal configuration has been updated") - configSignal, ok := config["signal"].(map[string]interface{}) + configSignal, ok := config["signal"].(map[string]any) g.Expect(ok).Should(BeTrue()) g.Expect(configSignal["socket_path"]).To(Equal("/signald/signald.sock")) By("Verifying that the permissions have been updated") - configBridge, ok := config["bridge"].(map[string]interface{}) + configBridge, ok := config["bridge"].(map[string]any) g.Expect(ok).Should(BeTrue()) - configBridgePermissions, ok := configBridge["permissions"].(map[string]interface{}) + configBridgePermissions, ok := configBridge["permissions"].(map[string]any) g.Expect(ok).Should(BeTrue()) g.Expect(configBridgePermissions).Should(HaveKeyWithValue("*", "relay")) g.Expect(configBridgePermissions).Should(HaveKeyWithValue(SynapseServerName, "user")) g.Expect(configBridgePermissions).Should(HaveKeyWithValue("@admin:"+SynapseServerName, "admin")) By("Verifying that the log configuration file path have been updated") - configLogging, ok := config["logging"].(map[string]interface{}) + configLogging, ok := config["logging"].(map[string]any) g.Expect(ok).Should(BeTrue()) - configLoggingHandlers, ok := configLogging["handlers"].(map[string]interface{}) + configLoggingHandlers, ok := configLogging["handlers"].(map[string]any) g.Expect(ok).Should(BeTrue()) - configLoggingHandlersFile, ok := configLoggingHandlers["file"].(map[string]interface{}) + configLoggingHandlersFile, ok := configLoggingHandlers["file"].(map[string]any) g.Expect(ok).Should(BeTrue()) g.Expect(configLoggingHandlersFile["filename"]).To(Equal("/data/mautrix-signal.log")) }, timeout, interval).Should(Succeed()) diff --git a/internal/controller/synapse/synapse/synapse_configmap.go b/internal/controller/synapse/synapse/synapse_configmap.go index 2b7972d..8d20d02 100644 --- a/internal/controller/synapse/synapse/synapse_configmap.go +++ b/internal/controller/synapse/synapse/synapse_configmap.go @@ -254,7 +254,7 @@ func (r *SynapseReconciler) updateSynapseConfigMapForPostgresCluster( func (r *SynapseReconciler) updateHomeserverWithPostgreSQLInfos( obj client.Object, - homeserver map[string]interface{}, + homeserver map[string]any, ) error { s := obj.(*synapsev1alpha1.Synapse) @@ -268,43 +268,43 @@ func (r *SynapseReconciler) updateHomeserverWithPostgreSQLInfos( return nil } -func (r *SynapseReconciler) fetchDatabaseDataFromSynapseStatus(s synapsev1alpha1.Synapse) (map[string]interface{}, error) { +func (r *SynapseReconciler) fetchDatabaseDataFromSynapseStatus(s synapsev1alpha1.Synapse) (map[string]any, error) { databaseData := HomeserverPgsqlDatabase{} // Check if s.Status.DatabaseConnectionInfo contains necessary information if s.Status.DatabaseConnectionInfo == (synapsev1alpha1.SynapseStatusDatabaseConnectionInfo{}) { err := errors.New("missing DatabaseConnectionInfo in Synapse status") - return map[string]interface{}{}, err + return map[string]any{}, err } if s.Status.DatabaseConnectionInfo.User == "" { err := errors.New("missing User in DatabaseConnectionInfo") - return map[string]interface{}{}, err + return map[string]any{}, err } if s.Status.DatabaseConnectionInfo.Password == "" { err := errors.New("missing Password in DatabaseConnectionInfo") - return map[string]interface{}{}, err + return map[string]any{}, err } decodedPassword := base64decode([]byte(s.Status.DatabaseConnectionInfo.Password)) if s.Status.DatabaseConnectionInfo.DatabaseName == "" { err := errors.New("missing DatabaseName in DatabaseConnectionInfo") - return map[string]interface{}{}, err + return map[string]any{}, err } if s.Status.DatabaseConnectionInfo.ConnectionURL == "" { err := errors.New("missing ConnectionURL in DatabaseConnectionInfo") - return map[string]interface{}{}, err + return map[string]any{}, err } connectionURL := strings.Split(s.Status.DatabaseConnectionInfo.ConnectionURL, ":") if len(connectionURL) < 2 { err := errors.New("error parsing the Connection URL with value: " + s.Status.DatabaseConnectionInfo.ConnectionURL) - return map[string]interface{}{}, err + return map[string]any{}, err } port, err := strconv.ParseInt(connectionURL[1], 10, 64) if err != nil { - return map[string]interface{}{}, err + return map[string]any{}, err } // Populate databaseData @@ -317,10 +317,10 @@ func (r *SynapseReconciler) fetchDatabaseDataFromSynapseStatus(s synapsev1alpha1 databaseData.Args.CpMin = 5 databaseData.Args.CpMax = 10 - // Convert databaseData into a map[string]interface{} + // Convert databaseData into a map[string]any databaseDataMap, err := utils.ConvertStructToMap(databaseData) if err != nil { - return map[string]interface{}{}, err + return map[string]any{}, err } return databaseDataMap, nil @@ -362,7 +362,7 @@ func (r *SynapseReconciler) updateSynapseConfigMapForBridges( func (r *SynapseReconciler) updateHomeserverWithBridgesInfo( obj client.Object, - homeserver map[string]interface{}, + homeserver map[string]any, ) error { s := obj.(*synapsev1alpha1.Synapse) @@ -384,7 +384,7 @@ func (r *SynapseReconciler) updateHomeserverWithBridgesInfo( } func (r *SynapseReconciler) addAppServicesToHomeserver( - homeserver map[string]interface{}, + homeserver map[string]any, configFilePaths []string, ) { homeserverAppService, ok := homeserver["app_service_config_files"].([]string) diff --git a/internal/controller/synapse/synapse/synapse_controller_test.go b/internal/controller/synapse/synapse/synapse_controller_test.go index f12b7f6..4277def 100644 --- a/internal/controller/synapse/synapse/synapse_controller_test.go +++ b/internal/controller/synapse/synapse/synapse_controller_test.go @@ -151,7 +151,7 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label( Expect(err).ShouldNot(HaveOccurred()) // Unmarshal the YAML document into an intermediate map - var mapBody interface{} + var mapBody any Expect(yaml.Unmarshal(yamlBody, &mapBody)).ShouldNot(HaveOccurred()) // The map has to be converted. See https://stackoverflow.com/a/40737676/6133648 @@ -189,13 +189,13 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label( }) Context("Validating Synapse CRD Schema", func() { - var obj map[string]interface{} + var obj map[string]any BeforeEach(func() { - obj = map[string]interface{}{ + obj = map[string]any{ "apiVersion": "synapse.opdev.io/v1alpha1", "kind": "Synapse", - "metadata": map[string]interface{}{ + "metadata": map[string]any{ "name": SynapseName, "namespace": SynapseNamespace, }, @@ -203,7 +203,7 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label( }) DescribeTable("Creating a misconfigured Synapse instance", - func(synapse_data map[string]interface{}) { + func(synapse_data map[string]any) { // Augment base synapse obj with additional fields for key, value := range synapse_data { obj[key] = value @@ -212,60 +212,60 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label( u := unstructured.Unstructured{Object: obj} Expect(k8sClient.Create(ctx, &u)).ShouldNot(Succeed()) }, - Entry("when Synapse spec is missing", map[string]interface{}{}), - Entry("when Synapse spec is empty", map[string]interface{}{ - "spec": map[string]interface{}{}, + Entry("when Synapse spec is missing", map[string]any{}), + Entry("when Synapse spec is empty", map[string]any{ + "spec": map[string]any{}, }), - Entry("when Synapse spec is missing Homeserver", map[string]interface{}{ - "spec": map[string]interface{}{"createNewPostgreSQL": true}, + Entry("when Synapse spec is missing Homeserver", map[string]any{ + "spec": map[string]any{"createNewPostgreSQL": true}, }), - Entry("when Synapse spec Homeserver is empty", map[string]interface{}{ - "spec": map[string]interface{}{ - "homeserver": map[string]interface{}{}, + Entry("when Synapse spec Homeserver is empty", map[string]any{ + "spec": map[string]any{ + "homeserver": map[string]any{}, }, }), - Entry("when Synapse spec Homeserver possess both Values and ConfigMap", map[string]interface{}{ - "spec": map[string]interface{}{ - "homeserver": map[string]interface{}{ - "configMap": map[string]interface{}{ + Entry("when Synapse spec Homeserver possess both Values and ConfigMap", map[string]any{ + "spec": map[string]any{ + "homeserver": map[string]any{ + "configMap": map[string]any{ "name": InputConfigMapName, "namespace": SynapseNamespace, }, - "values": map[string]interface{}{ + "values": map[string]any{ "serverName": ServerName, "reportStats": ReportStats, }, }}, }), - Entry("when Synapse spec Homeserver ConfigMap doesn't specify a Name", map[string]interface{}{ - "spec": map[string]interface{}{ - "homeserver": map[string]interface{}{ - "configMap": map[string]interface{}{ + Entry("when Synapse spec Homeserver ConfigMap doesn't specify a Name", map[string]any{ + "spec": map[string]any{ + "homeserver": map[string]any{ + "configMap": map[string]any{ "namespace": SynapseNamespace, }, }}, }), - Entry("when Synapse spec Homeserver Values is missing ServerName", map[string]interface{}{ - "spec": map[string]interface{}{ - "homeserver": map[string]interface{}{ - "values": map[string]interface{}{ + Entry("when Synapse spec Homeserver Values is missing ServerName", map[string]any{ + "spec": map[string]any{ + "homeserver": map[string]any{ + "values": map[string]any{ "reportStats": ReportStats, }, }}, }), - Entry("when Synapse spec Homeserver Values is missing ReportStats", map[string]interface{}{ - "spec": map[string]interface{}{ - "homeserver": map[string]interface{}{ - "values": map[string]interface{}{ + Entry("when Synapse spec Homeserver Values is missing ReportStats", map[string]any{ + "spec": map[string]any{ + "homeserver": map[string]any{ + "values": map[string]any{ "serverName": ServerName, }, }}, }), // This should not work but passes - PEntry("when Synapse spec possesses an invalid field", map[string]interface{}{ - "spec": map[string]interface{}{ - "homeserver": map[string]interface{}{ - "configMap": map[string]interface{}{ + PEntry("when Synapse spec possesses an invalid field", map[string]any{ + "spec": map[string]any{ + "homeserver": map[string]any{ + "configMap": map[string]any{ "name": InputConfigMapName, "namespace": SynapseNamespace, }, @@ -276,7 +276,7 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label( ) DescribeTable("Creating a correct Synapse instance", - func(synapse_data map[string]interface{}) { + func(synapse_data map[string]any) { // Augment base synapse obj with additional fields for key, value := range synapse_data { obj[key] = value @@ -289,10 +289,10 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label( }, Entry( "when the Homeserver Configuration file is provided via a ConfigMap", - map[string]interface{}{ - "spec": map[string]interface{}{ - "homeserver": map[string]interface{}{ - "configMap": map[string]interface{}{ + map[string]any{ + "spec": map[string]any{ + "homeserver": map[string]any{ + "configMap": map[string]any{ "name": InputConfigMapName, "namespace": SynapseNamespace, }, @@ -303,10 +303,10 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label( ), Entry( "when the Homeserver Configuration values are provided", - map[string]interface{}{ - "spec": map[string]interface{}{ - "homeserver": map[string]interface{}{ - "values": map[string]interface{}{ + map[string]any{ + "spec": map[string]any{ + "homeserver": map[string]any{ + "values": map[string]any{ "serverName": ServerName, "reportStats": ReportStats, }, @@ -317,10 +317,10 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label( ), Entry( "when optional CreateNewPostgreSQL and ConfigMap Namespace are missing", - map[string]interface{}{ - "spec": map[string]interface{}{ - "homeserver": map[string]interface{}{ - "configMap": map[string]interface{}{ + map[string]any{ + "spec": map[string]any{ + "homeserver": map[string]any{ + "configMap": map[string]any{ "name": InputConfigMapName, }, }, @@ -695,7 +695,7 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label( ConfigMapData, ok := createdConfigMap.Data["homeserver.yaml"] g.Expect(ok).Should(BeTrue()) - homeserver := make(map[string]interface{}) + homeserver := make(map[string]any) g.Expect(yaml.Unmarshal([]byte(ConfigMapData), homeserver)).Should(Succeed()) _, ok = homeserver["database"] @@ -815,7 +815,7 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label( ConfigMapData, ok := createdConfigMap.Data["homeserver.yaml"] g.Expect(ok).Should(BeTrue()) - homeserver := make(map[string]interface{}) + homeserver := make(map[string]any) g.Expect(yaml.Unmarshal([]byte(ConfigMapData), homeserver)).Should(Succeed()) _, ok = homeserver["app_service_config_files"] @@ -963,7 +963,7 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label( ConfigMapData, ok := createdConfigMap.Data["homeserver.yaml"] g.Expect(ok).Should(BeTrue()) - homeserver := make(map[string]interface{}) + homeserver := make(map[string]any) g.Expect(yaml.Unmarshal([]byte(ConfigMapData), homeserver)).Should(Succeed()) _, ok = homeserver["app_service_config_files"] diff --git a/internal/controller/synapse/synapse/synapse_test.go b/internal/controller/synapse/synapse/synapse_test.go index 49549ff..a222b56 100644 --- a/internal/controller/synapse/synapse/synapse_test.go +++ b/internal/controller/synapse/synapse/synapse_test.go @@ -337,8 +337,8 @@ var _ = Describe("Unit tests for Synapse package", Label("unit"), func() { Context("When updating the Synapse ConfigMap Data with PostgreSQL database information", func() { var r SynapseReconciler var cm corev1.ConfigMap - var homeserver_in map[interface{}]interface{} - var homeserver_out map[interface{}]interface{} + var homeserver_in map[any]any + var homeserver_out map[any]any var s synapsev1alpha1.Synapse var synapseDatabaseInfo synapsev1alpha1.SynapseStatusDatabaseConnectionInfo @@ -408,17 +408,17 @@ var _ = Describe("Unit tests for Synapse package", Label("unit"), func() { r = SynapseReconciler{} cm = corev1.ConfigMap{} s = synapsev1alpha1.Synapse{} - homeserver_out = make(map[interface{}]interface{}) + homeserver_out = make(map[any]any) // Init default value for pre-existing homeserver.yaml, and for Synapse // Status given as input. These are intended to be overwritten in the // different tests depending on the behavior that is currently being tested. - homeserver_in = map[interface{}]interface{}{ + homeserver_in = map[any]any{ "server_name": "example.com", "report_stats": true, - "database": map[interface{}]interface{}{ + "database": map[any]any{ "name": "sqlite3", - "args": map[interface{}]interface{}{ + "args": map[any]any{ "database": "/path/to/homeserver.db", }, }, @@ -462,12 +462,12 @@ var _ = Describe("Unit tests for Synapse package", Label("unit"), func() { When("when homeserver.yaml contain prior database information for a PostgreSQL Instance", func() { BeforeEach(func() { - homeserver_in = map[interface{}]interface{}{ + homeserver_in = map[any]any{ "server_name": "example.com", "report_stats": true, - "database": map[interface{}]interface{}{ + "database": map[any]any{ "name": "psycopg2", - "args": map[interface{}]interface{}{ + "args": map[any]any{ "user": "not-synapse", "password": "PmRJTlF1cn1yPHZKUkUrWmJaRCxkPGE+", "database": "anotherdb",