From 2c2f2151104c412eb09d7b93b2a3d83e35082d9a Mon Sep 17 00:00:00 2001 From: sheidkamp Date: Thu, 21 Nov 2024 13:51:06 -0500 Subject: [PATCH 1/5] Update types.go --- changelog/v1.18.0-rc2/remove-manifest-symlink.yaml | 6 ++++++ .../features/services/httproute/testdata/tcproute-crd.yaml | 1 - test/kubernetes/e2e/features/services/httproute/types.go | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelog/v1.18.0-rc2/remove-manifest-symlink.yaml delete mode 120000 test/kubernetes/e2e/features/services/httproute/testdata/tcproute-crd.yaml diff --git a/changelog/v1.18.0-rc2/remove-manifest-symlink.yaml b/changelog/v1.18.0-rc2/remove-manifest-symlink.yaml new file mode 100644 index 00000000000..d420bcd5fba --- /dev/null +++ b/changelog/v1.18.0-rc2/remove-manifest-symlink.yaml @@ -0,0 +1,6 @@ +changelog: + - type: NON_USER_FACING + issueLink: https://github.com/solo-io/solo-projects/issues/7255 + resolvesIssue: false + description: >- + Remove `tcproute-crd.yaml` symlink and update types.go to use the actual location diff --git a/test/kubernetes/e2e/features/services/httproute/testdata/tcproute-crd.yaml b/test/kubernetes/e2e/features/services/httproute/testdata/tcproute-crd.yaml deleted file mode 120000 index abdc43cdcc5..00000000000 --- a/test/kubernetes/e2e/features/services/httproute/testdata/tcproute-crd.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../projects/gateway2/crds/tcproute-crd.yaml \ No newline at end of file diff --git a/test/kubernetes/e2e/features/services/httproute/types.go b/test/kubernetes/e2e/features/services/httproute/types.go index bf431a974f5..a980361fe03 100644 --- a/test/kubernetes/e2e/features/services/httproute/types.go +++ b/test/kubernetes/e2e/features/services/httproute/types.go @@ -15,9 +15,12 @@ import ( ) var ( + // This is fragile, but symlinks don't work when the tests are imported to another repo, and its better than duplicating the file + repoRoot = filepath.Join(util.MustGetThisDir(), "..", "..", "..", "..", "..", "..") + routeWithServiceManifest = filepath.Join(util.MustGetThisDir(), "testdata", "route-with-service.yaml") serviceManifest = filepath.Join(util.MustGetThisDir(), "testdata", "service-for-route.yaml") - tcpRouteCrdManifest = filepath.Join(util.MustGetThisDir(), "testdata", "tcproute-crd.yaml") + tcpRouteCrdManifest = filepath.Join(repoRoot, "projects", "gateway2", "crds", "tcproute-crd.yaml") // Proxy resource to be translated glooProxyObjectMeta = metav1.ObjectMeta{ From 1eb8b14684d94a62371967b5f8d9692a8831800f Mon Sep 17 00:00:00 2001 From: sheidkamp Date: Thu, 21 Nov 2024 15:20:50 -0500 Subject: [PATCH 2/5] directory from crd package --- projects/gateway2/crds/crds.go | 17 +++++++++++++++++ .../e2e/features/services/httproute/types.go | 5 +++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/projects/gateway2/crds/crds.go b/projects/gateway2/crds/crds.go index d2541cee21b..14752f6df56 100644 --- a/projects/gateway2/crds/crds.go +++ b/projects/gateway2/crds/crds.go @@ -2,7 +2,24 @@ package crds import ( _ "embed" + "path" + "runtime" ) //go:embed gateway-crds.yaml var GatewayCrds []byte + +func getDirectory() string { + _, filename, _, _ := runtime.Caller(0) + return path.Dir(filename) +} + +// directory is the absolute path to the directory containing the crd files +// It can't change at runtime, so we can cache it +var directory = getDirectory() + +// Directory returns the absolute path to directory in which crds are stored (currently the same directory as this file) +// Used for tests to find the crd files if needed +func Directory() string { + return directory +} diff --git a/test/kubernetes/e2e/features/services/httproute/types.go b/test/kubernetes/e2e/features/services/httproute/types.go index a980361fe03..90efb31049c 100644 --- a/test/kubernetes/e2e/features/services/httproute/types.go +++ b/test/kubernetes/e2e/features/services/httproute/types.go @@ -9,6 +9,7 @@ import ( "github.com/solo-io/skv2/codegen/util" "github.com/onsi/gomega/gstruct" + "github.com/solo-io/gloo/projects/gateway2/crds" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -16,11 +17,11 @@ import ( var ( // This is fragile, but symlinks don't work when the tests are imported to another repo, and its better than duplicating the file - repoRoot = filepath.Join(util.MustGetThisDir(), "..", "..", "..", "..", "..", "..") + //repoRoot = filepath.Join(util.MustGetThisDir(), "..", "..", "..", "..", "..", "..") routeWithServiceManifest = filepath.Join(util.MustGetThisDir(), "testdata", "route-with-service.yaml") serviceManifest = filepath.Join(util.MustGetThisDir(), "testdata", "service-for-route.yaml") - tcpRouteCrdManifest = filepath.Join(repoRoot, "projects", "gateway2", "crds", "tcproute-crd.yaml") + tcpRouteCrdManifest = filepath.Join(crds.Directory(), "tcproute-crd.yaml") // Proxy resource to be translated glooProxyObjectMeta = metav1.ObjectMeta{ From 2db296b1b735d366520ed353bdab960ec075c34b Mon Sep 17 00:00:00 2001 From: sheidkamp Date: Thu, 21 Nov 2024 15:44:27 -0500 Subject: [PATCH 3/5] Update remove-manifest-symlink.yaml --- changelog/v1.18.0-rc2/remove-manifest-symlink.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/v1.18.0-rc2/remove-manifest-symlink.yaml b/changelog/v1.18.0-rc2/remove-manifest-symlink.yaml index d420bcd5fba..2f6a2e9812f 100644 --- a/changelog/v1.18.0-rc2/remove-manifest-symlink.yaml +++ b/changelog/v1.18.0-rc2/remove-manifest-symlink.yaml @@ -3,4 +3,4 @@ changelog: issueLink: https://github.com/solo-io/solo-projects/issues/7255 resolvesIssue: false description: >- - Remove `tcproute-crd.yaml` symlink and update types.go to use the actual location + Remove `tcproute-crd.yaml` symlink and get the crd location from the crd package. From 97b5cc317a79dea67ef8c5fb823695cc6ee9d11f Mon Sep 17 00:00:00 2001 From: sheidkamp Date: Thu, 21 Nov 2024 15:48:57 -0500 Subject: [PATCH 4/5] Update types.go --- test/kubernetes/e2e/features/services/httproute/types.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/kubernetes/e2e/features/services/httproute/types.go b/test/kubernetes/e2e/features/services/httproute/types.go index 90efb31049c..7c122f76aa3 100644 --- a/test/kubernetes/e2e/features/services/httproute/types.go +++ b/test/kubernetes/e2e/features/services/httproute/types.go @@ -16,9 +16,6 @@ import ( ) var ( - // This is fragile, but symlinks don't work when the tests are imported to another repo, and its better than duplicating the file - //repoRoot = filepath.Join(util.MustGetThisDir(), "..", "..", "..", "..", "..", "..") - routeWithServiceManifest = filepath.Join(util.MustGetThisDir(), "testdata", "route-with-service.yaml") serviceManifest = filepath.Join(util.MustGetThisDir(), "testdata", "service-for-route.yaml") tcpRouteCrdManifest = filepath.Join(crds.Directory(), "tcproute-crd.yaml") From ef82368440f349537349641af2b9097cbb6f7935 Mon Sep 17 00:00:00 2001 From: sheidkamp Date: Thu, 21 Nov 2024 16:30:52 -0500 Subject: [PATCH 5/5] Move more logic into CRD --- projects/gateway2/crds/crds.go | 7 ++++--- test/kubernetes/e2e/features/services/httproute/types.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/gateway2/crds/crds.go b/projects/gateway2/crds/crds.go index 14752f6df56..6af5799654c 100644 --- a/projects/gateway2/crds/crds.go +++ b/projects/gateway2/crds/crds.go @@ -3,6 +3,7 @@ package crds import ( _ "embed" "path" + "path/filepath" "runtime" ) @@ -18,8 +19,8 @@ func getDirectory() string { // It can't change at runtime, so we can cache it var directory = getDirectory() -// Directory returns the absolute path to directory in which crds are stored (currently the same directory as this file) +// AbsPathToCrd returns the absolute path to directory in which crds are stored (currently the same directory as this file) // Used for tests to find the crd files if needed -func Directory() string { - return directory +func AbsPathToCrd(crdFile string) string { + return filepath.Join(directory, crdFile) } diff --git a/test/kubernetes/e2e/features/services/httproute/types.go b/test/kubernetes/e2e/features/services/httproute/types.go index 7c122f76aa3..4ae4a30ef94 100644 --- a/test/kubernetes/e2e/features/services/httproute/types.go +++ b/test/kubernetes/e2e/features/services/httproute/types.go @@ -18,7 +18,7 @@ import ( var ( routeWithServiceManifest = filepath.Join(util.MustGetThisDir(), "testdata", "route-with-service.yaml") serviceManifest = filepath.Join(util.MustGetThisDir(), "testdata", "service-for-route.yaml") - tcpRouteCrdManifest = filepath.Join(crds.Directory(), "tcproute-crd.yaml") + tcpRouteCrdManifest = filepath.Join(crds.AbsPathToCrd("tcproute-crd.yaml")) // Proxy resource to be translated glooProxyObjectMeta = metav1.ObjectMeta{