Skip to content

Commit

Permalink
update oc env, return resources in list
Browse files Browse the repository at this point in the history
Running a command such as
`oc new-app https://myrepo -o yaml | oc set env -f - MYVAR=value -o
yaml` will not return a set of resources in an `api.List`, but rather
print them out individually. This prevents all items from being piped to
another `oc` command successfully, as only the last item will be parsed.

This patch appends all resources to an api.List before printing.
  • Loading branch information
juanvallejo committed Oct 18, 2016
1 parent d942e98 commit 57afc8a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/cmd/cli/cmd/set/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/spf13/cobra"
kapi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/fieldpath"
"k8s.io/kubernetes/pkg/kubectl"
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
Expand Down Expand Up @@ -489,11 +490,20 @@ func RunEnv(f *clientcmd.Factory, in io.Reader, out io.Writer, cmd *cobra.Comman
if err != nil {
return err
}
for _, object := range objects {
if err := p.PrintObj(object, out); err != nil {
return err
}

resourceList := &kapi.List{
TypeMeta: unversioned.TypeMeta{
Kind: "List",
APIVersion: outputVersion.Version,
},
ListMeta: unversioned.ListMeta{},
Items: objects,
}

if err := p.PrintObj(resourceList, out); err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit 57afc8a

Please sign in to comment.