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 23, 2018
1 parent 30a0b59 commit a6c6877
Show file tree
Hide file tree
Showing 4 changed files with 11 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
6 changes: 6 additions & 0 deletions pkg/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"

"github.com/openshift/origin/pkg/api/legacygroupification"
templateapi "github.com/openshift/origin/pkg/template/apis/template"
. "github.com/openshift/origin/pkg/template/generator"
"github.com/openshift/origin/pkg/util"
Expand Down Expand Up @@ -84,6 +85,11 @@ func (p *Processor) Process(template *templateapi.Template) field.ErrorList {
// referenced namespace.
stripNamespace(item)

// this changes oapi GVKs to groupified GVKs so they can be submitted to modern, aggregated servers
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 a6c6877

Please sign in to comment.