From 6b98e0b09a786efae45fa5afa601a1c21d54b94c Mon Sep 17 00:00:00 2001 From: Eric Weber Date: Thu, 2 May 2024 09:21:39 -0500 Subject: [PATCH] Add replace directive clarifying comment Longhorn 8481 Signed-off-by: Eric Weber --- go.mod | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/go.mod b/go.mod index 081e6d77aa..92a7c13934 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,20 @@ module github.com/longhorn/longhorn-manager go 1.22.2 +// Replace directives are required for dependencies in this section because: +// - This module imports k8s.io/kubernetes. +// - The development for all of these dependencies is done at kubernetes/staging and then synced to other repos. +// - The go.mod file for k8s.io/kubernetes imports these dependencies with version v0.0.0 (which does not exist) and \ +// uses its own replace directives to load the appropriate code from kubernetes/staging. +// - Go is not able to find a version v0.0.0 for these dependencies and cannot meaningfully follow replace directives in +// another go.mod file. +// +// The solution (which is used by all projects that import k8s.io/kubernetes) is to add replace directives for all +// k8s.io dependencies of k8s.io/kubernetes that k8s.io/kubernetes itself replaces in its go.mod file. The replace +// directives should pin the version of each dependency to the version of k8s.io/kubernetes that is imported. For +// example, if we import k8s.io/kubernetes v1.28.5, we should use v0.28.5 of all the replace directives. Depending on +// the portions of k8s.io/kubernetes code this module actually uses, not all of the replace directives may strictly be +// necessary. However, it is better to include all of them for consistency. replace ( k8s.io/api => k8s.io/api v0.30.0 k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.30.0