You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnfmt.Errorf(`dependency manager "modules" requires working directory to be in $GOPATH/src`+
149
-
` and GO111MODULE=on, or outside of $GOPATH/src and GO111MODULE="on", "auto", or unset. More info: https://github.com/operator-framework/operator-sdk/blob/master/doc/user-guide.md#go-modules`)
150
-
}
151
-
caseprojutil.DepManagerDep:
152
-
inGopathSrc, err:=projutil.WdInGoPathSrc()
153
-
iferr!=nil {
154
-
returnerr
155
-
}
156
-
if!inGopathSrc {
157
-
returnfmt.Errorf(`dependency manager "dep" requires working directory to be in $GOPATH/src`)
158
-
}
159
-
default:
160
-
returnprojutil.ErrInvalidDepManager(dm)
136
+
funccheckGoModules() error {
137
+
goModOn, err:=projutil.GoModOn()
138
+
iferr!=nil {
139
+
returnerr
140
+
}
141
+
if!goModOn {
142
+
returnfmt.Errorf(`dependency manager "modules" requires GO111MODULE="on", "auto", or unset.`+
143
+
` More info: https://github.com/operator-framework/operator-sdk/blob/master/doc/user-guide.md#go-modules`)
newCmd.Flags().StringVar(&depManager, "dep-manager", "modules", `Dependency manager the new project will use (choices: "dep", "modules")`)
49
46
newCmd.Flags().StringVar(&headerFile, "header-file", "", "Path to file containing headers for generated Go files. Copied to hack/boilerplate.go.txt")
50
47
newCmd.Flags().StringVar(&repo, "repo", "", "Project repository path. Used as the project's Go import path. This must be set if outside of $GOPATH/src with Go modules, and cannot be set if --dep-manager=dep")
log.Infof("Renamed Dockerfile to %s and replaced with newer version. Compare the new Dockerfile to your old one and manually migrate any customizations", newDockerfilePath)
Copy file name to clipboardExpand all lines: cmd/operator-sdk/new/cmd.go
+37-68Lines changed: 37 additions & 68 deletions
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,6 @@ generates a skeletal app-operator application in $HOME/projects/example.com/app-
56
56
newCmd.Flags().StringVar(&apiVersion, "api-version", "", "Kubernetes apiVersion and has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1) - used with \"ansible\" or \"helm\" types")
57
57
newCmd.Flags().StringVar(&kind, "kind", "", "Kubernetes CustomResourceDefintion kind. (e.g AppService) - used with \"ansible\" or \"helm\" types")
58
58
newCmd.Flags().StringVar(&operatorType, "type", "go", "Type of operator to initialize (choices: \"go\", \"ansible\" or \"helm\")")
59
-
newCmd.Flags().StringVar(&depManager, "dep-manager", "modules", `Dependency manager the new project will use (choices: "dep", "modules")`)
60
59
newCmd.Flags().StringVar(&repo, "repo", "", "Project repository path for Go operators. Used as the project's Go import path. This must be set if outside of $GOPATH/src with Go modules, and cannot be set if --dep-manager=dep (e.g. github.com/example-inc/my-opertor)")
61
60
newCmd.Flags().BoolVar(&gitInit, "git-init", false, "Initialize the project directory as a git repository (default false)")
62
61
newCmd.Flags().StringVar(&headerFile, "header-file", "", "Path to file containing headers for generated Go files. Copied to hack/boilerplate.go.txt")
@@ -76,7 +75,6 @@ var (
76
75
kindstring
77
76
operatorTypestring
78
77
projectNamestring
79
-
depManagerstring
80
78
headerFilestring
81
79
repostring
82
80
gitInitbool
@@ -180,26 +178,16 @@ func doGoScaffold() error {
180
178
s.BoilerplatePath=headerFile
181
179
}
182
180
183
-
varerrerror
184
-
switchm:=projutil.DepManagerType(depManager); m {
185
-
caseprojutil.DepManagerDep:
186
-
err=s.Execute(cfg, &scaffold.GopkgToml{})
187
-
caseprojutil.DepManagerGoMod:
188
-
ifgoModOn, merr:=projutil.GoModOn(); merr!=nil {
189
-
returnmerr
190
-
} elseif!goModOn {
191
-
returnerrors.New(`dependency manager "modules" requires working directory to be in $GOPATH/src`+
192
-
` and GO111MODULE=on, or outside of $GOPATH/src and GO111MODULE="on", "auto", or unset. More info: https://github.com/operator-framework/operator-sdk/blob/master/doc/user-guide.md#go-modules`)
0 commit comments