commands/new; Allow Ansible Operator to be created outside GOPATH
@@ -121,12 +121,15 @@ func mustBeNewProject() {
}
// repoPath checks if this project's repository path is rooted under $GOPATH and returns project's repository path.
+// repoPath field on generator is used primarily in generation of Go operator. For Ansible we will set it to cwd
func repoPath() string {
+ // We only care about GOPATH constraint checks if we are a Go operator
+ wd := mustGetwd()
+ if operatorType == goOperatorType {
gp := os.Getenv(gopath)
if len(gp) == 0 {
cmdError.ExitWithError(cmdError.ExitError, fmt.Errorf("$GOPATH env not set"))
}
- wd := mustGetwd()
// check if this project's repository path is rooted under $GOPATH
if !strings.HasPrefix(wd, gp) {
cmdError.ExitWithError(cmdError.ExitError, fmt.Errorf("project's repository path (%v) is not rooted under GOPATH (%v)", wd, gp))
@@ -136,6 +139,8 @@ func repoPath() string {
// strip any "/" prefix from the repo path.
return strings.TrimPrefix(rp, string(filepath.Separator))
}
+ return wd
+}
func verifyFlags() {
if len(apiVersion) == 0 {
