File tree 2 files changed +18
-16
lines changed
2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -24,14 +24,29 @@ Usage: from the root minikube directory, go run cmd/extract/extract.go
24
24
package main
25
25
26
26
import (
27
+ "os"
28
+ "strings"
29
+
27
30
"k8s.io/minikube/pkg/minikube/extract"
28
31
)
29
32
30
33
func main () {
31
34
paths := []string {"cmd" , "pkg" }
32
35
functions := []string {"translate.T" }
33
36
outDir := "translations"
34
- err := extract .TranslatableStrings (paths , functions , outDir )
37
+ cwd , err := os .Getwd ()
38
+ if err != nil {
39
+ panic ("Getting current working directory failed" )
40
+ }
41
+
42
+ if strings .Contains (cwd , "cmd" ) {
43
+ panic ("run extract.go from the minikube root directory" )
44
+ }
45
+
46
+ if _ , err = os .Stat (extract .ErrMapFile ); os .IsNotExist (err ) {
47
+ panic ("err_map.go doesn't exist" )
48
+ }
49
+ err = extract .TranslatableStrings (paths , functions , outDir )
35
50
36
51
if err != nil {
37
52
panic (err )
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ var blacklist = []string{
47
47
"opt %s" ,
48
48
}
49
49
50
- const errMapFile string = "pkg/minikube/problem/err_map.go"
50
+ const ErrMapFile string = "pkg/minikube/problem/err_map.go"
51
51
52
52
// state is a struct that represent the current state of the extraction process
53
53
type state struct {
@@ -114,19 +114,6 @@ func setParentFunc(e *state, f string) {
114
114
115
115
// TranslatableStrings finds all strings to that need to be translated in paths and prints them out to all json files in output
116
116
func TranslatableStrings (paths []string , functions []string , output string ) error {
117
- cwd , err := os .Getwd ()
118
- if err != nil {
119
- return errors .Wrap (err , "Getting current working directory" )
120
- }
121
-
122
- if strings .Contains (cwd , "cmd" ) {
123
- return errors .New ("run extract.go from the minikube root directory" )
124
- }
125
-
126
- if _ , err = os .Stat (errMapFile ); os .IsNotExist (err ) {
127
- return errors .New ("err_map.go doesn't exist" )
128
- }
129
-
130
117
e , err := newExtractor (functions )
131
118
132
119
if err != nil {
@@ -178,7 +165,7 @@ func inspectFile(e *state) error {
178
165
return err
179
166
}
180
167
181
- if e .filename == errMapFile {
168
+ if e .filename == ErrMapFile {
182
169
return extractAdvice (file , e )
183
170
}
184
171
You can’t perform that action at this time.
0 commit comments