Skip to content

Commit

Permalink
attempting to add new error
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-prindle committed Jun 18, 2021
1 parent a917b9a commit 6ebce74
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/skaffold/parser/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func getConfigs(cfgOpts configOpts, opts config.SkaffoldOptions, r *record) (Ska
if util.IsURL(pattern) {
continue
}
// TODO(aaron-prindle) verify this is the correct dir
// TODO(aaron-prindle) verify this is the correct way to get the dir
cwd, _ := util.RealWorkDir()
expanded, err := filepath.Glob(filepath.Join(cwd, pattern))
if err != nil {
Expand Down
32 changes: 32 additions & 0 deletions pkg/skaffold/schema/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,35 @@ func ConfigUnknownAPIVersionErr(version string) error {
},
})
}

// ConfigUnknownAPIVersionErr specifies that the config API version doesn't match any known versions.
func ConfigMissingManifestFile(config, file string)) error {
msg := fmt.Sprintf("missing manifest file specified %q", version)
return sErrors.NewError(fmt.Errorf(msg),
proto.ActionableErr{
Message: msg,
ErrCode: proto.StatusCode_CONFIG_UNKNOWN_API_VERSION_ERR,
Suggestions: []*proto.Suggestion{
{
SuggestionCode: proto.SuggestionCode_CONFIG_FIX_API_VERSION,
Action: "Set the config 'apiVersion' to a known value. Check https://skaffold.dev/docs/references/yaml/ for the list of valid API versions. Otherwise, check that your skaffold version is up-to-date",
},
},
})
}

// ConfigHasMissingManifestFileErr specifies that a manifest files mentioned in the config could not be found
func ConfigHasMissingManifestFileErr(config, file string) error {
msg := fmt.Sprintf("skaffold config named %q referenced file %q that could not be found", config, file)
return sErrors.NewError(fmt.Errorf(msg),
proto.ActionableErr{
Message: msg,
ErrCode: proto.StatusCode_CONFIG_MISSING_MANIFEST_FILE_ERR,
Suggestions: []*proto.Suggestion{
{
SuggestionCode: proto.SuggestionCode_CONFIG_FIX_MISSING_MANIFEST_FILE,
Action: fmt.Sprintf("Verify that file %q referenced in config %q exists and the path and naming are correct", config, file),
},
},
})
}
6 changes: 6 additions & 0 deletions pkg/skaffold/schema/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ func TestErrors(t *testing.T) {
errCode: proto.StatusCode_CONFIG_MULTI_IMPORT_PROFILE_CONFLICT_ERR,
suggestionCode: proto.SuggestionCode_CONFIG_CHECK_DEPENDENCY_PROFILES_SELECTION,
},
// TODO(aaron-prindle) add test for new error message
// {
// err: DuplicateConfigNamesAcrossFilesErr("", "", ""),
// errCode: proto.StatusCode_CONFIG_DUPLICATE_NAMES_ACROSS_FILES_ERR,
// suggestionCode: proto.SuggestionCode_CONFIG_CHANGE_NAMES,
// },
}

for i, test := range tests {
Expand Down

0 comments on commit 6ebce74

Please sign in to comment.