limit object conversion to known gvks
@@ -41,6 +41,7 @@ import (
buildv1 "github.com/openshift/api/build/v1"
imagev1 "github.com/openshift/api/image/v1"
routev1 "github.com/openshift/api/route/v1"
+ buildapi "github.com/openshift/origin/pkg/build/apis/build"
"github.com/openshift/origin/pkg/bulk"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/cmd/util/print"
@@ -443,6 +444,13 @@ func (o *AppOptions) RunNewApp() error {
return nil
}
+ supportedTypes := map[schema.GroupVersionKind]bool{
+ {Version: "v1", Kind: "Pod"}: true,
+ {Group: buildapi.GroupName, Version: "v1", Kind: "BuildConfig"}: true,
+ {Group: imageapi.GroupName, Version: "v1", Kind: "ImageStream"}: true,
+ {Group: routeapi.GroupName, Version: "v1", Kind: "Route"}: true,
+ }
+
hasMissingRepo := false
installing := []*corev1.Pod{}
indent := o.Action.DefaultIndent()
@@ -450,6 +458,13 @@ func (o *AppOptions) RunNewApp() error {
for _, item := range result.List.Items {
// these are all unstructured
unstructuredObj := item.(*unstructured.Unstructured)
+
+ // Determine if dealing with a "known" resource, containing a switch case below.
+ // If so, go through with a conversion attempt, and fail if necessary.
+ if supported := supportedTypes[unstructuredObj.GroupVersionKind()]; !supported {
+ continue
+ }
+
obj, err := legacyscheme.Scheme.New(unstructuredObj.GroupVersionKind())
if err != nil {
return err
@@ -457,6 +472,7 @@ func (o *AppOptions) RunNewApp() error {
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredObj.Object, obj); err != nil {
return err
}
+
switch t := obj.(type) {
case *corev1.Pod:
if t.Annotations[newcmd.GeneratedForJob] == "true" {
@@ -505,9 +521,9 @@ func (o *AppOptions) RunNewApp() error {
fmt.Fprintf(out, "%sAccess your application via route '%s' \n", indent, route.Spec.Host)
}
}
+
}
}
-
switch {
case len(installing) == 1:
return followInstallation(config, installing[0], o.LogsForObject)
