From ca5ed5ab99a0a64d5c4c8e2d328490d36c8b4362 Mon Sep 17 00:00:00 2001 From: Ignacio Fuertes Date: Mon, 3 Mar 2025 13:44:18 +0100 Subject: [PATCH 01/12] Change how test namespace name for e2e tests are generated to avoid conflicts when names are too long (#4678) * Change how test namespace name for e2e tests are generated to avoid conflicts when names are too long Signed-off-by: Nacho Fuertes * Take into account prefix when building namespace name Signed-off-by: Nacho Fuertes * Changed how namespace names are generated. Using hash Signed-off-by: Nacho Fuertes * Removed unused function Signed-off-by: Nacho Fuertes * Install latest CLI on action tests jobs Signed-off-by: Nacho Fuertes * Removed another unused function Signed-off-by: Nacho Fuertes * Removed unused function Signed-off-by: Nacho Fuertes --------- Signed-off-by: Nacho Fuertes --- .circleci/config.yml | 3 +++ integration/k8s-client.go | 33 --------------------------------- integration/okteto.go | 26 ++++++-------------------- 3 files changed, 9 insertions(+), 53 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ed251193c544..8422e4ff799a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,6 +10,7 @@ aliases: - &release-regex /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ - &release-branch-regex /^release-\d+\.\d+$/ - &docker-login echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin + - &install-cli curl https://get.okteto.com -sSfL | sh parameters: # The following parameters are filled by GH Actions to run CircleCI jobs @@ -155,6 +156,8 @@ jobs: - v4-pkg-cache-{{ checksum "go.sum" }} - attach_workspace: at: ./artifacts + # Install the latest CLI public available, as the actions tests uses the installed version to checkout the action branch to test + - run: *install-cli - run: name: Run actions integration tests command: | diff --git a/integration/k8s-client.go b/integration/k8s-client.go index 5bd8b0f41d16..ad406caab18d 100644 --- a/integration/k8s-client.go +++ b/integration/k8s-client.go @@ -22,45 +22,12 @@ import ( "time" "github.com/okteto/okteto/integration/commands" - "github.com/okteto/okteto/pkg/config" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/clientcmd" - clientcmdapi "k8s.io/client-go/tools/clientcmd/api" ) -// K8sClient returns a kubernetes client for current KUBECONFIG -func K8sClient() (*kubernetes.Clientset, *rest.Config, error) { - clientConfig := getClientConfig(config.GetKubeconfigPath(), "") - - config, err := clientConfig.ClientConfig() - if err != nil { - return nil, nil, err - } - - client, err := kubernetes.NewForConfig(config) - if err != nil { - return nil, nil, err - } - return client, config, nil -} - -func getClientConfig(kubeconfigPaths []string, kubeContext string) clientcmd.ClientConfig { - loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() - loadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig - loadingRules.Precedence = kubeconfigPaths - return clientcmd.NewNonInteractiveDeferredLoadingClientConfig( - loadingRules, - &clientcmd.ConfigOverrides{ - CurrentContext: kubeContext, - ClusterInfo: clientcmdapi.Cluster{Server: ""}, - }, - ) -} - func GetPodsBySelector(ctx context.Context, ns, selector string, client kubernetes.Interface) (*corev1.PodList, error) { return client.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{LabelSelector: selector}) } diff --git a/integration/okteto.go b/integration/okteto.go index a56f67658ad0..8e9cadc5f16e 100644 --- a/integration/okteto.go +++ b/integration/okteto.go @@ -14,6 +14,7 @@ package integration import ( + "crypto/sha256" "fmt" "io" "log" @@ -26,8 +27,6 @@ import ( "testing" "time" - "github.com/okteto/okteto/pkg/config" - "github.com/okteto/okteto/pkg/k8s/kubeconfig" "github.com/okteto/okteto/pkg/model" "github.com/okteto/okteto/pkg/okteto" ) @@ -79,16 +78,6 @@ func RunOktetoVersion(oktetoPath string) (string, error) { return string(o), nil } -func reduceName(s string) string { - return strings.Map(func(r rune) rune { - switch r { - case 'a', 'e', 'i', 'o', 'u', '_': - return -1 - } - return r - }, s) -} - // GetTestNamespace returns the name for a namespace func GetTestNamespace(name string) string { runtimeOS := runtime.GOOS @@ -97,16 +86,13 @@ func GetTestNamespace(name string) string { } else { runtimeOS = runtimeOS[:3] } - name = reduceName(strings.ToLower(name)) + // To avoid namespace name conflicts, we hash the test name, and add a timestamp and the OS as prefix + sha := fmt.Sprintf("%x", sha256.Sum256([]byte(name))) + finalName := fmt.Sprintf("%d-%s-%s", time.Now().Unix(), runtimeOS, sha[:8]) if prefix := os.Getenv("OKTETO_NAMESPACE_PREFIX"); prefix != "" { - name = fmt.Sprintf("%s-%s", prefix, name) + finalName = fmt.Sprintf("%s-%s", prefix, finalName) } - return strings.ToLower(fmt.Sprintf("%s-%s-%d", name, runtimeOS, time.Now().Unix())) -} - -// GetCurrentNamespace returns the current namespace of the kubeconfig path -func GetCurrentNamespace() string { - return kubeconfig.CurrentNamespace(config.GetKubeconfigPath()) + return finalName } // GetContentFromURL returns the content of the url From 564a986388f95bedc4effea29b21f8924c9717ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20L=C3=B3pez=20Barba?= Date: Thu, 6 Mar 2025 17:08:07 +0100 Subject: [PATCH 02/12] update buildkit to 0.20.1 (#4679) * update buildkit to 0.20.0 Signed-off-by: Javier Lopez * fix: update containerd to v2.0.3 and buildkit to latest version Signed-off-by: Javier Lopez --------- Signed-off-by: Javier Lopez --- go.mod | 18 ++++++------ go.sum | 58 ++++++++++++++++++--------------------- pkg/build/buildkit/opt.go | 6 +++- 3 files changed, 40 insertions(+), 42 deletions(-) diff --git a/go.mod b/go.mod index fd540b4d525b..97ca69f59904 100644 --- a/go.mod +++ b/go.mod @@ -13,9 +13,9 @@ require ( github.com/compose-spec/godotenv v1.1.1 github.com/containerd/console v1.0.4 // indirect github.com/denisbrodbeck/machineid v1.0.1 - github.com/docker/cli v27.5.0+incompatible + github.com/docker/cli v27.5.1+incompatible github.com/docker/distribution v2.8.2+incompatible // indirect - github.com/docker/docker v27.5.0+incompatible + github.com/docker/docker v27.5.1+incompatible github.com/docker/docker-credential-helpers v0.8.2 github.com/dukex/mixpanel v0.0.0-20180925151559-f8d5594f958e github.com/fatih/color v1.18.0 @@ -30,7 +30,7 @@ require ( github.com/manifoldco/promptui v0.9.0 github.com/mitchellh/go-ps v1.0.0 github.com/moby/buildkit v0.18.2 - github.com/moby/term v0.5.0 + github.com/moby/term v0.5.2 github.com/pkg/errors v0.9.1 github.com/shirou/gopsutil v3.21.11+incompatible github.com/shurcooL/graphql v0.0.0-20220606043923-3cf50f8a0a29 @@ -45,7 +45,7 @@ require ( golang.org/x/oauth2 v0.24.0 golang.org/x/sync v0.10.0 golang.org/x/term v0.27.0 - google.golang.org/grpc v1.68.1 + google.golang.org/grpc v1.69.4 gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.31.5 @@ -59,7 +59,7 @@ require ( require ( cloud.google.com/go v0.112.0 // indirect cloud.google.com/go/storage v1.36.0 // indirect - github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/ProtonMail/go-crypto v1.1.3 // indirect @@ -157,7 +157,7 @@ require ( go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect golang.org/x/net v0.33.0 // indirect - golang.org/x/sys v0.28.0 // indirect + golang.org/x/sys v0.29.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.8.0 // indirect google.golang.org/api v0.162.0 // indirect @@ -195,7 +195,7 @@ require ( github.com/bodgit/plumbing v1.3.0 // indirect github.com/bodgit/sevenzip v1.6.0 // indirect github.com/bodgit/windows v1.0.1 // indirect - github.com/containerd/containerd/v2 v2.0.2 // indirect + github.com/containerd/containerd/v2 v2.0.3 // indirect github.com/containerd/errdefs/pkg v0.3.0 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect @@ -252,9 +252,9 @@ require ( go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect go.opentelemetry.io/otel/metric v1.31.0 // indirect - golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect + golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect ) -replace github.com/moby/buildkit => github.com/okteto/buildkit v0.0.0-20250128133300-1fcbd8a9589c +replace github.com/moby/buildkit => github.com/okteto/buildkit v0.0.0-20250305162419-c75ae82352dd diff --git a/go.sum b/go.sum index b939657c180b..9297c1d29910 100644 --- a/go.sum +++ b/go.sum @@ -189,8 +189,8 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8af github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20231105174938-2b5cbb29f3e2 h1:dIScnXFlF784X79oi7MzVT6GWqr/W1uUt0pB5CsDs9M= github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20231105174938-2b5cbb29f3e2/go.mod h1:gCLVsLfv1egrcZu+GoJATN5ts75F2s62ih/457eWzOw= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg= +github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= @@ -285,14 +285,14 @@ github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUo github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb/go.mod h1:ZjrT6AXHbDs86ZSdt/osfBi5qfexBrKUdONk989Wnk4= github.com/compose-spec/godotenv v1.1.1 h1:lp+WpAInnw06YN9sV/XLUOV/9z4C+6wjJdWlrdVac7o= github.com/compose-spec/godotenv v1.1.1/go.mod h1:zF/3BOa18Z24tts5qnO/E9YURQanJTBUf7nlcCTNsyc= -github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0= -github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0= +github.com/containerd/cgroups/v3 v3.0.5 h1:44na7Ud+VwyE7LIoJ8JTNQOa549a8543BmzaJHo6Bzo= +github.com/containerd/cgroups/v3 v3.0.5/go.mod h1:SA5DLYnXO8pTGYiAHXz94qvLQTKfVM5GEVisn4jpins= github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn4ro= github.com/containerd/console v1.0.4/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/containerd/containerd/api v1.8.0 h1:hVTNJKR8fMc/2Tiw60ZRijntNMd1U+JVMyTRdsD2bS0= github.com/containerd/containerd/api v1.8.0/go.mod h1:dFv4lt6S20wTu/hMcP4350RL87qPWLVa/OHOwmmdnYc= -github.com/containerd/containerd/v2 v2.0.2 h1:GmH/tRBlTvrXOLwSpWE2vNAm8+MqI6nmxKpKBNKY8Wc= -github.com/containerd/containerd/v2 v2.0.2/go.mod h1:wIqEvQ/6cyPFUGJ5yMFanspPabMLor+bF865OHvNTTI= +github.com/containerd/containerd/v2 v2.0.3 h1:zBKgwgZsuu+LPCMzCLgA4sC4MiZzZ59ZT31XkmiISQM= +github.com/containerd/containerd/v2 v2.0.3/go.mod h1:5j9QUUaV/cy9ZeAx4S+8n9ffpf+iYnEj4jiExgcbuLY= github.com/containerd/continuity v0.4.5 h1:ZRoN1sXq9u7V6QoHMcVWGhOwDFqZ4B9i5H6un1Wh0x4= github.com/containerd/continuity v0.4.5/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE= github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= @@ -332,12 +332,12 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/docker/cli v27.5.0+incompatible h1:aMphQkcGtpHixwwhAXJT1rrK/detk2JIvDaFkLctbGM= -github.com/docker/cli v27.5.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v27.5.1+incompatible h1:JB9cieUT9YNiMITtIsguaN55PLOHhBSz3LKVc6cqWaY= +github.com/docker/cli v27.5.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v27.5.0+incompatible h1:um++2NcQtGRTz5eEgO6aJimo6/JxrTXC941hd05JO6U= -github.com/docker/docker v27.5.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.5.1+incompatible h1:4PYU5dnBYqRQi0294d1FBECqT9ECWeQAIfE8q4YnPY8= +github.com/docker/docker v27.5.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= @@ -661,8 +661,8 @@ github.com/moby/sys/user v0.3.0 h1:9ni5DlcW5an3SvRSx4MouotOygvzaXbaSrc/wGDFWPo= github.com/moby/sys/user v0.3.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs= github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= -github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= -github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= +github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -678,8 +678,8 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nwaples/rardecode/v2 v2.0.0-beta.4.0.20241112120701-034e449c6e78 h1:MYzLheyVx1tJVDqfu3YnN4jtnyALNzLvwl+f58TcvQY= github.com/nwaples/rardecode/v2 v2.0.0-beta.4.0.20241112120701-034e449c6e78/go.mod h1:yntwv/HfMc/Hbvtq9I19D1n58te3h6KsqCf3GxyfBGY= -github.com/okteto/buildkit v0.0.0-20250128133300-1fcbd8a9589c h1:dcxahwZxN0+mVpg00212vMerw/HnztnktIt77463QwQ= -github.com/okteto/buildkit v0.0.0-20250128133300-1fcbd8a9589c/go.mod h1:AwzOfszCU2lmnwct00OQKdBpRfIg4cdvMGJYC/GxIno= +github.com/okteto/buildkit v0.0.0-20250305162419-c75ae82352dd h1:kU5eEAqPDvkACvS8KHfrqw1ytTzZS61Zp+B0CYsh8ZI= +github.com/okteto/buildkit v0.0.0-20250305162419-c75ae82352dd/go.mod h1:ggmwF2T/AHh3IdSV65lRTHpAurYaSgqvNEWJF+npBHM= github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= @@ -690,8 +690,6 @@ github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQ github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626 h1:DmNGcqH3WDbV5k8OJ+esPWbqUOX5rMLR2PMvziDMJi0= -github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626/go.mod h1:BRHJJd0E+cx42OybVYSgUvZmU0B8P9gZuRXlZUP7TKI= github.com/opencontainers/selinux v1.11.1 h1:nHFvthhM0qY8/m+vfhJylliSshm8G1jJ2jDMcgULaH8= github.com/opencontainers/selinux v1.11.1/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= @@ -780,8 +778,6 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI= -github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/therootcompany/xz v1.0.1 h1:CmOtsn1CbtmyYiusbfmhmkpAAETj0wBIH6kCYaX+xzw= github.com/therootcompany/xz v1.0.1/go.mod h1:3K3UH1yCKgBneZYhuQUvJ9HPD19UEXEI0BWbMn8qNMY= github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo= @@ -849,6 +845,8 @@ go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozR go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= +go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc= +go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8= go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -879,8 +877,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk= -golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= +golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo= +golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -907,8 +905,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= -golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1079,8 +1077,8 @@ golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1160,8 +1158,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE= -golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg= +golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= +golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1370,8 +1368,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.68.1 h1:oI5oTa11+ng8r8XMMN7jAOmWfPZWbYpCFaMUTACxkM0= -google.golang.org/grpc v1.68.1/go.mod h1:+q1XYFJjShcqn0QZHvCyeR4CXPA+llXIeUIfIe00waw= +google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A= +google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1460,7 +1458,3 @@ sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+s sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= -tags.cncf.io/container-device-interface v0.8.0 h1:8bCFo/g9WODjWx3m6EYl3GfUG31eKJbaggyBDxEldRc= -tags.cncf.io/container-device-interface v0.8.0/go.mod h1:Apb7N4VdILW0EVdEMRYXIDVRZfNJZ+kmEUss2kRRQ6Y= -tags.cncf.io/container-device-interface/specs-go v0.8.0 h1:QYGFzGxvYK/ZLMrjhvY0RjpUavIn4KcmRmVP/JjdBTA= -tags.cncf.io/container-device-interface/specs-go v0.8.0/go.mod h1:BhJIkjjPh4qpys+qm4DAYtUyryaTDg9zris+AczXyws= diff --git a/pkg/build/buildkit/opt.go b/pkg/build/buildkit/opt.go index 6ead56cd1700..70721bff059f 100644 --- a/pkg/build/buildkit/opt.go +++ b/pkg/build/buildkit/opt.go @@ -195,7 +195,11 @@ func (b *SolveOptBuilder) Build(ctx context.Context, buildOptions *types.BuildOp attachable = append(attachable, ap) } else { dockerCfg := dockerConfig.LoadDefaultConfigFile(os.Stderr) - attachable = append(attachable, authprovider.NewDockerAuthProvider(dockerCfg, map[string]*authprovider.AuthTLSConfig{})) + authProviderConfig := authprovider.DockerAuthProviderConfig{ + ConfigFile: dockerCfg, + TLSConfigs: map[string]*authprovider.AuthTLSConfig{}, + } + attachable = append(attachable, authprovider.NewDockerAuthProvider(authProviderConfig)) } for _, sess := range buildOptions.SshSessions { From 3d25ff3dd6cfc9b23630d3a56c511347cedd7d09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Mar 2025 17:59:31 +0100 Subject: [PATCH 03/12] build(deps): bump rack from 3.1.10 to 3.1.11 in /samples/ruby (#4680) Bumps [rack](https://github.com/rack/rack) from 3.1.10 to 3.1.11. - [Release notes](https://github.com/rack/rack/releases) - [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md) - [Commits](https://github.com/rack/rack/compare/v3.1.10...v3.1.11) --- updated-dependencies: - dependency-name: rack dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- samples/ruby/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/ruby/Gemfile.lock b/samples/ruby/Gemfile.lock index b85688adf895..72cbd35d8536 100644 --- a/samples/ruby/Gemfile.lock +++ b/samples/ruby/Gemfile.lock @@ -6,7 +6,7 @@ GEM multi_json (1.15.0) mustermann (3.0.3) ruby2_keywords (~> 0.0.1) - rack (3.1.10) + rack (3.1.11) rack-protection (4.1.0) base64 (>= 0.1.0) logger (>= 1.6.0) From ca45beceb82ffdc37187f60af83895011474889e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Mar 2025 18:10:12 +0100 Subject: [PATCH 04/12] build(deps): bump jinja2 from 3.1.5 to 3.1.6 in /samples/python (#4681) Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.5 to 3.1.6. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.5...3.1.6) --- updated-dependencies: - dependency-name: jinja2 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- samples/python/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/python/requirements.txt b/samples/python/requirements.txt index 503e16f3af8b..39236e10166c 100644 --- a/samples/python/requirements.txt +++ b/samples/python/requirements.txt @@ -1,7 +1,7 @@ click==8.1.3 Flask==2.3.2 itsdangerous==2.1.2 -Jinja2==3.1.5 +Jinja2==3.1.6 MarkupSafe==2.1.2 pydevd-pycharm==231.7515.12 Werkzeug==3.0.6 From dd62f76f13bb9d7e04fcd238a94bb65eb3c53949 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:06:24 +0100 Subject: [PATCH 05/12] build(deps): bump rack from 3.1.11 to 3.1.12 in /samples/ruby (#4683) Bumps [rack](https://github.com/rack/rack) from 3.1.11 to 3.1.12. - [Release notes](https://github.com/rack/rack/releases) - [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md) - [Commits](https://github.com/rack/rack/compare/v3.1.11...v3.1.12) --- updated-dependencies: - dependency-name: rack dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- samples/ruby/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/ruby/Gemfile.lock b/samples/ruby/Gemfile.lock index 72cbd35d8536..c609d201e0cf 100644 --- a/samples/ruby/Gemfile.lock +++ b/samples/ruby/Gemfile.lock @@ -6,7 +6,7 @@ GEM multi_json (1.15.0) mustermann (3.0.3) ruby2_keywords (~> 0.0.1) - rack (3.1.11) + rack (3.1.12) rack-protection (4.1.0) base64 (>= 0.1.0) logger (>= 1.6.0) From 34433f7d3c9084fa399720bf5350eab63c31d757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20L=C3=B3pez=20Barba?= Date: Tue, 18 Mar 2025 14:39:21 +0100 Subject: [PATCH 06/12] add action e2e to okteto test (#4682) * add action e2e to okteto test Signed-off-by: Javier Lopez * address comments Signed-off-by: Javier Lopez --------- Signed-off-by: Javier Lopez --- integration/actions/test_test.go | 137 +++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 integration/actions/test_test.go diff --git a/integration/actions/test_test.go b/integration/actions/test_test.go new file mode 100644 index 000000000000..50756e833551 --- /dev/null +++ b/integration/actions/test_test.go @@ -0,0 +1,137 @@ +//go:build actions +// +build actions + +// Copyright 2023 The Okteto Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package actions + +import ( + "fmt" + "log" + "os" + "os/exec" + "path/filepath" + "strings" + "testing" + + "github.com/okteto/okteto/integration" + "github.com/stretchr/testify/assert" +) + +const ( + testPath = "okteto/test" +) + +func TestOktetoTestActions(t *testing.T) { + integration.SkipIfWindows(t) + namespace := integration.GetTestNamespace(t.Name()) + + assert.NoError(t, executeCreateNamespaceAction(namespace)) + + oktetoManifest, err := createOktetoTestManifest(t) + assert.NoError(t, err) + + assert.NoError(t, executeOktetoTestAction(namespace, oktetoManifest)) +} + +func executeOktetoTestAction(namespace, oktetoManifest string) error { + actionRepo := fmt.Sprintf("%s%s.git", githubHTTPSURL, testPath) + actionFolder := strings.Split(testPath, "/")[1] + log.Printf("cloning destroy path repository: %s", actionRepo) + if err := integration.CloneGitRepoWithBranch(actionRepo, oktetoVersion); err != nil { + if err := integration.CloneGitRepo(actionRepo); err != nil { + return err + } + log.Printf("cloned repo %s main branch\n", actionRepo) + } + log.Printf("cloned repo %s \n", actionRepo) + defer integration.DeleteGitRepo(actionFolder) + + builder := exec.Command("go", "build", "-o", "test", "./cmd/main.go") + builder.Dir = actionFolder + builder.Env = os.Environ() + o, err := builder.CombinedOutput() + if err != nil { + return fmt.Errorf("go build: %s", string(o)) + } + + testBinary, err := filepath.Abs(filepath.Join(actionFolder, "test")) + if err != nil { + return fmt.Errorf("filepath.Abs: %s", err) + } + + command := exec.Command(testBinary, "", namespace, "", "", "", "VAR1=Hello", "", "", "") + command.Env = os.Environ() + command.Dir = filepath.Dir(oktetoManifest) + o, err = command.CombinedOutput() + if err != nil { + return fmt.Errorf("test: %s", string(o)) + } + + log.Printf("okteto test output: \n%s\n", string(o)) + + _, err = os.Stat(filepath.Join(filepath.Dir(oktetoManifest), "coverage.txt")) + if err != nil { + return err + } + + _, err = os.Stat(filepath.Join(filepath.Dir(oktetoManifest), "reports/additional-coverage.txt")) + if err != nil { + return err + } + + if !strings.Contains(string(o), "OK unit") && !strings.Contains(string(o), "OK integration") && !strings.Contains(string(o), "OK e2e") && !strings.Contains(string(o), "VAR1=Hello") { + return fmt.Errorf("unexpected output: %s", string(o)) + } + return nil +} + +func createOktetoTestManifest(t *testing.T) (string, error) { + manifest := ` +test: + unit: + context: . + image: alpine + commands: + - echo "OK unit" + integration: + context: . + image: alpine + commands: + - echo "OK integration" + - echo "OK" > coverage.txt + - mkdir -p reports && echo "OK" > reports/additional-coverage.txt + artifacts: + - coverage.txt + - reports + e2e: + context: . + image: alpine + commands: + - echo "OK e2e" + var: + context: . + image: alpine + commands: + - echo "VAR1=$VAR1" +` + dir := t.TempDir() + log.Printf("created tempdir: %s", dir) + manifestPath := filepath.Join(dir, "okteto.yml") + manifestContent := []byte(manifest) + if err := os.WriteFile(manifestPath, manifestContent, 0600); err != nil { + return "", err + } + return manifestPath, nil +} From 8d44d3b109eb6a929517abc8a434196ec070e72d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 14:39:42 +0100 Subject: [PATCH 07/12] build(deps): bump golang.org/x/net from 0.33.0 to 0.36.0 (#4684) * build(deps): bump golang.org/x/net from 0.33.0 to 0.36.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.33.0 to 0.36.0. - [Commits](https://github.com/golang/net/compare/v0.33.0...v0.36.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] * build(deps): update Go version to 1.23.7 Signed-off-by: Javier Lopez * build(deps): update Go version to 1.23.7 in Dockerfile Signed-off-by: Javier Lopez * build(deps): update golang-ci image version to 2.7.3 in CircleCI config Signed-off-by: Javier Lopez * build(deps): downgrade Go version to 1.23.6 in Dockerfile and go.mod Signed-off-by: Javier Lopez --------- Signed-off-by: dependabot[bot] Signed-off-by: Javier Lopez Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Javier Lopez --- .circleci/config.yml | 2 +- Dockerfile | 2 +- go.mod | 14 +++++++------- go.sum | 24 ++++++++++++------------ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8422e4ff799a..9e68b3c21a38 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -35,7 +35,7 @@ orbs: executors: golang-ci: docker: - - image: okteto/golang-ci:2.7.1 + - image: okteto/golang-ci:2.7.3 environment: OKTETO_CONTEXT: https://staging.okteto.dev OKTETO_APPS_SUBDOMAIN: staging.dev.okteto.net diff --git a/Dockerfile b/Dockerfile index b79a2a5925fb..7825ecac29b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ FROM syncthing/syncthing:${SYNCTHING_VERSION} AS syncthing FROM okteto/remote:${OKTETO_REMOTE_VERSION} AS remote FROM okteto/supervisor:${OKTETO_SUPERVISOR_VERSION} AS supervisor FROM okteto/clean:${OKTETO_CLEAN_VERSION} AS clean -FROM golang:1.22.9-bookworm AS golang-builder +FROM golang:1.23.6-bookworm AS golang-builder FROM golang-builder as kustomize-builder ARG TARGETARCH diff --git a/go.mod b/go.mod index 97ca69f59904..008d1be07faf 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/okteto/okteto -go 1.22.9 +go 1.23.6 require ( github.com/Masterminds/semver/v3 v3.1.1 @@ -41,10 +41,10 @@ require ( github.com/src-d/enry/v2 v2.1.0 github.com/stern/stern v1.22.0 github.com/vbauerster/mpb/v7 v7.5.3 - golang.org/x/crypto v0.31.0 + golang.org/x/crypto v0.35.0 golang.org/x/oauth2 v0.24.0 - golang.org/x/sync v0.10.0 - golang.org/x/term v0.27.0 + golang.org/x/sync v0.11.0 + golang.org/x/term v0.29.0 google.golang.org/grpc v1.69.4 gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/yaml.v2 v2.4.0 @@ -156,9 +156,9 @@ require ( go.opentelemetry.io/otel/trace v1.31.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect - golang.org/x/net v0.33.0 // indirect - golang.org/x/sys v0.29.0 // indirect - golang.org/x/text v0.21.0 // indirect + golang.org/x/net v0.36.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.22.0 // indirect golang.org/x/time v0.8.0 // indirect google.golang.org/api v0.162.0 // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect diff --git a/go.sum b/go.sum index 9297c1d29910..2bc75b9bc7cc 100644 --- a/go.sum +++ b/go.sum @@ -865,8 +865,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= +golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -956,8 +956,8 @@ golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfS golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA= +golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -999,8 +999,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1077,15 +1077,15 @@ golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= -golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= +golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1097,8 +1097,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From d7ab9e56f65e873a0c9e1c36d69f682bac5bb35c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 11:19:39 +0100 Subject: [PATCH 08/12] build(deps): bump github.com/containerd/containerd/v2 (#4687) Bumps [github.com/containerd/containerd/v2](https://github.com/containerd/containerd) from 2.0.3 to 2.0.4. - [Release notes](https://github.com/containerd/containerd/releases) - [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md) - [Commits](https://github.com/containerd/containerd/compare/v2.0.3...v2.0.4) --- updated-dependencies: - dependency-name: github.com/containerd/containerd/v2 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 008d1be07faf..55bdc6165025 100644 --- a/go.mod +++ b/go.mod @@ -195,7 +195,7 @@ require ( github.com/bodgit/plumbing v1.3.0 // indirect github.com/bodgit/sevenzip v1.6.0 // indirect github.com/bodgit/windows v1.0.1 // indirect - github.com/containerd/containerd/v2 v2.0.3 // indirect + github.com/containerd/containerd/v2 v2.0.4 // indirect github.com/containerd/errdefs/pkg v0.3.0 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect diff --git a/go.sum b/go.sum index 2bc75b9bc7cc..52b2ddd4114b 100644 --- a/go.sum +++ b/go.sum @@ -291,8 +291,8 @@ github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn github.com/containerd/console v1.0.4/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/containerd/containerd/api v1.8.0 h1:hVTNJKR8fMc/2Tiw60ZRijntNMd1U+JVMyTRdsD2bS0= github.com/containerd/containerd/api v1.8.0/go.mod h1:dFv4lt6S20wTu/hMcP4350RL87qPWLVa/OHOwmmdnYc= -github.com/containerd/containerd/v2 v2.0.3 h1:zBKgwgZsuu+LPCMzCLgA4sC4MiZzZ59ZT31XkmiISQM= -github.com/containerd/containerd/v2 v2.0.3/go.mod h1:5j9QUUaV/cy9ZeAx4S+8n9ffpf+iYnEj4jiExgcbuLY= +github.com/containerd/containerd/v2 v2.0.4 h1:+r7yJMwhTfMm3CDyiBjMBQO8a9CTBxL2Bg/JtqtIwB8= +github.com/containerd/containerd/v2 v2.0.4/go.mod h1:5j9QUUaV/cy9ZeAx4S+8n9ffpf+iYnEj4jiExgcbuLY= github.com/containerd/continuity v0.4.5 h1:ZRoN1sXq9u7V6QoHMcVWGhOwDFqZ4B9i5H6un1Wh0x4= github.com/containerd/continuity v0.4.5/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE= github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= From f6d190f52ed229408b986f21621d3bc2aa530c81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 15:02:35 +0100 Subject: [PATCH 09/12] build(deps): bump github.com/golang-jwt/jwt/v4 from 4.5.1 to 4.5.2 (#4688) Bumps [github.com/golang-jwt/jwt/v4](https://github.com/golang-jwt/jwt) from 4.5.1 to 4.5.2. - [Release notes](https://github.com/golang-jwt/jwt/releases) - [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md) - [Commits](https://github.com/golang-jwt/jwt/compare/v4.5.1...v4.5.2) --- updated-dependencies: - dependency-name: github.com/golang-jwt/jwt/v4 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 55bdc6165025..0f382a0df38f 100644 --- a/go.mod +++ b/go.mod @@ -90,7 +90,7 @@ require ( github.com/go-openapi/swag v0.22.4 // indirect github.com/gofrs/flock v0.12.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang-jwt/jwt/v4 v4.5.1 + github.com/golang-jwt/jwt/v4 v4.5.2 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/btree v1.1.2 // indirect diff --git a/go.sum b/go.sum index 52b2ddd4114b..bae163c045ae 100644 --- a/go.sum +++ b/go.sum @@ -417,8 +417,8 @@ github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= -github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI= +github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= From 2c924ed4c9431d48aa06434783babb104783d2de Mon Sep 17 00:00:00 2001 From: Ignacio Fuertes Date: Tue, 25 Mar 2025 16:03:58 +0100 Subject: [PATCH 10/12] DEV-877: Split ignorer logic for Smart Build into 2 different functions according to the flag, and use a temporary file for the SHA calculation (#4689) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * DEV-877: Made changes to not change the default behavior when the flag is disabled Signed-off-by: Nacho Fuertes * DEV-877: Fix format of the file Signed-off-by: Nacho Fuertes * DEV-877: Speed up SHA calculation creating a temporary file Signed-off-by: Nacho Fuertes * DEV-877: Changed mock to see if a windows unit test is fixed Signed-off-by: Nacho Fuertes * DEV-877: Fix indentation of test file Signed-off-by: Nacho Fuertes * Update pkg/repository/local_git.go Co-authored-by: Javier López Barba --------- Signed-off-by: Nacho Fuertes Co-authored-by: Javier López Barba --- pkg/repository/git.go | 70 +++++---- pkg/repository/local_git.go | 119 ++++++++++++-- pkg/repository/local_git_test.go | 257 +++++++++++++++++++++++++++---- 3 files changed, 382 insertions(+), 64 deletions(-) diff --git a/pkg/repository/git.go b/pkg/repository/git.go index 3ded9fe92591..fe161afa26d7 100644 --- a/pkg/repository/git.go +++ b/pkg/repository/git.go @@ -35,7 +35,8 @@ import ( ) const ( - gitOperationTimeout = 5 * time.Second + gitOperationTimeout = 5 * time.Second + limitDiffSizeToLogInMB = 1024 * 1024 ) var ( @@ -45,26 +46,28 @@ var ( ) type gitRepoController struct { - repoGetter repositoryGetterInterface - fs afero.Fs - ignorer func(subpath string) ignore.Ignorer - path string + repoGetter repositoryGetterInterface + fs afero.Fs + ignorer func(subpath string) ignore.Ignorer + path string + shouldIgnoreFiles bool } func newGitRepoController(path string) gitRepoController { + shouldIgnoreFiles := env.LoadBoolean("OKTETO_SMART_BUILDS_IGNORE_FILES_ENABLED") return gitRepoController{ repoGetter: gitRepositoryGetter{}, path: path, fs: afero.NewOsFs(), ignorer: func(subpath string) ignore.Ignorer { - if !env.LoadBoolean("OKTETO_SMART_BUILDS_IGNORE_FILES_ENABLED") { + if !shouldIgnoreFiles { return ignore.Never } return ignore.NewMultiIgnorer( ignore.NewDockerIgnorer(filepath.Join(subpath, ".dockerignore")), ) - }, + shouldIgnoreFiles: shouldIgnoreFiles, } } @@ -95,7 +98,7 @@ func (r gitRepoController) calculateIsClean(ctx context.Context) (bool, error) { if err != nil { return false, fmt.Errorf("failed to infer the git repo's current worktree: %w", err) } - status, err := worktree.Status(ctx, "", NewLocalGit("git", &LocalExec{}, r.ignorer)) + status, err := worktree.Status(ctx, "", NewLocalGit("git", &LocalExec{}, r.ignorer, r.shouldIgnoreFiles)) if err != nil { return false, fmt.Errorf("failed to infer the git repo's status: %w", err) } @@ -272,10 +275,6 @@ func (r gitRepoController) GetDiffHash(contextDir string) (string, error) { if err != nil { return "", fmt.Errorf("failed to analyze git repo: %w", err) } - worktree, err := repo.Worktree() - if err != nil { - return "", fmt.Errorf("failed to get git repo root: %w", err) - } // go func that cancels the context after the timeout go func() { @@ -294,7 +293,7 @@ func (r gitRepoController) GetDiffHash(contextDir string) (string, error) { // go func that calculates the diff using git diff go func() { - diff, err := repo.GetDiff(ctx, contextDir, NewLocalGit("git", &LocalExec{}, r.ignorer)) + diff, err := repo.GetDiff(ctx, contextDir, NewLocalGit("git", &LocalExec{}, r.ignorer, r.shouldIgnoreFiles)) select { case <-timeoutCh: oktetoLog.Debug("Timeout exceeded calculating git diff: assuming dirty commit") @@ -320,22 +319,31 @@ func (r gitRepoController) GetDiffHash(contextDir string) (string, error) { return } - filteredUntrackedFiles := []string{} - for _, f := range untrackedFiles { - relpath := resolveRelativePath(filepath.Join(worktree.GetRoot(), f), contextDir) - shouldIgnore, err := r.ignorer(contextDir).Ignore(relpath) + if r.shouldIgnoreFiles { + worktree, err := repo.Worktree() if err != nil { - oktetoLog.Debugf("ignore error in GetDiffHash: %v", err) - } - if !shouldIgnore { - filteredUntrackedFiles = append(filteredUntrackedFiles, f) + oktetoLog.Debugf("Failed to get worktree, skipping calculation of files to ignore: %v", err) } else { - oktetoLog.Debugf("skipping %v file change in GetDiffHash based on known ignore files", f) + filteredUntrackedFiles := []string{} + for _, f := range untrackedFiles { + relpath := resolveRelativePath(filepath.Join(worktree.GetRoot(), f), contextDir) + shouldIgnore, err := r.ignorer(contextDir).Ignore(relpath) + if err != nil { + oktetoLog.Debugf("ignore error in GetDiffHash: %v", err) + } + if !shouldIgnore { + filteredUntrackedFiles = append(filteredUntrackedFiles, f) + } else { + oktetoLog.Debugf("skipping %v file change in GetDiffHash based on known ignore files", f) + } + + } + + untrackedFiles = filteredUntrackedFiles } - } - untrackedFilesContent, err := r.getUntrackedContent(ctx, filteredUntrackedFiles) + untrackedFilesContent, err := r.getUntrackedContent(ctx, untrackedFiles) select { case <-timeoutCh: oktetoLog.Debug("Timeout exceeded calculating git untracked files: assuming dirty commit") @@ -357,7 +365,13 @@ func (r gitRepoController) GetDiffHash(contextDir string) (string, error) { } hashFrom := fmt.Sprintf("%s-%s", diffResponse.diff, untrackedFilesResponse.untrackedFilesDiff) - oktetoLog.Infof("hashing diff: %s", hashFrom) + logDiff := hashFrom + if len(hashFrom) > limitDiffSizeToLogInMB { + logDiff = hashFrom[:limitDiffSizeToLogInMB] + } + + // As the diff might be huge, setting an arbitrary limit in the chars we print in the logs, if not, it could cause performance issues + oktetoLog.Infof("hashing diff: %v", logDiff) diffHash := sha256.Sum256([]byte(hashFrom)) return hex.EncodeToString(diffHash[:]), nil } @@ -386,7 +400,7 @@ func (r gitRepoController) calculateLatestDirSHA(ctx context.Context, contextDir return "", fmt.Errorf("failed to calculate latestDirCommit: failed to analyze git repo: %w", err) } - return repo.GetLatestSHA(ctx, contextDir, NewLocalGit("git", &LocalExec{}, r.ignorer)) + return repo.GetLatestSHA(ctx, contextDir, NewLocalGit("git", &LocalExec{}, r.ignorer, r.shouldIgnoreFiles)) } type repositoryGetterInterface interface { @@ -433,7 +447,7 @@ func (ogr oktetoGitRepository) calculateUntrackedFiles(ctx context.Context, cont return []string{}, fmt.Errorf("failed to infer the git repo's current worktree: %w", err) } - return worktree.ListUntrackedFiles(ctx, contextDir, NewLocalGit("git", &LocalExec{}, nil)) + return worktree.ListUntrackedFiles(ctx, contextDir, NewLocalGit("git", &LocalExec{}, nil, false)) } type oktetoGitWorktree struct { @@ -496,7 +510,7 @@ func (ogr oktetoGitWorktree) ListUntrackedFiles(ctx context.Context, workdir str // git is not available, so we fall back on git-go oktetoLog.Debug("Calculating git untrackedFiles: git is not installed, for better performances consider installing it") - status, err := ogr.Status(ctx, ogr.GetRoot(), NewLocalGit("git", &LocalExec{}, nil)) + status, err := ogr.Status(ctx, ogr.GetRoot(), NewLocalGit("git", &LocalExec{}, nil, false)) if err != nil { return []string{}, fmt.Errorf("failed to infer the git repo's status: %w", err) } diff --git a/pkg/repository/local_git.go b/pkg/repository/local_git.go index 4b57b67bd81c..c3020ba69ea7 100644 --- a/pkg/repository/local_git.go +++ b/pkg/repository/local_git.go @@ -18,6 +18,7 @@ import ( "bytes" "context" "errors" + "fmt" "io" "os" "os/exec" @@ -30,8 +31,10 @@ import ( "github.com/bluekeyes/go-gitdiff/gitdiff" "github.com/go-git/go-git/v5" + "github.com/okteto/okteto/pkg/config" "github.com/okteto/okteto/pkg/ignore" oktetoLog "github.com/okteto/okteto/pkg/log" + "github.com/spf13/afero" ) var ( @@ -147,21 +150,25 @@ type LocalGitInterface interface { } type LocalGit struct { - exec CommandExecutor - ignorer func(subpath string) ignore.Ignorer - gitPath string + exec CommandExecutor + ignorer func(subpath string) ignore.Ignorer + gitPath string + shouldIgnoreFiles bool + fs afero.Fs } -func NewLocalGit(gitPath string, exec CommandExecutor, ignorer func(path string) ignore.Ignorer) *LocalGit { +func NewLocalGit(gitPath string, exec CommandExecutor, ignorer func(path string) ignore.Ignorer, shouldIgnoreFiles bool) *LocalGit { if ignorer == nil { ignorer = func(path string) ignore.Ignorer { return ignore.Never } } return &LocalGit{ - gitPath: gitPath, - exec: exec, - ignorer: ignorer, + gitPath: gitPath, + exec: exec, + ignorer: ignorer, + shouldIgnoreFiles: shouldIgnoreFiles, + fs: afero.NewOsFs(), } } @@ -286,6 +293,16 @@ func (lg *LocalGit) GetDirContentSHA(ctx context.Context, gitPath, dirPath strin return "", errLocalGitCannotGetCommitTooManyAttempts } + if lg.shouldIgnoreFiles { + return lg.getDirContentSHAWithIgnore(ctx, gitPath, dirPath, fixAttempt) + } + + return lg.getDirContentSHAWithoutIgnore(ctx, gitPath, dirPath, fixAttempt) +} + +// getDirContentSHAWithIgnore calculates the SHA of the content of the given directory using git ls-files and git hash-object taking into account +// files to be ignored by the ignorer +func (lg *LocalGit) getDirContentSHAWithIgnore(ctx context.Context, gitPath, dirPath string, fixAttempt int) (string, error) { handleError := func(e error) (string, error) { var exitError *exec.ExitError errors.As(e, &exitError) @@ -306,6 +323,7 @@ func (lg *LocalGit) GetDirContentSHA(ctx context.Context, gitPath, dirPath strin filesRaw, err := lg.exec.RunCommand(ctx, dirPath, lg.gitPath, "--no-optional-locks", "ls-files", "-s") if err != nil { + oktetoLog.Debugf("failed to list files in directory %s: %v", dirPath, err) return handleError(err) } @@ -345,24 +363,104 @@ func (lg *LocalGit) GetDirContentSHA(ctx context.Context, gitPath, dirPath strin filteredLS := strings.Join(filteredLines, "\n") - hashObjectCmdArgs := []string{"--no-optional-locks", "hash-object", "--stdin"} - output, err := lg.exec.RunPipeCommands(ctx, gitPath, "echo", []string{filteredLS}, lg.gitPath, hashObjectCmdArgs) + // As the list of files might be too long, we write it to a file and calculate the hash of the file + f, err := lg.fs.Create(filepath.Join(config.GetOktetoHome(), fmt.Sprintf("git-untracked-%s-%d", filepath.Base(dirPath), time.Now().UnixNano()))) + if err != nil { + oktetoLog.Debugf("failed to create untracked file: %v", err) + return "", err + } + + defer func() { + err := lg.fs.Remove(f.Name()) + if err != nil { + oktetoLog.Debugf("failed to remove untracked file: %v", err) + } + }() + + _, err = f.WriteString(filteredLS) + if err != nil { + oktetoLog.Debugf("failed to write untracked file: %v", err) + return "", err + } + + hashObjectCmdArgs := []string{"--no-optional-locks", "hash-object", f.Name()} + output, err := lg.exec.RunCommand(ctx, dirPath, lg.gitPath, hashObjectCmdArgs...) if err != nil { + oktetoLog.Debugf("failed to calculate hash of directory %s: %v", dirPath, err) return handleError(err) } return string(output), nil } +// getDirContentSHAWithoutIgnore calculates the SHA of the content of the given directory using git ls-files and git hash-object +func (lg *LocalGit) getDirContentSHAWithoutIgnore(ctx context.Context, gitPath, dirPath string, fixAttempt int) (string, error) { + lsFilesCmdArgs := []string{"--no-optional-locks", "ls-files", "-s", dirPath} + hashObjectCmdArgs := []string{"--no-optional-locks", "hash-object", "--stdin"} + + output, err := lg.exec.RunPipeCommands(ctx, gitPath, lg.gitPath, lsFilesCmdArgs, lg.gitPath, hashObjectCmdArgs) + if err != nil { + oktetoLog.Debugf("error getting dir content hash %s: %v", dirPath, err) + var exitError *exec.ExitError + errors.As(err, &exitError) + if exitError != nil { + exitErr := string(exitError.Stderr) + if strings.Contains(exitErr, "detected dubious ownership in repository") { + err = lg.FixDubiousOwnershipConfig(gitPath) + if err != nil { + return "", errLocalGitCannotGetStatusCannotRecover + } + fixAttempt++ + return lg.GetDirContentSHA(ctx, gitPath, dirPath, fixAttempt) + } + } + return "", errLocalGitCannotGetStatusCannotRecover + } + return string(output), nil +} + // Diff returns the diff of the repository at the given path func (lg *LocalGit) Diff(ctx context.Context, gitPath, dirPath string, fixAttempt int) (string, error) { if fixAttempt > 1 { return "", errLocalGitCannotGetCommitTooManyAttempts } + if lg.shouldIgnoreFiles { + return lg.diffWithIgnore(ctx, gitPath, dirPath, fixAttempt) + } + + return lg.diffWithoutIgnore(ctx, gitPath, dirPath, fixAttempt) +} + +// diffWithoutIgnore calculates the diff of the repository at the given path +func (lg *LocalGit) diffWithoutIgnore(ctx context.Context, gitPath, dirPath string, fixAttempt int) (string, error) { + output, err := lg.exec.RunCommand(ctx, gitPath, lg.gitPath, "--no-optional-locks", "diff", "--no-color", "--", "HEAD", dirPath) + if err != nil { + oktetoLog.Debugf("error getting diff of directory %s: %v", dirPath, err) + var exitError *exec.ExitError + errors.As(err, &exitError) + if exitError != nil { + exitErr := string(exitError.Stderr) + if strings.Contains(exitErr, "detected dubious ownership in repository") { + err = lg.FixDubiousOwnershipConfig(gitPath) + if err != nil { + return "", errLocalGitCannotGetStatusCannotRecover + } + fixAttempt++ + return lg.GetDirContentSHA(ctx, gitPath, dirPath, fixAttempt) + } + } + return "", errLocalGitCannotGetStatusCannotRecover + } + return string(output), nil +} + +// diffWithIgnore calculates the diff of the repository at the given path taking into account files to be ignored by the ignorer +func (lg *LocalGit) diffWithIgnore(ctx context.Context, gitPath, dirPath string, fixAttempt int) (string, error) { rawOutput, err := lg.exec.RunCommand(ctx, dirPath, lg.gitPath, "--no-optional-locks", "diff", "--no-color", "HEAD", ".") if err != nil { + oktetoLog.Debugf("error getting diff of directory %s: %v", dirPath, err) var exitError *exec.ExitError errors.As(err, &exitError) if exitError != nil { @@ -381,6 +479,7 @@ func (lg *LocalGit) Diff(ctx context.Context, gitPath, dirPath string, fixAttemp files, _, err := gitdiff.Parse(bytes.NewReader(rawOutput)) if err != nil { + oktetoLog.Debugf("error parsing diff of directory %s: %v", dirPath, err) return "", err } @@ -407,7 +506,7 @@ func (lg *LocalGit) Diff(ctx context.Context, gitPath, dirPath string, fixAttemp return diff.String(), nil } -// relpath removes dirPathToRemove from fullpath and returns the relative path +// resolveRelativePath removes dirPathToRemove from absoluteFullpath and returns the relative path func resolveRelativePath(absoluteFullpath string, dirPathToRemove string) string { relpath := strings.TrimPrefix(absoluteFullpath, dirPathToRemove) return strings.TrimPrefix(relpath, string(filepath.Separator)) diff --git a/pkg/repository/local_git_test.go b/pkg/repository/local_git_test.go index 901cb4eb7626..28a50a0a2dad 100644 --- a/pkg/repository/local_git_test.go +++ b/pkg/repository/local_git_test.go @@ -16,13 +16,44 @@ package repository import ( "context" "os/exec" + "path/filepath" "runtime" "testing" "time" + "github.com/okteto/okteto/pkg/ignore" + "github.com/spf13/afero" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" ) +type mockLocalGit struct { + mock.Mock +} + +func (mlg *mockLocalGit) RunCommand(ctx context.Context, dir string, name string, arg ...string) ([]byte, error) { + args := mlg.Called(ctx, dir, name, arg) + return args.Get(0).([]byte), args.Error(1) +} + +func (mlg *mockLocalGit) LookPath(file string) (string, error) { + args := mlg.Called(file) + return args.String(0), args.Error(1) +} + +func (mlg *mockLocalGit) RunPipeCommands(ctx context.Context, dir string, cmd1 string, cmd1Args []string, cmd2 string, cmd2Args []string) ([]byte, error) { + args := mlg.Called(ctx, dir, cmd1, cmd1Args, cmd2, cmd2Args) + + return args.Get(0).([]byte), args.Error(1) +} + +type fakeIgnorer struct{} + +func (fi *fakeIgnorer) Ignore(path string) (bool, error) { + return path == filepath.Join("git", "README.md"), nil +} + type mockLocalExec struct { runCommand func(ctx context.Context, dir string, name string, arg ...string) ([]byte, error) pipeCommand func(ctx context.Context, dir string, cmd1 string, cmd1Args []string, cmd2 string, cmd2Args []string) ([]byte, error) @@ -83,7 +114,7 @@ func TestLocalGit_Exists(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - lg := NewLocalGit("git", tt.mockExec(), nil) + lg := NewLocalGit("git", tt.mockExec(), nil, false) _, err := lg.Exists() assert.ErrorIs(t, err, tt.err) }) @@ -122,7 +153,7 @@ func TestLocalGit_FixDubiousOwnershipConfig(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - lg := NewLocalGit("git", tt.mockExec(), nil) + lg := NewLocalGit("git", tt.mockExec(), nil, false) err := lg.FixDubiousOwnershipConfig("/test/dir") assert.ErrorIs(t, err, tt.err) @@ -210,7 +241,7 @@ func TestLocalGit_Status(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - lg := NewLocalGit("git", tt.mock(), nil) + lg := NewLocalGit("git", tt.mock(), nil, false) _, err := lg.Status(context.Background(), "/test/dir", "", tt.fixAttempts) assert.ErrorIs(t, err, tt.expectedErr) @@ -246,32 +277,13 @@ func Test_LocalExec_RunCommand(t *testing.T) { assert.Equal(t, "okteto\n", string(got)) } -func TestLocalGit_GetDirContentSHA(t *testing.T) { +func TestLocalGit_GetDirContentSHAWithError(t *testing.T) { tests := []struct { expectedErr error mock func() *mockLocalExec name string fixAttempts int }{ - { - name: "success", - fixAttempts: 0, - mock: func() *mockLocalExec { - return &mockLocalExec{ - runCommand: func(ctx context.Context, dir, name string, arg ...string) ([]byte, error) { - return []byte( - `100644 5cc5ccc76f0fa2674fd3b17c1b863d62eebcb853 0 Dockerfile - 100644 261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64 0 LICENSE - 100644 50675ea7dda5ea4d4204468eaf121681c204a717 0 Makefile - 100644 5a48ac3289fbec053cc3016b9f1a46d7d59597d2 0 README.md`), nil - }, - pipeCommand: func(ctx context.Context, dir string, cmd1 string, cmd1Args []string, cmd2 string, cmd2Args []string) ([]byte, error) { - return []byte("123123"), nil - }, - } - }, - expectedErr: nil, - }, { name: "failure due to too many attempts", fixAttempts: 2, @@ -289,7 +301,7 @@ func TestLocalGit_GetDirContentSHA(t *testing.T) { fixAttempts: 1, mock: func() *mockLocalExec { return &mockLocalExec{ - runCommand: func(ctx context.Context, dir string, name string, arg ...string) ([]byte, error) { + pipeCommand: func(ctx context.Context, dir string, cmd1 string, cmd1Args []string, cmd2 string, cmd2Args []string) ([]byte, error) { return nil, assert.AnError }, } @@ -300,13 +312,62 @@ func TestLocalGit_GetDirContentSHA(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - lg := NewLocalGit("git", tt.mock(), nil) + lg := NewLocalGit("git", tt.mock(), nil, false) _, err := lg.GetDirContentSHA(context.Background(), "", "/test/dir", tt.fixAttempts) assert.ErrorIs(t, err, tt.expectedErr) }) } } + +func TestLocalGit_GetDirContentSHAWithoutIgnore(t *testing.T) { + dirPath := "/test/dir" + gitPath := "git" + lsFilesCmdArgs := []string{"--no-optional-locks", "ls-files", "-s", dirPath} + hashObjectCmdArgs := []string{"--no-optional-locks", "hash-object", "--stdin"} + localGit := &mockLocalGit{} + + localGit.On("RunPipeCommands", mock.Anything, gitPath, gitPath, lsFilesCmdArgs, gitPath, hashObjectCmdArgs).Return([]byte("very complex SHA"), nil) + + lg := NewLocalGit(gitPath, localGit, nil, false) + + output, err := lg.GetDirContentSHA(context.Background(), gitPath, dirPath, 0) + + localGit.AssertExpectations(t) + require.NoError(t, err) + require.Equal(t, "very complex SHA", output) + +} + +func TestLocalGit_GetDirContentSHAWithIgnore(t *testing.T) { + dirPath := "/test/dir" + gitPath := "git" + localGit := &mockLocalGit{} + lsFilesOutput := `100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 README.md +100644 f8d0d1b317c27e75dc328e1e33d2ac8ed257db44 0 main.go +100644 a45c22d80f57524e6b605e842a48bde9c455c8f0 0 pkg/utils/helpers.go +100644 2c9be049f5eb50b3c2d03de362e8f4d3e0b96fb4 0 cmd/root.go +100644 8f7e0670619e3f6d83731c99df68307d5273b82c 0 .gitignore +100755 f8d0d1b317c27e75dc328e1e33d2ac8ed257db44 0 scripts/build.sh` + ignorer := func(filename string) ignore.Ignorer { + return &fakeIgnorer{} + } + + localGit.On("RunCommand", mock.Anything, dirPath, gitPath, []string{"--no-optional-locks", "ls-files", "-s"}).Return([]byte(lsFilesOutput), nil) + + localGit.On("RunCommand", mock.Anything, dirPath, gitPath, mock.Anything).Return([]byte("very complex SHA with ignorer"), nil) + + lg := NewLocalGit(gitPath, localGit, ignorer, true) + lg.fs = afero.NewMemMapFs() + + output, err := lg.GetDirContentSHA(context.Background(), gitPath, dirPath, 0) + + localGit.AssertExpectations(t) + require.NoError(t, err) + require.Equal(t, "very complex SHA with ignorer", output) + +} + func TestLocalGit_ListUntrackedFiles(t *testing.T) { tests := []struct { expectedErr error @@ -375,7 +436,7 @@ func TestLocalGit_ListUntrackedFiles(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - lg := NewLocalGit("git", tt.execMock(), nil) + lg := NewLocalGit("git", tt.execMock(), nil, false) files, err := lg.ListUntrackedFiles(context.Background(), "/test/dir", "/test", tt.fixAttempt) assert.Equal(t, tt.expectedFiles, files) @@ -383,3 +444,147 @@ func TestLocalGit_ListUntrackedFiles(t *testing.T) { }) } } + +func TestLocalGit_GetDiffWithError(t *testing.T) { + tests := []struct { + expectedErr error + mock func() *mockLocalExec + name string + fixAttempts int + }{ + { + name: "failure due to too many attempts", + fixAttempts: 2, + mock: func() *mockLocalExec { + return &mockLocalExec{ + runCommand: func(_ context.Context, _ string, _ string, _ ...string) ([]byte, error) { + return nil, assert.AnError + }, + } + }, + expectedErr: errLocalGitCannotGetCommitTooManyAttempts, + }, + { + name: "cannot recover", + fixAttempts: 1, + mock: func() *mockLocalExec { + return &mockLocalExec{ + runCommand: func(_ context.Context, _ string, _ string, _ ...string) ([]byte, error) { + return nil, assert.AnError + }, + } + }, + expectedErr: errLocalGitCannotGetStatusCannotRecover, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + lg := NewLocalGit("git", tt.mock(), nil, false) + _, err := lg.Diff(context.Background(), "", "/test/dir", tt.fixAttempts) + + assert.ErrorIs(t, err, tt.expectedErr) + }) + } +} + +func TestLocalGit_GetDiffWithoutIgnore(t *testing.T) { + dirPath := "/test/dir" + gitPath := "git" + diffCmdArgs := []string{"--no-optional-locks", "diff", "--no-color", "--", "HEAD", dirPath} + localGit := &mockLocalGit{} + + localGit.On("RunCommand", mock.Anything, gitPath, gitPath, diffCmdArgs).Return([]byte("very complex diff"), nil) + + lg := NewLocalGit(gitPath, localGit, nil, false) + + output, err := lg.Diff(context.Background(), gitPath, dirPath, 0) + + localGit.AssertExpectations(t) + require.NoError(t, err) + require.Equal(t, "very complex diff", output) +} + +func TestLocalGit_GetDiffWithIgnore(t *testing.T) { + dirPath := "/test/dir" + gitPath := "git" + diffCmdArgs := []string{"--no-optional-locks", "diff", "--no-color", "HEAD", "."} + diffOutput := `diff --git a/README.md b/README.md +index d14a7f3..3c9e1a0 100644 +--- a/README.md ++++ b/README.md +@@ -1,5 +1,11 @@ +-# My Project +-This project does something useful. +- +-## Getting Started +-To get started, run "main.go". ++# My Awesome Project ++ ++This project does something incredibly useful and efficient. ++ ++## Requirements ++ ++- Go 1.20 or higher ++- Git ++ ++## Getting Started ++Run the application using: "go run main.go" + +diff --git a/main.go b/main.go +index e69de29..b6fc4c3 100644 +--- a/main.go ++++ b/main.go +@@ -0,0 +1,15 @@ ++package main ++ ++import ( ++ "fmt" ++ "os" ++) ++ ++func main() { ++ name := "World" ++ if len(os.Args) > 1 { ++ name = os.Args[1] ++ } ++ fmt.Printf("Hello, %s!\n", name) ++} ++` + expectedOutput := `diff --git a/main.go b/main.go +index e69de29..b6fc4c3 100644 +--- a/main.go ++++ b/main.go +@@ -0,0 +1,15 @@ ++package main ++ ++import ( ++ "fmt" ++ "os" ++) ++ ++func main() { ++ name := "World" ++ if len(os.Args) > 1 { ++ name = os.Args[1] ++ } ++ fmt.Printf("Hello, %s!\n", name) ++} ++ +\ No newline at end of file +` + localGit := &mockLocalGit{} + + localGit.On("RunCommand", mock.Anything, dirPath, gitPath, diffCmdArgs).Return([]byte(diffOutput), nil) + + ignorer := func(filename string) ignore.Ignorer { + return &fakeIgnorer{} + } + lg := NewLocalGit(gitPath, localGit, ignorer, true) + + output, err := lg.Diff(context.Background(), gitPath, dirPath, 0) + + localGit.AssertExpectations(t) + require.NoError(t, err) + require.Equal(t, expectedOutput, output) +} From b3323dd459a9c093559ef835c31db8db00d0a3d9 Mon Sep 17 00:00:00 2001 From: Ignacio Fuertes Date: Tue, 25 Mar 2025 19:25:53 +0100 Subject: [PATCH 11/12] Avoid to get an stuck channel to send a message to an unbuffered channel when timing out the list untracked files operation (#4691) Signed-off-by: Nacho Fuertes --- pkg/repository/git.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/repository/git.go b/pkg/repository/git.go index fe161afa26d7..5b2bc3427184 100644 --- a/pkg/repository/git.go +++ b/pkg/repository/git.go @@ -268,8 +268,8 @@ func (r gitRepoController) GetDiffHash(contextDir string) (string, error) { defer cancel() timeoutCh := make(chan struct{}) - diffCh := make(chan diffResponse) - untrackedFilesCh := make(chan untrackedFilesResponse) + diffCh := make(chan diffResponse, 2) + untrackedFilesCh := make(chan untrackedFilesResponse, 2) repo, err := r.repoGetter.get(r.path) if err != nil { From 4a6454f947ead9cca570ea53cc0c6741385658d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20L=C3=B3pez=20Barba?= Date: Thu, 27 Mar 2025 11:54:07 +0100 Subject: [PATCH 12/12] feat: add depends_on annotation support for services (#4686) * feat: add depends_on annotation support for services Signed-off-by: Javier Lopez * fix: update depends_on annotation to use the correct domain Signed-off-by: Javier Lopez --------- Signed-off-by: Javier Lopez --- pkg/cmd/stack/translate.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/stack/translate.go b/pkg/cmd/stack/translate.go index 788ed7327d11..b41a07729c4d 100644 --- a/pkg/cmd/stack/translate.go +++ b/pkg/cmd/stack/translate.go @@ -16,6 +16,7 @@ package stack import ( "context" "encoding/base64" + "encoding/json" "fmt" "os" "sort" @@ -57,6 +58,9 @@ const ( // oktetoComposeVolumeAffinityEnabledEnvVar represents whether the feature flag to enable volume affinity is enabled or not oktetoComposeVolumeAffinityEnabledEnvVar = "OKTETO_COMPOSE_VOLUME_AFFINITY_ENABLED" + + // dependsOnAnnotation represents the annotation to define the depends_on field + dependsOnAnnotation = "dev.okteto.com/depends-on" ) // +enum @@ -554,18 +558,27 @@ func translateLabelSelector(svcName string, s *model.Stack) map[string]string { } func translateAnnotations(svc *model.Service) map[string]string { - result := getAnnotations() + result := getAnnotations(svc) for k, v := range svc.Annotations { result[k] = v } return result } -func getAnnotations() map[string]string { +func getAnnotations(svc *model.Service) map[string]string { annotations := map[string]string{} if utils.IsOktetoRepo() { annotations[model.OktetoSampleAnnotation] = "true" } + if len(svc.DependsOn) > 0 { + dependsOn, err := json.Marshal(svc.DependsOn) + if err != nil { + oktetoLog.Infof("error marshalling depends_on annotation: %s", err) + } else { + annotations[dependsOnAnnotation] = string(dependsOn) + } + } + return annotations }