@@ -22,8 +22,9 @@ import (
22
22
"strings"
23
23
"sync"
24
24
25
- "github.com/GoogleContainerTools/skaffold/pkg/skaffold/config "
25
+ "github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants "
26
26
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/instrumentation"
27
+ "github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner/runcontext"
27
28
"github.com/GoogleContainerTools/skaffold/proto/v1"
28
29
)
29
30
@@ -38,14 +39,14 @@ const (
38
39
Cleanup = Phase ("Cleanup" )
39
40
40
41
// Report issue text
41
- reportIssueText = "If above error is unexpected, please open an issue https://github.com/GoogleContainerTools/skaffold/issues/new to report this error"
42
+ reportIssueText = "If above error is unexpected, please open an issue " + constants . GithubIssueLink + " to report this error"
42
43
)
43
44
44
45
var (
45
- setOptionsOnce sync.Once
46
- skaffoldOpts config. SkaffoldOptions
46
+ setRunContextOnce sync.Once
47
+ runCtx runcontext. RunContext
47
48
48
- reportIssueSuggestion = func (config. SkaffoldOptions ) []* proto.Suggestion {
49
+ reportIssueSuggestion = func (runcontext. RunContext ) []* proto.Suggestion {
49
50
return []* proto.Suggestion {{
50
51
SuggestionCode : proto .SuggestionCode_OPEN_ISSUE ,
51
52
Action : reportIssueText ,
@@ -55,11 +56,11 @@ var (
55
56
56
57
type Phase string
57
58
58
- // SetSkaffoldOptions set Skaffold config options once. These options are used later to
59
- // suggest actionable error messages based on skaffold run context
60
- func SetSkaffoldOptions ( opts config. SkaffoldOptions ) {
61
- setOptionsOnce .Do (func () {
62
- skaffoldOpts = opts
59
+ // SetRunContext set Skaffold runCtx once. This run context is used later to
60
+ // suggest actionable error messages based on skaffold command line options and run context
61
+ func SetRunContext ( rc runcontext. RunContext ) {
62
+ setRunContextOnce .Do (func () {
63
+ runCtx = rc
63
64
})
64
65
}
65
66
@@ -83,7 +84,7 @@ func ShowAIError(err error) error {
83
84
for _ , v := range append (knownProblems , knownInitProblems ... ) {
84
85
if v .regexp .MatchString (err .Error ()) {
85
86
instrumentation .SetErrorCode (v .errCode )
86
- if suggestions := v .suggestion (skaffoldOpts ); suggestions != nil {
87
+ if suggestions := v .suggestion (runCtx ); suggestions != nil {
87
88
description := fmt .Sprintf ("%s\n " , err )
88
89
if v .description != nil {
89
90
description = strings .Trim (v .description (err ), "." )
@@ -98,9 +99,9 @@ func ShowAIError(err error) error {
98
99
99
100
func IsOldImageManifestProblem (err error ) (string , bool ) {
100
101
if err != nil && oldImageManifest .regexp .MatchString (err .Error ()) {
101
- if s := oldImageManifest .suggestion (skaffoldOpts ); s != nil {
102
+ if s := oldImageManifest .suggestion (runCtx ); s != nil {
102
103
return fmt .Sprintf ("%s. %s" , oldImageManifest .description (err ),
103
- concatSuggestions (oldImageManifest .suggestion (skaffoldOpts ))), true
104
+ concatSuggestions (oldImageManifest .suggestion (runCtx ))), true
104
105
}
105
106
return "" , true
106
107
}
@@ -116,7 +117,7 @@ func getErrorCodeFromError(phase Phase, err error) (proto.StatusCode, []*proto.S
116
117
if problems , ok := allErrors [phase ]; ok {
117
118
for _ , v := range problems {
118
119
if v .regexp .MatchString (err .Error ()) {
119
- return v .errCode , v .suggestion (skaffoldOpts )
120
+ return v .errCode , v .suggestion (runCtx )
120
121
}
121
122
}
122
123
}
0 commit comments