Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ package services
import (
"errors"
"fmt"
"maps"
"path"
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -841,8 +843,8 @@ func (feast *FeastServices) setInitContainer(podSpec *corev1.PodSpec, fsYamlB64
createCommand = strings.Join(initSlice, " ")
} else if feastProjectDir.Git != nil {
gitSlice := []string{"git"}
for key, value := range feastProjectDir.Git.Configs {
gitSlice = append(gitSlice, "-c", key+"="+value)
for _, key := range slices.Sorted(maps.Keys(feastProjectDir.Git.Configs)) {
gitSlice = append(gitSlice, "-c", key+"="+feastProjectDir.Git.Configs[key])
}
gitSlice = append(gitSlice, "clone", feastProjectDir.Git.URL, projectPath)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package services

import (
"context"
"strings"
"testing"

feastdevv1 "github.com/feast-dev/feast/infra/feast-operator/api/v1"
"github.com/feast-dev/feast/infra/feast-operator/internal/controller/handler"
Expand Down Expand Up @@ -1035,3 +1037,28 @@ var _ = Describe("Pod Container Failure Messages", func() {
Expect(containerFailureMessage(pod)).To(BeEmpty())
})
})

func TestSetInitContainerSortsGitConfigs(t *testing.T) {
fs := minimalFeatureStore()
fs.Spec.FeastProjectDir = &feastdevv1.FeastProjectDir{
Git: &feastdevv1.GitCloneOptions{
URL: "https://github.com/feast-dev/feast",
Configs: map[string]string{
"http.sslVerify": "false",
"core.longpaths": "true",
"http.proxy": "http://proxy:3128",
},
},
}
ApplyDefaultsToStatus(fs)
feast := FeastServices{Handler: handler.FeastHandler{FeatureStore: fs}}

want := "git -c core.longpaths=true -c http.proxy=http://proxy:3128 -c http.sslVerify=false clone"
for i := 0; i < 20; i++ {
podSpec := &corev1.PodSpec{}
feast.setInitContainer(podSpec, "")
if got := podSpec.InitContainers[0].Args[0]; !strings.Contains(got, want) {
t.Fatalf("got %q, want it to contain %q", got, want)
}
}
}