Skip to content

Commit a6e71b7

Browse files
committed
adjust newapp/newbuild error messages (arg classification vs. actual processing
1 parent cf406ea commit a6e71b7

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

pkg/generate/app/errors.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ type ErrNoMatch struct {
1717

1818
func (e ErrNoMatch) Error() string {
1919
if len(e.Qualifier) != 0 {
20-
return fmt.Sprintf("no match for %q: %s", e.Value, e.Qualifier)
20+
return fmt.Sprintf("unable to locate resource for %q: %s", e.Value, e.Qualifier)
2121
}
22-
return fmt.Sprintf("no match for %q", e.Value)
22+
return fmt.Sprintf("unable to locate resource for %q", e.Value)
2323
}
2424

2525
// Suggestion is the usage error message returned when no match is found.

pkg/oc/cli/cmd/newapp.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ func handleError(err error, baseName, commandName, commandPath string, config *n
723723
// this print serves as a header for the printing of the errorGroups, but
724724
// only print it if we precede with classification errors, to help distinguish
725725
// between the two
726-
fmt.Fprintln(buf, "Errors occurred during resource creation:")
726+
fmt.Fprintf(buf, "Errors occurred during %s processing of arguments:\n", commandName)
727727
}
728728
for _, group := range groups {
729729
fmt.Fprint(buf, kcmdutil.MultipleErrors("error: ", group.errs))

pkg/oc/generate/app/cmd/newapp.go

+8
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,17 @@ func (c *AppConfig) AddArguments(args []string) []string {
320320

321321
switch {
322322
case c.tryToAddEnvironmentArguments(s):
323+
// does not update c.ArgumentClassificationErrors
323324
case c.tryToAddSourceArguments(s):
325+
// successful with first classification attempt
324326
case c.tryToAddComponentArguments(s):
327+
// clear out any errors noted for source classification as we are successful with component
328+
// classification
329+
c.ArgumentClassificationErrors = []ArgumentClassificationError{}
325330
case c.tryToAddTemplateArguments(s):
331+
// clear out any errors noted for source/component classification as we are successful with template
332+
// classification
333+
c.ArgumentClassificationErrors = []ArgumentClassificationError{}
326334
default:
327335
glog.V(2).Infof("treating %s as unknown\n", s)
328336
unknown = append(unknown, s)

test/cmd/newapp.sh

+7-8
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,13 @@ os::cmd::expect_success 'oc delete is myruby'
5353
os::cmd::expect_failure_and_text 'oc new-app https://github.com/openshift/nodejs-ex --strategy=docker' 'No Dockerfile was found'
5454

5555
# repo related error message validation
56-
os::cmd::expect_failure_and_text 'oc new-app mysql-persisten mysql' 'mysql-persisten as a local directory'
57-
os::cmd::expect_failure_and_text 'oc new-app mysql-persisten mysql' 'mysql as a local directory'
58-
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: '
59-
os::cmd::expect_failure_and_text 'oc new-app https://www.google.com/openshift/nodejs-e' 'as a Git repository URL: '
60-
os::cmd::expect_failure_and_text 'oc new-app https://examplegit.com/openshift/nodejs-e' 'as a Git repository URL: '
61-
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: '
62-
os::cmd::expect_failure_and_text 'oc new-build https://www.google.com/openshift/nodejs-e' 'as a Git repository URL: '
63-
os::cmd::expect_failure_and_text 'oc new-build https://examplegit.com/openshift/nodejs-e' 'as a Git repository URL: '
56+
os::cmd::expect_failure_and_text 'oc new-app mysql-persisten mysql' 'only a partial match was found'
57+
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'
58+
os::cmd::expect_failure_and_text 'oc new-app https://www.google.com/openshift/nodejs-e' 'unable to lo'
59+
os::cmd::expect_failure_and_text 'oc new-app https://examplegit.com/openshift/nodejs-e' 'unable to lo '
60+
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'
61+
os::cmd::expect_failure_and_text 'oc new-build https://www.google.com/openshift/nodejs-e' 'unable to lo'
62+
os::cmd::expect_failure_and_text 'oc new-build https://examplegit.com/openshift/nodejs-e' 'unable to lo'
6463

6564
# setting source secret via the --source-secret flag
6665
os::cmd::expect_success_and_text 'oc new-app https://github.com/openshift/cakephp-ex --source-secret=mysecret -o yaml' 'name: mysecret'

test/integration/newapp_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func TestNewAppResolve(t *testing.T) {
154154
},
155155
},
156156
})},
157-
expectedErr: `no match for "mysql:invalid`,
157+
expectedErr: `unable to locate resource for "mysql:invalid`,
158158
},
159159
{
160160
name: "Successful mysql builder",

0 commit comments

Comments
 (0)