Skip to content

Commit e196340

Browse files
fmountclaude
andcommitted
Modernize Go code with latest style conventions
Applied automated modernization using gopls modernize tool to update: - Replace interface{} with any type alias (Go 1.18+) - Update range loops to use idiomatic range syntax - Replace fmt.Sprintf with fmt.Appendf where appropriate These changes improve code readability and align with current Go best practices. Co-Authored-By: Claude <[email protected]> Signed-off-by: Francesco Pantano <[email protected]>
1 parent e032ee3 commit e196340

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

controllers/galera_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func buildGcommURI(instance *mariadbv1.Galera) string {
142142
basename := instance.Name + "-galera"
143143
res := []string{}
144144

145-
for i := 0; i < replicas; i++ {
145+
for i := range replicas {
146146
// Generate Gcomm with subdomains for TLS validation
147147
res = append(res, basename+"-"+strconv.Itoa(i)+"."+basename+"."+instance.Namespace+".svc")
148148
}
@@ -943,7 +943,7 @@ func (r *GaleraReconciler) generateConfigMaps(
943943
envVars *map[string]env.Setter,
944944
) error {
945945
log := GetLog(ctx, "galera")
946-
templateParameters := map[string]interface{}{
946+
templateParameters := map[string]any{
947947
"logToDisk": instance.Spec.LogToDisk,
948948
}
949949
customData := make(map[string]string)

tests/functional/base_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ const (
3434
interval = timeout / 100
3535
)
3636

37-
func CreateGaleraConfig(namespace string, spec map[string]interface{}) client.Object {
37+
func CreateGaleraConfig(namespace string, spec map[string]any) client.Object {
3838
name := uuid.New().String()
3939

40-
raw := map[string]interface{}{
40+
raw := map[string]any{
4141
"apiVersion": "mariadb.openstack.org/v1beta1",
4242
"kind": "Galera",
43-
"metadata": map[string]interface{}{
43+
"metadata": map[string]any{
4444
"name": name,
4545
"namespace": namespace,
4646
},
@@ -50,8 +50,8 @@ func CreateGaleraConfig(namespace string, spec map[string]interface{}) client.Ob
5050
return th.CreateUnstructured(raw)
5151
}
5252

53-
func GetDefaultGaleraSpec() map[string]interface{} {
54-
return map[string]interface{}{
53+
func GetDefaultGaleraSpec() map[string]any {
54+
return map[string]any{
5555
"replicas": 1,
5656
"logToDisk": false,
5757
"secret": "osp-secret",

tests/functional/galera_webhook_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ var _ = Describe("Galera webhook", func() {
4646
When("a Galera gets created with a name longer then 46 chars", func() {
4747
It("gets blocked by the webhook and fail", func() {
4848

49-
raw := map[string]interface{}{
49+
raw := map[string]any{
5050
"apiVersion": "mariadb.openstack.org/v1beta1",
5151
"kind": "Galera",
52-
"metadata": map[string]interface{}{
52+
"metadata": map[string]any{
5353
"name": "foo-1234567890-1234567890-1234567890-1234567890",
5454
"namespace": namespace,
5555
},

0 commit comments

Comments
 (0)