@@ -21,16 +21,15 @@ import (
21
21
"path/filepath"
22
22
"strings"
23
23
24
- "github.com/operator-framework/operator-sdk/pkg/scaffold/ansible"
25
- "github.com/operator-framework/operator-sdk/pkg/scaffold/helm"
26
-
27
24
log "github.com/sirupsen/logrus"
28
25
"github.com/spf13/cobra"
29
26
)
30
27
31
28
const (
32
- SrcDir = "src"
29
+ srcDir = "src"
33
30
mainFile = "./cmd/manager/main.go"
31
+ rolesDir = "./roles"
32
+ helmChartsDir = "./helm-charts"
34
33
buildDockerfile = "./build/Dockerfile"
35
34
)
36
35
@@ -87,7 +86,7 @@ func MustGetwd() string {
87
86
// e.g: "github.com/example-inc/app-operator"
88
87
func CheckAndGetProjectGoPkg () string {
89
88
gopath := SetGopath (GetGopath ())
90
- goSrc := filepath .Join (gopath , SrcDir )
89
+ goSrc := filepath .Join (gopath , srcDir )
91
90
wd := MustGetwd ()
92
91
currPkg := strings .Replace (wd , goSrc + string (filepath .Separator ), "" , 1 )
93
92
// strip any "/" prefix from the repo path.
@@ -102,15 +101,19 @@ func GetOperatorType() OperatorType {
102
101
if _ , err := os .Stat (mainFile ); err == nil {
103
102
return OperatorTypeGo
104
103
}
105
- if stat , err := os .Stat (ansible . RolesDir ); err == nil && stat .IsDir () {
104
+ if stat , err := os .Stat (rolesDir ); err == nil && stat .IsDir () {
106
105
return OperatorTypeAnsible
107
106
}
108
- if stat , err := os .Stat (helm . HelmChartsDir ); err == nil && stat .IsDir () {
107
+ if stat , err := os .Stat (helmChartsDir ); err == nil && stat .IsDir () {
109
108
return OperatorTypeHelm
110
109
}
111
110
return OperatorTypeUnknown
112
111
}
113
112
113
+ func IsOperatorGo () bool {
114
+ return GetOperatorType () == OperatorTypeGo
115
+ }
116
+
114
117
// GetGopath gets GOPATH and makes sure it is set and non-empty.
115
118
func GetGopath () string {
116
119
gopath , ok := os .LookupEnv (GopathEnv )
0 commit comments