diff --git a/pkg/generate/app/errors.go b/pkg/generate/app/errors.go index 1e38fd825a56..bf08869d7f26 100644 --- a/pkg/generate/app/errors.go +++ b/pkg/generate/app/errors.go @@ -17,9 +17,9 @@ type ErrNoMatch struct { func (e ErrNoMatch) Error() string { if len(e.Qualifier) != 0 { - return fmt.Sprintf("no match for %q: %s", e.Value, e.Qualifier) + return fmt.Sprintf("unable to locate resource for %q: %s", e.Value, e.Qualifier) } - return fmt.Sprintf("no match for %q", e.Value) + return fmt.Sprintf("unable to locate resource for %q", e.Value) } // Suggestion is the usage error message returned when no match is found. diff --git a/pkg/oc/cli/cmd/newapp.go b/pkg/oc/cli/cmd/newapp.go index b8988bb73cea..095fda8a83a5 100644 --- a/pkg/oc/cli/cmd/newapp.go +++ b/pkg/oc/cli/cmd/newapp.go @@ -723,7 +723,7 @@ func handleError(err error, baseName, commandName, commandPath string, config *n // this print serves as a header for the printing of the errorGroups, but // only print it if we precede with classification errors, to help distinguish // between the two - fmt.Fprintln(buf, "Errors occurred during resource creation:") + fmt.Fprintf(buf, "Errors occurred during %s processing of arguments:\n", commandName) } for _, group := range groups { fmt.Fprint(buf, kcmdutil.MultipleErrors("error: ", group.errs)) diff --git a/pkg/oc/generate/app/cmd/newapp.go b/pkg/oc/generate/app/cmd/newapp.go index 0319737cb00f..631a75f1a73c 100644 --- a/pkg/oc/generate/app/cmd/newapp.go +++ b/pkg/oc/generate/app/cmd/newapp.go @@ -320,9 +320,17 @@ func (c *AppConfig) AddArguments(args []string) []string { switch { case c.tryToAddEnvironmentArguments(s): + // does not update c.ArgumentClassificationErrors case c.tryToAddSourceArguments(s): + // successful with first classification attempt case c.tryToAddComponentArguments(s): + // clear out any errors noted for source classification as we are successful with component + // classification + c.ArgumentClassificationErrors = []ArgumentClassificationError{} case c.tryToAddTemplateArguments(s): + // clear out any errors noted for source/component classification as we are successful with template + // classification + c.ArgumentClassificationErrors = []ArgumentClassificationError{} default: glog.V(2).Infof("treating %s as unknown\n", s) unknown = append(unknown, s) diff --git a/test/cmd/newapp.sh b/test/cmd/newapp.sh index d5958eb3c828..39ae32ceee7c 100755 --- a/test/cmd/newapp.sh +++ b/test/cmd/newapp.sh @@ -53,14 +53,13 @@ os::cmd::expect_success 'oc delete is myruby' os::cmd::expect_failure_and_text 'oc new-app https://github.com/openshift/nodejs-ex --strategy=docker' 'No Dockerfile was found' # repo related error message validation -os::cmd::expect_failure_and_text 'oc new-app mysql-persisten mysql' 'mysql-persisten as a local directory' -os::cmd::expect_failure_and_text 'oc new-app mysql-persisten mysql' 'mysql as a local directory' -os::cmd::expect_failure_and_text 'oc new-app --strategy=docker https://192.30.253.113/openshift/ruby-hello-world.git' 'as a Git repository URL: ' -os::cmd::expect_failure_and_text 'oc new-app https://www.google.com/openshift/nodejs-e' 'as a Git repository URL: ' -os::cmd::expect_failure_and_text 'oc new-app https://examplegit.com/openshift/nodejs-e' 'as a Git repository URL: ' -os::cmd::expect_failure_and_text 'oc new-build --strategy=docker https://192.30.253.113/openshift/ruby-hello-world.git' 'as a Git repository URL: ' -os::cmd::expect_failure_and_text 'oc new-build https://www.google.com/openshift/nodejs-e' 'as a Git repository URL: ' -os::cmd::expect_failure_and_text 'oc new-build https://examplegit.com/openshift/nodejs-e' 'as a Git repository URL: ' +os::cmd::expect_failure_and_text 'oc new-app mysql-persisten mysql' 'only a partial match was found' +os::cmd::expect_failure_and_text 'oc new-app --strategy=docker https://192.30.253.113/openshift/ruby-hello-world.git' 'only a partial match was found' +os::cmd::expect_failure_and_text 'oc new-app https://www.google.com/openshift/nodejs-e' 'unable to lo' +os::cmd::expect_failure_and_text 'oc new-app https://examplegit.com/openshift/nodejs-e' 'unable to lo ' +os::cmd::expect_failure_and_text 'oc new-build --strategy=docker https://192.30.253.113/openshift/ruby-hello-world.git' '--strategy is specified and none of the arguments provided could be classified as a source code location' +os::cmd::expect_failure_and_text 'oc new-build https://www.google.com/openshift/nodejs-e' 'unable to lo' +os::cmd::expect_failure_and_text 'oc new-build https://examplegit.com/openshift/nodejs-e' 'unable to lo' # setting source secret via the --source-secret flag os::cmd::expect_success_and_text 'oc new-app https://github.com/openshift/cakephp-ex --source-secret=mysecret -o yaml' 'name: mysecret' diff --git a/test/integration/newapp_test.go b/test/integration/newapp_test.go index 2587052df26f..273f2b4fc07b 100644 --- a/test/integration/newapp_test.go +++ b/test/integration/newapp_test.go @@ -154,7 +154,7 @@ func TestNewAppResolve(t *testing.T) { }, }, })}, - expectedErr: `no match for "mysql:invalid`, + expectedErr: `unable to locate resource for "mysql:invalid`, }, { name: "Successful mysql builder",