Skip to content

Commit

Permalink
switch process to produce groupified openshift api resources
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k committed Apr 20, 2018
1 parent 45d2bb2 commit 2a62dfc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cli
package legacygroupification

import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down
5 changes: 3 additions & 2 deletions pkg/oc/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"runtime"
"strings"

"github.com/openshift/origin/pkg/api/legacygroupification"
"github.com/spf13/cobra"

kubecmd "k8s.io/kubernetes/pkg/kubectl/cmd"
Expand Down Expand Up @@ -317,8 +318,8 @@ func CommandFor(basename string) *cobra.Command {
cmd = kubecmd.NewKubectlCommand(kcmdutil.NewFactory(nil), in, out, errout)
default:
// we only need this change for `oc`. `kubectl` should behave as close to `kubectl` as we can
resource.OAPIToGroupified = OAPIToGroupified
kcmdutil.OAPIToGroupifiedGVK = OAPIToGroupifiedGVK
resource.OAPIToGroupified = legacygroupification.OAPIToGroupified
kcmdutil.OAPIToGroupifiedGVK = legacygroupification.OAPIToGroupifiedGVK
cmd = NewCommandCLI("oc", "oc", in, out, errout)
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"regexp"
"strings"

"github.com/openshift/origin/pkg/api/legacygroupification"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -84,6 +85,10 @@ func (p *Processor) Process(template *templateapi.Template) field.ErrorList {
// referenced namespace.
stripNamespace(item)

gvk := item.GetObjectKind().GroupVersionKind()
legacygroupification.OAPIToGroupifiedGVK(&gvk)
item.GetObjectKind().SetGroupVersionKind(gvk)

newItem, err := p.SubstituteParameters(paramMap, item)
if err != nil {
templateErrors = append(templateErrors, field.Invalid(idxPath.Child("parameters"), template.Parameters, err.Error()))
Expand Down
2 changes: 1 addition & 1 deletion test/templates/testdata/guestbook_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"message": "Your admin credentials are adminQ3H:dwNJiJwW",
"objects": [
{
"apiVersion": "v1",
"apiVersion": "route.openshift.io/v1",
"kind": "Route",
"metadata": {
"creationTimestamp": null,
Expand Down

0 comments on commit 2a62dfc

Please sign in to comment.