File tree Expand file tree Collapse file tree 3 files changed +18
-21
lines changed Expand file tree Collapse file tree 3 files changed +18
-21
lines changed Original file line number Diff line number Diff line change 15
15
package main
16
16
17
17
import (
18
- "fmt"
19
18
"os"
20
19
21
20
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
@@ -93,8 +92,8 @@ func checkGoModulesForCmd(cmd *cobra.Command) (err error) {
93
92
if skipCheckForCmd (cmd ) {
94
93
return nil
95
94
}
96
- // Do not perform this check if the project is non-Go, as they will be
97
- // using go modules.
95
+ // Do not perform this check if the project is non-Go, as they will not
96
+ // be using go modules.
98
97
if ! projutil .IsOperatorGo () {
99
98
return nil
100
99
}
@@ -105,7 +104,7 @@ func checkGoModulesForCmd(cmd *cobra.Command) (err error) {
105
104
return nil
106
105
}
107
106
108
- return checkGoModules ()
107
+ return projutil . CheckGoModules ()
109
108
}
110
109
111
110
var commandsToSkip = map [string ]struct {}{
@@ -132,15 +131,3 @@ func skipCheckForCmd(cmd *cobra.Command) (skip bool) {
132
131
})
133
132
return skip
134
133
}
135
-
136
- func checkGoModules () error {
137
- goModOn , err := projutil .GoModOn ()
138
- if err != nil {
139
- return err
140
- }
141
- if ! goModOn {
142
- return fmt .Errorf (`using go 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` )
144
- }
145
- return nil
146
- }
Original file line number Diff line number Diff line change @@ -178,11 +178,8 @@ func doGoScaffold() error {
178
178
s .BoilerplatePath = headerFile
179
179
}
180
180
181
- if goModOn , merr := projutil .GoModOn (); merr != nil {
182
- return merr
183
- } else if ! goModOn {
184
- return errors .New (`using go modules requires GO111MODULE="on", "auto", or unset.` +
185
- ` More info: https://github.com/operator-framework/operator-sdk/blob/master/doc/user-guide.md#go-modules` )
181
+ if err := projutil .CheckGoModules (); err != nil {
182
+ return err
186
183
}
187
184
188
185
err := s .Execute (cfg ,
Original file line number Diff line number Diff line change @@ -256,3 +256,16 @@ func CheckRepo(repo string) error {
256
256
}
257
257
return nil
258
258
}
259
+
260
+ // CheckGoModules ensures that go modules are enabled.
261
+ func CheckGoModules () error {
262
+ goModOn , err := GoModOn ()
263
+ if err != nil {
264
+ return err
265
+ }
266
+ if ! goModOn {
267
+ return fmt .Errorf (`using go modules requires GO111MODULE="on", "auto", or unset.` +
268
+ ` More info: https://github.com/operator-framework/operator-sdk/blob/master/doc/user-guide.md#go-modules` )
269
+ }
270
+ return nil
271
+ }
You can’t perform that action at this time.
0 commit comments