Skip to content

Commit

Permalink
Stop using exp maps package
Browse files Browse the repository at this point in the history
  • Loading branch information
BooleanCat committed Jul 20, 2024
1 parent da01a16 commit 8bfc20f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
5 changes: 3 additions & 2 deletions api/actions/manifest/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package manifest
import (
"context"
"fmt"
"maps"
"slices"
"strings"

"code.cloudfoundry.org/korifi/api/actions/shared"
Expand All @@ -12,7 +14,6 @@ import (
"code.cloudfoundry.org/korifi/api/repositories"
"code.cloudfoundry.org/korifi/api/tools/singleton"
korifiv1alpha1 "code.cloudfoundry.org/korifi/controllers/api/v1alpha1"
"golang.org/x/exp/maps"
)

type Applier struct {
Expand Down Expand Up @@ -218,7 +219,7 @@ func (a *Applier) applyServices(ctx context.Context, authInfo authorization.Info
}

serviceInstances, err := a.serviceInstanceRepo.ListServiceInstances(ctx, authInfo, repositories.ListServiceInstanceMessage{
Names: maps.Keys(desiredServiceNames),
Names: slices.Collect(maps.Keys(desiredServiceNames)),
})
if err != nil {
return err
Expand Down
5 changes: 3 additions & 2 deletions api/actions/manifest/state_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"context"
"errors"
"fmt"
"maps"
"path"
"slices"

"code.cloudfoundry.org/korifi/api/actions/shared"
"code.cloudfoundry.org/korifi/api/authorization"
apierrors "code.cloudfoundry.org/korifi/api/errors"
"code.cloudfoundry.org/korifi/api/repositories"
"code.cloudfoundry.org/korifi/api/tools/singleton"
"golang.org/x/exp/maps"
)

type StateCollector struct {
Expand Down Expand Up @@ -131,7 +132,7 @@ func (s StateCollector) collectServiceBindings(ctx context.Context, authInfo aut
serviceInstanceGUIDSet[sb.ServiceInstanceGUID] = true
}

services, err := s.serviceInstanceRepo.ListServiceInstances(ctx, authInfo, repositories.ListServiceInstanceMessage{GUIDs: maps.Keys(serviceInstanceGUIDSet)})
services, err := s.serviceInstanceRepo.ListServiceInstances(ctx, authInfo, repositories.ListServiceInstanceMessage{GUIDs: slices.Collect(maps.Keys(serviceInstanceGUIDSet))})
if err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions controllers/controllers/workloads/k8sns/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"errors"
"fmt"
"maps"
"slices"

korifiv1alpha1 "code.cloudfoundry.org/korifi/controllers/api/v1alpha1"
"code.cloudfoundry.org/korifi/controllers/controllers/workloads/k8sns"
"code.cloudfoundry.org/korifi/tools"
"code.cloudfoundry.org/korifi/tools/k8s"
"golang.org/x/exp/maps"

"github.com/google/uuid"
. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -165,7 +166,7 @@ var _ = Describe("K8S NS Reconciler Integration Tests", func() {
Expect(createdSecret.Type).To(Equal(imageRegistrySecret.Type))

By("omitting annotations from deployment tools", func() {
Expect(maps.Keys(createdSecret.Annotations)).NotTo(ContainElements("kapp.k14s.io/foo", "meta.helm.sh/baz"))
Expect(slices.Collect(maps.Keys(createdSecret.Annotations))).NotTo(ContainElements("kapp.k14s.io/foo", "meta.helm.sh/baz"))
})
})

Expand Down
5 changes: 3 additions & 2 deletions controllers/controllers/workloads/spaces/controller_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package spaces_test

import (
"maps"
"slices"
"time"

korifiv1alpha1 "code.cloudfoundry.org/korifi/controllers/api/v1alpha1"
Expand All @@ -10,7 +12,6 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gstruct"
"golang.org/x/exp/maps"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -143,7 +144,7 @@ var _ = Describe("CFSpaceReconciler Integration Tests", func() {
}).Should(Succeed())

By("omitting annotations from deployment tools", func() {
Expect(maps.Keys(createdServiceAccount.Annotations)).To(ConsistOf("cloudfoundry.org/propagate-service-account"))
Expect(slices.Collect(maps.Keys(createdServiceAccount.Annotations))).To(ConsistOf("cloudfoundry.org/propagate-service-account"))
Expect(createdServiceAccount.Annotations["cloudfoundry.org/propagate-service-account"]).To(Equal("true"))
})
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ require (
github.com/pivotal/kpack v0.15.0
github.com/satori/go.uuid v1.2.0
github.com/servicebinding/runtime v1.0.0
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
golang.org/x/text v0.16.0
gopkg.in/square/go-jose.v2 v2.6.0
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -75,6 +74,7 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 // indirect
reconciler.io/runtime v0.20.0 // indirect
)
Expand Down
5 changes: 3 additions & 2 deletions scripts/helmdoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ package main
import (
"encoding/json"
"fmt"
"maps"
"os"
"slices"
"sort"
"strings"

"golang.org/x/exp/maps"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

func printDocForSchema(schema map[string]any, indentLevel int) {
indentStr := strings.Repeat(" ", indentLevel)
names := maps.Keys(schema)
names := slices.Collect(maps.Keys(schema))
sort.Slice(names, func(a, b int) bool {
if names[a] == "global" {
return true
Expand Down

0 comments on commit 8bfc20f

Please sign in to comment.