From b810387b216d1fa73a06ed3869e8968d98f07b81 Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Thu, 20 Dec 2018 10:52:23 -0800 Subject: [PATCH 1/2] test/e2e/memcached_test.go: symlink pkg and internal --- test/e2e/memcached_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/e2e/memcached_test.go b/test/e2e/memcached_test.go index 3f08aa6724d..3c74872f2cc 100644 --- a/test/e2e/memcached_test.go +++ b/test/e2e/memcached_test.go @@ -224,9 +224,12 @@ func TestMemcached(t *testing.T) { } // link local sdk to vendor if not in travis if repo == "" { - os.RemoveAll("vendor/github.com/operator-framework/operator-sdk/pkg") - os.Symlink(filepath.Join(gopath, "src/github.com/operator-framework/operator-sdk/pkg"), - "vendor/github.com/operator-framework/operator-sdk/pkg") + for _, dir := range []string{"pkg", "internal"} { + repoDir := filepath.Join("github.com/operator-framework/operator-sdk", dir) + vendorDir := filepath.Join("vendor", repoDir) + os.RemoveAll(vendorDir) + os.Symlink(filepath.Join(gopath, "src", repoDir), vendorDir) + } } file, err := yamlutil.GenerateCombinedGlobalManifest() From 2ce77cfb4b433fa0a58c59f4f099c805bf4b2f33 Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Thu, 20 Dec 2018 16:23:43 -0800 Subject: [PATCH 2/2] use scaffold and projutil constants --- internal/util/projutil/project_util.go | 12 +++++------- test/e2e/memcached_test.go | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/internal/util/projutil/project_util.go b/internal/util/projutil/project_util.go index 3a7bf647587..2d44ed95d7e 100644 --- a/internal/util/projutil/project_util.go +++ b/internal/util/projutil/project_util.go @@ -21,6 +21,7 @@ import ( "path/filepath" "strings" + "github.com/operator-framework/operator-sdk/pkg/scaffold" "github.com/operator-framework/operator-sdk/pkg/scaffold/ansible" "github.com/operator-framework/operator-sdk/pkg/scaffold/helm" @@ -28,16 +29,13 @@ import ( "github.com/spf13/cobra" ) -const ( - SrcDir = "src" - mainFile = "./cmd/manager/main.go" - buildDockerfile = "./build/Dockerfile" -) - const ( GopathEnv = "GOPATH" + SrcDir = "src" ) +var mainFile = filepath.Join(scaffold.ManagerDir, scaffold.CmdFile) + // OperatorType - the type of operator type OperatorType = string @@ -57,7 +55,7 @@ const ( func MustInProjectRoot() { // if the current directory has the "./build/dockerfile" file, then it is safe to say // we are at the project root. - _, err := os.Stat(buildDockerfile) + _, err := os.Stat(filepath.Join(scaffold.BuildDir, scaffold.DockerfileFile)) if err != nil { if os.IsNotExist(err) { log.Fatal("must run command in project root dir: project structure requires ./build/Dockerfile") diff --git a/test/e2e/memcached_test.go b/test/e2e/memcached_test.go index 3c74872f2cc..b5c0c27b96b 100644 --- a/test/e2e/memcached_test.go +++ b/test/e2e/memcached_test.go @@ -228,7 +228,7 @@ func TestMemcached(t *testing.T) { repoDir := filepath.Join("github.com/operator-framework/operator-sdk", dir) vendorDir := filepath.Join("vendor", repoDir) os.RemoveAll(vendorDir) - os.Symlink(filepath.Join(gopath, "src", repoDir), vendorDir) + os.Symlink(filepath.Join(gopath, projutil.SrcDir, repoDir), vendorDir) } }